From 4a930ee4eb6c95eff2410ca5d9e7061bd8b450ad Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 15 Feb 2015 09:56:17 -0500 Subject: [PATCH] Bring back Yii 1.1 documentation Closes #157. --- assets/javascripts/news.json | 2 +- assets/stylesheets/global/_icons.scss | 1 + lib/docs/filters/yii1/clean_html.rb | 33 +++++++++++++++++++++++++++ lib/docs/filters/yii1/entries.rb | 21 +++++++++++++++++ lib/docs/scrapers/yii1.rb | 17 ++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 lib/docs/filters/yii1/clean_html.rb create mode 100644 lib/docs/filters/yii1/entries.rb create mode 100644 lib/docs/scrapers/yii1.rb diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 98533185..b5f0aca4 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,6 +1,6 @@ [ [ "2015-02-15", - "New io.js documentation" + "New io.js and Yii 1.1 documentations" ], [ "2015-02-08", "New dark theme\nClick the icon in the bottom left corner to activate.\nFeedback welcome :)" diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index d89d4119..e5662b40 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -52,6 +52,7 @@ ._icon-c:before { background-position: -2rem -7rem; } %icon-path { background-position: -3rem -7rem; } ._icon-yii:before { background-position: -4rem -7rem; } +._icon-yii1:before { background-position: -4rem -7rem; } ._icon-cpp:before { background-position: 0 -8rem; } ._icon-go:before { background-position: -1rem -8rem; } ._icon-express:before { background-position: -2rem -8rem; } diff --git a/lib/docs/filters/yii1/clean_html.rb b/lib/docs/filters/yii1/clean_html.rb new file mode 100644 index 00000000..035981ed --- /dev/null +++ b/lib/docs/filters/yii1/clean_html.rb @@ -0,0 +1,33 @@ +module Docs + class Yii1 + class CleanHtmlFilter < Filter + def call + at_css('h1').content = 'Yii PHP Framework' if root_page? + + css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove + + css('.summary > p > .toggle').each do |node| + node.parent.remove + end + + css('.signature', '.signature2').each do |node| + node.name = 'pre' + node.inner_html = node.inner_html.strip + end + + css('div.detailHeader').each do |node| + node.name = 'h3' + end + + css('.sourceCode > .code > code').each do |node| + parent = node.parent + parent.name = 'pre' + node.remove + parent.inner_html = node.first_element_child.inner_html.strip + end + + doc + end + end + end +end diff --git a/lib/docs/filters/yii1/entries.rb b/lib/docs/filters/yii1/entries.rb new file mode 100644 index 00000000..f9a779d4 --- /dev/null +++ b/lib/docs/filters/yii1/entries.rb @@ -0,0 +1,21 @@ +module Docs + class Yii1 + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content.strip + end + + def get_type + css('.summaryTable td').first.content + end + + def additional_entries + css('.detailHeader').inject [] do |entries, node| + name = node.child.content.strip + name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->') + entries << [name, node['id']] + end + end + end + end +end diff --git a/lib/docs/scrapers/yii1.rb b/lib/docs/scrapers/yii1.rb new file mode 100644 index 00000000..1f655753 --- /dev/null +++ b/lib/docs/scrapers/yii1.rb @@ -0,0 +1,17 @@ +module Docs + class Yii1 < UrlScraper + self.name = 'Yii 1' + self.slug = 'yii1' + self.type = 'yii' + self.version = '1.1.16' + self.base_url = 'http://www.yiiframework.com/doc/api/1.1/' + + html_filters.push 'yii1/clean_html', 'yii1/entries' + + options[:container] = '.grid_9' + options[:attribution] = <<-HTML + © 2008–2015 by Yii Software LLC
+ Licensed under the three clause BSD license. + HTML + end +end