Showing the changes to lib/docs (3 of 13 files). Show all
Unified · Split
| @@ -0,0 +1,31 @@ | |||
| 1 | module Docs | ||
| 2 | class Mongoose | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | css('hr', '.showcode', '.sourcecode').remove | ||
| 6 | |||
| 7 | if slug == 'api' | ||
| 8 | at_css('.controls').after('<h1>Mongoose API</h1>') | ||
| 9 | |||
| 10 | css('.private', '.controls').remove | ||
| 11 | |||
| 12 | css('a + .method').each do |node| | ||
| 13 | node.previous_element.replace("<h2>#{node.previous_element.to_html}</h2>") | ||
| 14 | end | ||
| 15 | else | ||
| 16 | at_css('h2').name = 'h1' | ||
| 17 | |||
| 18 | css('h3').each do |node| | ||
| 19 | node.name = 'h2' | ||
| 20 | end | ||
| 21 | end | ||
| 22 | |||
| 23 | css('pre > code', 'h1 + ul', '.module', '.item', 'h3 > a', 'h3 code').each do |node| | ||
| 24 | node.before(node.children).remove | ||
| 25 | end | ||
| 26 | |||
| 27 | doc | ||
| 28 | end | ||
| 29 | end | ||
| 30 | end | ||
| 31 | end | ||
| @@ -0,0 +1,39 @@ | |||
| 1 | module Docs | ||
| 2 | class Mongoose | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | if slug == 'api' | ||
| 6 | 'Mongoose' | ||
| 7 | else | ||
| 8 | at_css('h1').content | ||
| 9 | end | ||
| 10 | end | ||
| 11 | |||
| 12 | def get_type | ||
| 13 | if slug == 'api' | ||
| 14 | 'Mongoose' | ||
| 15 | else | ||
| 16 | 'Guides' | ||
| 17 | end | ||
| 18 | end | ||
| 19 | |||
| 20 | def additional_entries | ||
| 21 | return [] unless slug == 'api' | ||
| 22 | entries = [] | ||
| 23 | |||
| 24 | css('h3[id]').each do |node| | ||
| 25 | next if node['id'] == 'index_' | ||
| 26 | |||
| 27 | name = node.content.strip | ||
| 28 | name.sub! %r{\(.+\)}, '()' | ||
| 29 | next if name.include?(' ') | ||
| 30 | |||
| 31 | type = name.split(/[#\.\(]/).first | ||
| 32 | entries << [name, node['id'], type] | ||
| 33 | end | ||
| 34 | |||
| 35 | entries | ||
| 36 | end | ||
| 37 | end | ||
| 38 | end | ||
| 39 | end | ||
| @@ -0,0 +1,25 @@ | |||
| 1 | module Docs | ||
| 2 | class Mongoose < UrlScraper | ||
| 3 | self.name = 'Mongoose' | ||
| 4 | self.type = 'mongoose' | ||
| 5 | self.version = '3.8.17' | ||
| 6 | self.base_url = 'http://mongoosejs.com/docs/' | ||
| 7 | self.root_path = 'index.html' | ||
| 8 | self.initial_paths = %w(guide.html api.html) | ||
| 9 | |||
| 10 | html_filters.push 'mongoose/clean_html', 'mongoose/entries' | ||
| 11 | |||
| 12 | options[:container] = '#content' | ||
| 13 | |||
| 14 | options[:skip] = %w( | ||
| 15 | faq.html | ||
| 16 | prior.html | ||
| 17 | migration.html | ||
| 18 | plugins) | ||
| 19 | |||
| 20 | options[:attribution] = <<-HTML | ||
| 21 | © 2010 LearnBoost<br> | ||
| 22 | Licensed under the MIT License. | ||
| 23 | HTML | ||
| 24 | end | ||
| 25 | end | ||