diff --git a/assets/javascripts/views/pages/codeception.coffee b/assets/javascripts/views/pages/codeception.coffee new file mode 100644 index 00000000..bcc6e4c7 --- /dev/null +++ b/assets/javascripts/views/pages/codeception.coffee @@ -0,0 +1,10 @@ +#= require views/pages/base + +class app.views.CodeceptionPage extends app.views.BasePage + LANGUAGE_RGX = /language-(\w+)/ + + prepare: -> + for el in @findAll('pre > code') + if el.className.match(LANGUAGE_RGX) + @highlightCode(el, el.className.match(LANGUAGE_RGX)[1]) + return diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 5846183b..23884a92 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -39,6 +39,7 @@ 'pages/c', 'pages/cakephp', 'pages/clojure', + 'pages/codeception', 'pages/coffeescript', 'pages/cordova', 'pages/crystal', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index ac52f946..bfa6cf8c 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -39,6 +39,7 @@ 'pages/c', 'pages/cakephp', 'pages/clojure', + 'pages/codeception', 'pages/coffeescript', 'pages/cordova', 'pages/crystal', diff --git a/assets/stylesheets/pages/_codeception.scss b/assets/stylesheets/pages/_codeception.scss new file mode 100644 index 00000000..9595bc4b --- /dev/null +++ b/assets/stylesheets/pages/_codeception.scss @@ -0,0 +1,29 @@ +._codeception { + @extend %simple; + + .warning, .alert { + @extend %note; + } + + h4 { + @extend %block-label; + } + + .alert-danger { @extend %note-red; } + + .language-yaml { + @extend .token; + + .c1 { + @extend .token.comment; + } + + .pi { + @extend .token.operator; + } + + .s { + @extend .token.string; + } + } +} diff --git a/lib/docs/filters/codeception/clean_html.rb b/lib/docs/filters/codeception/clean_html.rb new file mode 100644 index 00000000..1ac12c36 --- /dev/null +++ b/lib/docs/filters/codeception/clean_html.rb @@ -0,0 +1,20 @@ +module Docs + class Codeception + class CleanHtmlFilter < Filter + def call + root_page? ? root : other + doc + end + + def root + doc.inner_html = ' ' + end + + def other + @doc = doc.at_css('div.page, div.content') + css('.btn-group').remove + doc + end + end + end +end diff --git a/lib/docs/filters/codeception/entries.rb b/lib/docs/filters/codeception/entries.rb new file mode 100644 index 00000000..0561c03f --- /dev/null +++ b/lib/docs/filters/codeception/entries.rb @@ -0,0 +1,47 @@ +module Docs + class Codeception + class EntriesFilter < Docs::EntriesFilter + def get_name + (subpath.scan(/\d\d/).first || '') + ' ' + (at_css('h1') || at_css('h2')).content + end + + def get_type + return 'Module::' + (at_css('h1') || at_css('h2')).content if subpath.start_with?('modules') + return 'Guides' if subpath =~ /\d\d/ + (at_css('h1') || at_css('h2')).content + end + + def include_default_entry? + return true if %w(Guides).include? type + return true if type =~ /(Module)|(Util)/ + false + end + + def additional_entries + + if type =~ /Module/ + prefix = type.sub(/Module::/, '')+ '::' + pattern = '#actions ~ h4' + elsif type =~ /Functions/ + prefix = '' + pattern = 'h4' + elsif type =~ /Util/ + prefix = type.sub(/Codeception\/Util/, '')+ '::' + pattern = 'h3' + elsif type =~ /(Commands)|(Configuration)/ + prefix = '' + pattern = 'h2' + else + prefix = '' + pattern = 'none' + end + + css(pattern).map do |node| + [prefix + node.content, node['id']] + end.compact + + end + + end + end +end diff --git a/lib/docs/scrapers/codeception.rb b/lib/docs/scrapers/codeception.rb new file mode 100644 index 00000000..def14e8c --- /dev/null +++ b/lib/docs/scrapers/codeception.rb @@ -0,0 +1,24 @@ +module Docs + class Codeception < UrlScraper + self.name = 'Codeception' + self.type = 'codeception' + self.root_path = 'index.html' + self.release = '2.2' + self.base_url = 'http://codeception.com/docs/' + self.links = { + home: 'http://codeception.com/', + code: 'https://github.com/codeception/codeception' + } + + html_filters.push 'codeception/clean_html', 'codeception/entries', 'title' + + options[:root_title] = 'Codeception' + options[:title] = false + options[:skip_patterns] = [/install/] + + options[:attribution] = <<-HTML + © 2011–2016 Michael Bodnarchuk and Contributors
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/codeception/16.png b/public/icons/docs/codeception/16.png new file mode 100644 index 00000000..e641ecbb Binary files /dev/null and b/public/icons/docs/codeception/16.png differ diff --git a/public/icons/docs/codeception/16@2x.png b/public/icons/docs/codeception/16@2x.png new file mode 100644 index 00000000..369f74fc Binary files /dev/null and b/public/icons/docs/codeception/16@2x.png differ diff --git a/public/icons/docs/codeception/SOURCE b/public/icons/docs/codeception/SOURCE new file mode 100644 index 00000000..efa025de --- /dev/null +++ b/public/icons/docs/codeception/SOURCE @@ -0,0 +1 @@ +https://www.openhub.net/p/codeception