Showing the changes to lib/docs (3 of 13 files). Show all
Unified · Split
| @@ -2,17 +2,40 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Codeception |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − root_page? ? root : other | |
| 6 | − doc | |
| 7 | − end | |
| 5 | + @doc = doc.at_css('div.page, div.content') | |
| 8 | 6 | |
| 9 | − def root | |
| 10 | − doc.inner_html = ' ' | |
| 11 | − end | |
| 7 | + while doc.element_children.length == 1 | |
| 8 | + doc.first_element_child.before(doc.first_element_child.children).remove | |
| 9 | + end | |
| 10 | + | |
| 11 | + if root_page? | |
| 12 | + at_css('h1').content = 'Codeception Documentation' | |
| 13 | + end | |
| 14 | + | |
| 15 | + unless at_css('h1') | |
| 16 | + at_css('h2').name = 'h1' | |
| 17 | + end | |
| 18 | + | |
| 19 | + unless at_css('h2') | |
| 20 | + css('h3').each { |node| node.name = 'h2' } | |
| 21 | + css('h4').each { |node| node.name = 'h3' } | |
| 22 | + end | |
| 12 | 23 | |
| 13 | − def other | |
| 14 | − @doc = doc.at_css('div.page, div.content') | |
| 15 | 24 | css('.btn-group').remove |
| 25 | + | |
| 26 | + css('.alert:last-child').each do |node| | |
| 27 | + node.remove if node.content.include?('taken from the source code') | |
| 28 | + end | |
| 29 | + | |
| 30 | + css('.highlight').each do |node| | |
| 31 | + node.before(node.children).remove | |
| 32 | + end | |
| 33 | + | |
| 34 | + css('pre > code').each do |node| | |
| 35 | + node.parent['data-language'] = node['data-lang'] | |
| 36 | + node.parent.content = node.parent.content | |
| 37 | + end | |
| 38 | + | |
| 16 | 39 | doc |
| 17 | 40 | end |
| 18 | 41 | end |
| @@ -2,46 +2,48 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Codeception |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | − (subpath.scan(/\d\d/).first || '') + ' ' + (at_css('h1') || at_css('h2')).content | |
| 6 | − end | |
| 5 | + name = (at_css('h1') || at_css('h2')).content | |
| 7 | 6 | |
| 8 | − def get_type | |
| 9 | − return 'Module::' + (at_css('h1') || at_css('h2')).content if subpath.start_with?('modules') | |
| 10 | − return 'Guides' if subpath =~ /\d\d/ | |
| 11 | − (at_css('h1') || at_css('h2')).content | |
| 7 | + if number = subpath[/\A\d+/] | |
| 8 | + name.prepend "#{number.to_i}. " | |
| 9 | + end | |
| 10 | + | |
| 11 | + name | |
| 12 | 12 | end |
| 13 | 13 | |
| 14 | − def include_default_entry? | |
| 15 | − return true if %w(Guides).include? type | |
| 16 | − return true if type =~ /(Module)|(Util)/ | |
| 17 | − false | |
| 14 | + def get_type | |
| 15 | + if subpath =~ /\d\d/ | |
| 16 | + 'Guides' | |
| 17 | + elsif subpath.start_with?('modules') | |
| 18 | + "Module: #{name}" | |
| 19 | + elsif name.include?('Util') | |
| 20 | + "Util Class: #{name.split('\\').last}" | |
| 21 | + else | |
| 22 | + "Reference: #{name}" | |
| 23 | + end | |
| 18 | 24 | end |
| 19 | 25 | |
| 20 | 26 | def additional_entries |
| 21 | − | |
| 22 | 27 | if type =~ /Module/ |
| 23 | − prefix = type.sub(/Module::/, '')+ '::' | |
| 28 | + prefix = "#{name}::" | |
| 24 | 29 | pattern = '#actions ~ h4' |
| 25 | 30 | elsif type =~ /Functions/ |
| 26 | 31 | prefix = '' |
| 27 | − pattern = 'h4' | |
| 28 | − elsif type =~ /Util/ | |
| 29 | − prefix = type.sub(/Codeception\/Util/, '')+ '::' | |
| 32 | + pattern = '#page h4' | |
| 33 | + elsif name =~ /Util/ | |
| 34 | + prefix = "#{name.remove('Codeception\\Util\\')}::" | |
| 30 | 35 | pattern = 'h3' |
| 31 | 36 | elsif type =~ /(Commands)|(Configuration)/ |
| 32 | − prefix = '' | |
| 33 | − pattern = 'h2' | |
| 34 | − else | |
| 35 | 37 | prefix = '' |
| 36 | − pattern = 'none' | |
| 38 | + pattern = 'h2' | |
| 37 | 39 | end |
| 38 | 40 | |
| 41 | + return [] unless pattern | |
| 42 | + | |
| 39 | 43 | css(pattern).map do |node| |
| 40 | 44 | [prefix + node.content, node['id']] |
| 41 | 45 | end.compact |
| 42 | − | |
| 43 | 46 | end |
| 44 | − | |
| 45 | 47 | end |
| 46 | 48 | end |
| 47 | 49 | end |
| @@ -2,22 +2,20 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Codeception < UrlScraper |
| 3 | 3 | self.name = 'Codeception' |
| 4 | 4 | self.type = 'codeception' |
| 5 | − self.root_path = 'index.html' | |
| 6 | − self.release = '2.2' | |
| 5 | + self.release = '2.2.6' | |
| 7 | 6 | self.base_url = 'http://codeception.com/docs/' |
| 7 | + self.root_path = 'index.html' | |
| 8 | 8 | self.links = { |
| 9 | 9 | home: 'http://codeception.com/', |
| 10 | 10 | code: 'https://github.com/codeception/codeception' |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | − html_filters.push 'codeception/clean_html', 'codeception/entries', 'title' | |
| 13 | + html_filters.push 'codeception/entries', 'codeception/clean_html' | |
| 14 | 14 | |
| 15 | − options[:root_title] = 'Codeception' | |
| 16 | − options[:title] = false | |
| 17 | 15 | options[:skip_patterns] = [/install/] |
| 18 | 16 | |
| 19 | 17 | options[:attribution] = <<-HTML |
| 20 | − © 2011–2016 Michael Bodnarchuk and Contributors<br> | |
| 18 | + © 2011–2016 Michael Bodnarchuk and contributors<br> | |
| 21 | 19 | Licensed under the MIT License. |
| 22 | 20 | HTML |
| 23 | 21 | end |