Showing the changes to lib/docs (3 of 14 files). Show all
Unified · Split
| @@ -2,15 +2,21 @@ module Docs · 1 unmodified line | |||
| 2 | class Sinon | 2 | class Sinon |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | css('> p:first-child', 'a.api', 'ul.nav').remove | 5 | if root_page? |
| 6 | at_css('h1').content = 'Sinon.JS' | ||
| 7 | else | ||
| 8 | css('h1').each do |node| | ||
| 9 | node.content = node.content.remove(' - Sinon.JS') | ||
| 10 | end | ||
| 11 | end | ||
| 6 | 12 | ||
| 7 | css('.section', 'h2 code', 'h3 code').each do |node| | 13 | css('.post', '.post-header', '.post-content', 'pre code').each do |node| |
| 8 | node.before(node.children).remove | 14 | node.before(node.children).remove |
| 9 | end | 15 | end |
| 10 | 16 | ||
| 11 | # Remove code highlighting | 17 | css('h1 + h1').remove |
| 18 | |||
| 12 | css('pre').each do |node| | 19 | css('pre').each do |node| |
| 13 | node.content = node.content | ||
| 14 | node['data-language'] = 'javascript' | 20 | node['data-language'] = 'javascript' |
| 15 | end | 21 | end |
| 16 | 22 | ||
| @@ -1,46 +1,27 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Sinon | 2 | class Sinon |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | def additional_entries | 4 | def get_name |
| 5 | entries = [] | 5 | at_css('h1').content.strip |
| 6 | type = config = nil | 6 | end |
| 7 | |||
| 8 | css('*').each do |node| | ||
| 9 | if node.name == 'h2' | ||
| 10 | config = false | ||
| 11 | type = node.content.strip | ||
| 12 | type.remove! 'Test ' | ||
| 13 | type.remove! 'Sinon.JS ' | ||
| 14 | type = type[0].upcase + type.from(1) | ||
| 15 | |||
| 16 | id = type.parameterize | ||
| 17 | node['id'] = id | ||
| 18 | 7 | ||
| 19 | entries << [type, id, 'Sections'] | 8 | def get_type |
| 20 | elsif node.name == 'h3' && node.content.include?('sinon.config') | 9 | name |
| 21 | config = true | 10 | end |
| 22 | elsif node.name == 'dl' | ||
| 23 | node.css('dt > code').each do |code| | ||
| 24 | name = code.content.strip | ||
| 25 | name.sub! %r{\(.*\);?}, '()' | ||
| 26 | name.sub! %r{\Aserver.(\w+)\s=.*\z}, 'server.\1' | ||
| 27 | name.remove! '`' | ||
| 28 | name.remove! %r{\A.+?\=\s+} | ||
| 29 | name.remove! %r{\A\w+?\s} | ||
| 30 | name.prepend 'sinon.config.' if config | ||
| 31 | 11 | ||
| 32 | next if name =~ /\s/ | 12 | def additional_entries |
| 33 | next if entries.any? { |entry| entry[0].casecmp(name) == 0 } | 13 | css('h4 > code').each_with_object [] do |node, entries| |
| 14 | name = node.content.strip | ||
| 15 | name.sub! %r{\s*\(.*\);?}, '()' | ||
| 16 | name.sub! %r{\A(\w+\.\w+)\s+\=.*}, '\1' | ||
| 17 | name.remove! %r{\A.+?\=\s+} | ||
| 18 | name.remove! %r{\A\w+?\s} | ||
| 19 | name.remove! %r{;\z} | ||
| 34 | 20 | ||
| 35 | id = name.parameterize | 21 | next if entries.any? { |entry| entry[0].casecmp(name) == 0 } |
| 36 | code.parent['id'] = id | ||
| 37 | 22 | ||
| 38 | entries << [name, id, type] | 23 | entries << [name, node.parent['id']] |
| 39 | end | ||
| 40 | end | ||
| 41 | end | 24 | end |
| 42 | |||
| 43 | entries | ||
| 44 | end | 25 | end |
| 45 | end | 26 | end |
| 46 | end | 27 | end |
| @@ -1,23 +1,31 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Sinon < UrlScraper | 2 | class Sinon < UrlScraper |
| 3 | self.name = 'Sinon' | 3 | self.name = 'Sinon.JS' |
| 4 | self.slug = 'sinon' | ||
| 4 | self.type = 'sinon' | 5 | self.type = 'sinon' |
| 5 | self.release = '1.17.5' | ||
| 6 | self.base_url = 'http://sinonjs.org/docs/' | ||
| 7 | self.links = { | 6 | self.links = { |
| 8 | home: 'http://sinonjs.org/', | 7 | home: 'http://sinonjs.org/', |
| 9 | code: 'https://github.com/cjohansen/Sinon.JS' | 8 | code: 'https://github.com/sinonjs/sinon' |
| 10 | } | 9 | } |
| 11 | 10 | ||
| 12 | html_filters.push 'sinon/clean_html', 'sinon/entries', 'title' | 11 | html_filters.push 'sinon/clean_html', 'sinon/entries' |
| 13 | 12 | ||
| 14 | options[:title] = 'Sinon.JS' | 13 | options[:title] = 'Sinon.JS' |
| 15 | options[:container] = '.docs' | 14 | options[:container] = '.content .container' |
| 16 | options[:skip_links] = true | ||
| 17 | 15 | ||
| 18 | options[:attribution] = <<-HTML | 16 | options[:attribution] = <<-HTML |
| 19 | © 2010–2016 Christian Johansen<br> | 17 | © 2010–2017 Christian Johansen<br> |
| 20 | Licensed under the BSD License. | 18 | Licensed under the BSD License. |
| 21 | HTML | 19 | HTML |
| 20 | |||
| 21 | version '2' do | ||
| 22 | self.release = '2.1.0' | ||
| 23 | self.base_url = "http://sinonjs.org/releases/v#{release}/" | ||
| 24 | end | ||
| 25 | |||
| 26 | version '1' do | ||
| 27 | self.release = '1.17.7' | ||
| 28 | self.base_url = "http://sinonjs.org/releases/v#{release}/" | ||
| 29 | end | ||
| 22 | end | 30 | end |
| 23 | end | 31 | end |