diff --git a/lib/docs/filters/twig/clean_html.rb b/lib/docs/filters/twig/clean_html.rb new file mode 100644 index 00000000..a214b839 --- /dev/null +++ b/lib/docs/filters/twig/clean_html.rb @@ -0,0 +1,12 @@ +module Docs + class Twig + class CleanHtmlFilter < Filter + def call + + css('.infobar', '.admonition-note', 'ul.pages', '.offline-docs').remove + + doc + end + end + end +end diff --git a/lib/docs/filters/twig/entries.rb b/lib/docs/filters/twig/entries.rb new file mode 100644 index 00000000..bb21ce9b --- /dev/null +++ b/lib/docs/filters/twig/entries.rb @@ -0,0 +1,33 @@ +module Docs + class Twig + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content.strip.tr('ΒΆ', '') + name + end + + def get_type + if slug.include?('deprecate') + 'Deprecated' + elsif slug.include?('extensions') + 'Doc\\Extensions' + elsif slug.include?('tags') + 'tags' + elsif slug.include?('filters') + 'filters' + elsif slug.include?('functions') + 'functions' + elsif slug.include?('tests') + 'tests' + elsif slug.include?('-operator') || slug.include?('#math') || slug.include?('comparisons') + 'operators' + elsif slug.in?('doc/index') || slug.include?('intro') || slug.include?('recipes') || slug.include?('internals') || slug.include?('coding_standards') || slug.include?('installation') || slug.include?('api') || slug.include?('advanced') + 'Doc' + elsif slug.include?('templates') + 'Doc\\Templates' + end + end + + end + end +end diff --git a/lib/docs/scrapers/twig.rb b/lib/docs/scrapers/twig.rb new file mode 100755 index 00000000..b1ac1a69 --- /dev/null +++ b/lib/docs/scrapers/twig.rb @@ -0,0 +1,20 @@ +module Docs + class Twig < UrlScraper + self.type = 'twig' + + options[:attribution] = <<-HTML + © 2009–2016 by SensioLabs
+ Licensed under the three clause BSD license. + HTML + + self.release = '1.24.1' + self.base_url = 'http://twig.sensiolabs.org/' + self.root_path = 'documentation' + + html_filters.push 'twig/clean_html', 'twig/entries' + + options[:container] = 'div.bd > div.content' + options[:skip_patterns] = [/\Aapi/, /\Alicense/] + options[:skip] = %w(doc/deprecated.html doc/advanced_legacy.html) + end +end diff --git a/public/icons/docs/twig/16.png b/public/icons/docs/twig/16.png new file mode 100644 index 00000000..b52ef454 Binary files /dev/null and b/public/icons/docs/twig/16.png differ diff --git a/public/icons/docs/twig/16@2x.png b/public/icons/docs/twig/16@2x.png new file mode 100644 index 00000000..7dacb1a2 Binary files /dev/null and b/public/icons/docs/twig/16@2x.png differ diff --git a/public/icons/docs/twig/SOURCE b/public/icons/docs/twig/SOURCE new file mode 100644 index 00000000..e9916089 --- /dev/null +++ b/public/icons/docs/twig/SOURCE @@ -0,0 +1 @@ +http://twig.sensiolabs.org/images/twig-logo.png