Showing the changes to lib/docs (3 of 14 files). Show all
Unified · Split
| @@ -0,0 +1,22 @@ | ||
| 1 | +module Docs | |
| 2 | + class Requirejs | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + css('.sectionMark', '.hbox > .sect').remove | |
| 6 | + css('h1 + .note').remove if root_page? | |
| 7 | + | |
| 8 | + css('.section', 'pre > code').each do |node| | |
| 9 | + node.before(node.children).remove | |
| 10 | + end | |
| 11 | + | |
| 12 | + css('h2', 'h3', 'h4').each do |node| | |
| 13 | + next unless link = node.at_css('a[name]') | |
| 14 | + node['id'] = link['name'] | |
| 15 | + link.before(link.children).remove | |
| 16 | + end | |
| 17 | + | |
| 18 | + doc | |
| 19 | + end | |
| 20 | + end | |
| 21 | + end | |
| 22 | +end | |
| @@ -0,0 +1,35 @@ | ||
| 1 | +module Docs | |
| 2 | + class Requirejs | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + at_css('h1').content | |
| 6 | + end | |
| 7 | + | |
| 8 | + def get_type | |
| 9 | + 'Guides' | |
| 10 | + end | |
| 11 | + | |
| 12 | + def additional_entries | |
| 13 | + return [] unless root_page? | |
| 14 | + | |
| 15 | + entries = [] | |
| 16 | + type = nil | |
| 17 | + | |
| 18 | + css('*').each do |node| | |
| 19 | + if node.name == 'h2' | |
| 20 | + type = node.content | |
| 21 | + elsif node.name == 'h3' || node.name == 'h4' | |
| 22 | + entries << [node.content, node['id'], type] | |
| 23 | + end | |
| 24 | + end | |
| 25 | + | |
| 26 | + css('p[id^="config-"]').each do |node| | |
| 27 | + next if node['id'].include?('note') | |
| 28 | + entries << [node.at_css('strong').content, node['id'], 'Configuration Options'] | |
| 29 | + end | |
| 30 | + | |
| 31 | + entries | |
| 32 | + end | |
| 33 | + end | |
| 34 | + end | |
| 35 | +end | |
| @@ -0,0 +1,29 @@ | ||
| 1 | +module Docs | |
| 2 | + class Requirejs < UrlScraper | |
| 3 | + self.name = 'RequireJS' | |
| 4 | + self.type = 'requirejs' | |
| 5 | + self.version = '2.1.4' | |
| 6 | + self.base_url = 'http://requirejs.org/docs/' | |
| 7 | + self.root_path = 'api.html' | |
| 8 | + self.initial_paths = %w( | |
| 9 | + optimization.html | |
| 10 | + jquery.html | |
| 11 | + node.html | |
| 12 | + dojo.html | |
| 13 | + commonjs.html | |
| 14 | + plugins.html | |
| 15 | + why.html | |
| 16 | + whyamd.html) | |
| 17 | + | |
| 18 | + html_filters.push 'requirejs/clean_html', 'requirejs/entries' | |
| 19 | + | |
| 20 | + options[:container] = '#content' | |
| 21 | + options[:follow_links] = false | |
| 22 | + options[:only] = self.initial_paths | |
| 23 | + | |
| 24 | + options[:attribution] = <<-HTML | |
| 25 | + © 2010–2014 The Dojo Foundation<br> | |
| 26 | + Licensed under the MIT License. | |
| 27 | + HTML | |
| 28 | + end | |
| 29 | +end | |