Showing the changes to lib/docs (3 of 8 files). Show all
Unified · Split
| @@ -0,0 +1,25 @@ | ||
| 1 | +module Docs | |
| 2 | + class Composer | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + # Remove unneeded elements | |
| 6 | + css('#searchbar, .toc, .fork-and-edit, .anchor').remove | |
| 7 | + | |
| 8 | + # Code blocks | |
| 9 | + css('pre').each do |node| | |
| 10 | + code = node.at_css('code[class]') | |
| 11 | + | |
| 12 | + unless code.nil? | |
| 13 | + node['data-language'] = 'javascript' if code['class'].include?('javascript') | |
| 14 | + node['data-language'] = 'php' if code['class'].include?('php') | |
| 15 | + end | |
| 16 | + | |
| 17 | + node.content = node.content.strip | |
| 18 | + node.remove_attribute('class') | |
| 19 | + end | |
| 20 | + | |
| 21 | + doc | |
| 22 | + end | |
| 23 | + end | |
| 24 | + end | |
| 25 | +end | |
| @@ -0,0 +1,39 @@ | ||
| 1 | +module Docs | |
| 2 | + class Composer | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + title = at_css('h1').content | |
| 6 | + | |
| 7 | + title = "#{Integer(subpath[1]) + 1}. #{title}" if type == 'Book' | |
| 8 | + | |
| 9 | + title | |
| 10 | + end | |
| 11 | + | |
| 12 | + def get_type | |
| 13 | + return 'Articles' if subpath.start_with?('articles/') | |
| 14 | + | |
| 15 | + 'Book' | |
| 16 | + end | |
| 17 | + | |
| 18 | + def additional_entries | |
| 19 | + entries = [] | |
| 20 | + | |
| 21 | + if subpath == '04-schema.md' # JSON Schema | |
| 22 | + css('h3').each do |node| | |
| 23 | + name = node.content.strip | |
| 24 | + name.remove!(' (root-only)') | |
| 25 | + entries << [name, node['id'], 'JSON Schema'] | |
| 26 | + end | |
| 27 | + end | |
| 28 | + | |
| 29 | + if subpath == '06-config.md' # Composer config | |
| 30 | + css('h2').each do |node| | |
| 31 | + entries << [node.content.strip, node['id'], 'Configuration Options'] | |
| 32 | + end | |
| 33 | + end | |
| 34 | + | |
| 35 | + entries | |
| 36 | + end | |
| 37 | + end | |
| 38 | + end | |
| 39 | +end | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +module Docs | |
| 2 | + class Composer < UrlScraper | |
| 3 | + self.name = 'Composer' | |
| 4 | + self.type = 'composer' | |
| 5 | + | |
| 6 | + self.links = { | |
| 7 | + home: 'https://getcomposer.org', | |
| 8 | + code: 'https://github.com/composer/composer' | |
| 9 | + } | |
| 10 | + | |
| 11 | + html_filters.push 'composer/clean_html', 'composer/entries' | |
| 12 | + | |
| 13 | + self.release = '1.7.2' | |
| 14 | + self.base_url = 'https://getcomposer.org/doc/' | |
| 15 | + | |
| 16 | + options[:container] = '#main' | |
| 17 | + | |
| 18 | + options[:skip_patterns] = [ | |
| 19 | + /^faqs/ | |
| 20 | + ] | |
| 21 | + | |
| 22 | + options[:attribution] = <<-HTML | |
| 23 | + © Nils Adermann, Jordi Boggiano<br> | |
| 24 | + Licensed under the MIT License. | |
| 25 | + HTML | |
| 26 | + end | |
| 27 | +end | |