Showing the changes to lib/docs (3 of 13 files). Show all
Unified · Split
| @@ -0,0 +1,30 @@ | ||
| 1 | +module Docs | |
| 2 | + class Jasmine | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + @doc = at_css('.docs') | |
| 6 | + | |
| 7 | + at_css('h1').content = 'Jasmine' if root_page? | |
| 8 | + | |
| 9 | + css('header', 'article', 'section:not([class])', 'div.description').each do |node| | |
| 10 | + node.before(node.children).remove | |
| 11 | + end | |
| 12 | + | |
| 13 | + css('h3.subsection-title').each do |node| | |
| 14 | + node.name = 'h2' | |
| 15 | + end | |
| 16 | + | |
| 17 | + css('h4.name').each do |node| | |
| 18 | + node.name = 'h3' | |
| 19 | + end | |
| 20 | + | |
| 21 | + css('pre').each do |node| | |
| 22 | + node.content = node.content | |
| 23 | + node['data-language'] = 'javascript' | |
| 24 | + end | |
| 25 | + | |
| 26 | + doc | |
| 27 | + end | |
| 28 | + end | |
| 29 | + end | |
| 30 | +end | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +module Docs | |
| 2 | + class Jasmine | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('h1').content.strip | |
| 6 | + name.remove! %r{\A\w+:\s} | |
| 7 | + name | |
| 8 | + end | |
| 9 | + | |
| 10 | + def get_type | |
| 11 | + at_css('h1').content.strip | |
| 12 | + end | |
| 13 | + | |
| 14 | + def additional_entries | |
| 15 | + css('h3[id]').each_with_object [] do |node, entries| | |
| 16 | + name = node.content.strip | |
| 17 | + next if name.start_with?('new ') | |
| 18 | + static = name.sub! '(static) ', '' | |
| 19 | + name.sub! %r{\(.*\)}, '()' | |
| 20 | + name.remove! %r{\s.*} | |
| 21 | + name.prepend "#{self.name}#{static ? '.' : '#'}" unless slug == 'global' | |
| 22 | + entries << [name, node['id']] | |
| 23 | + end | |
| 24 | + end | |
| 25 | + end | |
| 26 | + end | |
| 27 | +end | |
| @@ -0,0 +1,21 @@ | ||
| 1 | +module Docs | |
| 2 | + class Jasmine < UrlScraper | |
| 3 | + self.type = 'jasmine' | |
| 4 | + self.release = '2.6.1' | |
| 5 | + self.base_url = 'https://jasmine.github.io/api/2.6/' | |
| 6 | + self.root_path = 'index.html' | |
| 7 | + self.links = { | |
| 8 | + home: 'https://jasmine.github.io/', | |
| 9 | + code: 'https://github.com/jasmine/jasmine' | |
| 10 | + } | |
| 11 | + | |
| 12 | + html_filters.push 'jasmine/clean_html', 'jasmine/entries' | |
| 13 | + | |
| 14 | + options[:container] = '.main-content' | |
| 15 | + | |
| 16 | + options[:attribution] = <<-HTML | |
| 17 | + © 2008–2017 Pivotal Labs<br> | |
| 18 | + Licensed under the MIT License. | |
| 19 | + HTML | |
| 20 | + end | |
| 21 | +end | |