History

Improve and complete Yii documentation

Thibaut committed 12 years ago

Commit 138ee091 parent 55d045514 files · +78 −49Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  4. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  5. assets/javascripts/views/pages/yii.coffee +15 −0
  6. assets/stylesheets/application.css.scss +2 −1
  7. assets/stylesheets/global/_icons.scss +1 −0
  8. assets/stylesheets/pages/_yii.scss +24 −0
  9. lib/docs/filters/yii/clean_html.rb +18 −33
  10. lib/docs/filters/yii/entries.rb +7 −16
  11. lib/docs/scrapers/yii.rb +5 −2
  12. public/icons/docs/yii/16.png +0 −0
  13. public/icons/docs/yii/16@2x.png +0 −0
  14. public/icons/docs/yii/SOURCE +1 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -200,5 +200,10 @@ credits = [ · 199 unmodified lines
200200 '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
201201 'MIT',
202202 'https://raw.github.com/jashkenas/underscore/master/LICENSE'
203+ ], [
204+ 'Yii',
205+ '2008-2014 by Yii Software LLC',
206+ 'BSD',
207+ 'https://raw.github.com/yiisoft/yii/master/LICENSE'
203208 ]
204209 ]
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -24,7 +24,10 @@ newsItem = (date, news) -> · 23 unmodified lines
2424 result
2525
2626 app.news = [
27− [ 1394236800000, # March 8, 2014
27+ [ 1394928000000, # March 16, 2013
28+ """ New <a href="/yii/">Yii</a> documentation """,
29+ ], [
30+ 1394236800000, # March 8, 2014
2831 """ Added path bar. """,
2932 ], [
3033 1393027200000, # February 22, 2014
assets/javascripts/views/pages/yii.coffee+15−0
@@ -0,0 +1,15 @@
1+#= require views/pages/base
2+
3+class app.views.YiiPage extends app.views.BasePage
4+ @events:
5+ click: 'onClick'
6+
7+ onClick: (event) ->
8+ return unless event.target.classList.contains 'show'
9+ $.stopEvent(event)
10+
11+ source = $ '.code', event.target.parentNode.parentNode
12+ isShown = source.style.display is 'block'
13+
14+ source.style.display = if isShown then 'none' else 'block'
15+ event.target.textContent = if isShown then 'show' else 'hide'
assets/stylesheets/application.css.scss+2−1
@@ -48,4 +48,5 @@ · 47 unmodified lines
4848 'pages/rfc',
4949 'pages/sphinx',
5050 'pages/underscore',
51− 'pages/yard';
51+ 'pages/yard',
52+ 'pages/yii';
assets/stylesheets/global/_icons.scss+1−0
@@ -50,3 +50,4 @@ · 49 unmodified lines
5050 ._icon-moment:before { background-position: -1rem -7rem; }
5151 ._icon-c:before { background-position: -2rem -7rem; }
5252 %icon-path { background-position: -3rem -7rem; }
53+._icon-yii:before { background-position: -4rem -7rem; }
assets/stylesheets/pages/_yii.scss+24−0
@@ -0,0 +1,24 @@
1+._yii {
2+ h2 { @extend %block-heading; }
3+ > h3 { @extend %block-label, %label-blue; }
4+
5+ .paramNameCol { font-weight: bold; }
6+ .signature2 { margin: .4em 0; }
7+ .sourceCode { margin-bottom: 1em; }
8+ .sourceCode > .code { display: none; }
9+
10+ .SeeAlso {
11+ > h4 {
12+ margin-bottom: 1em;
13+ font-size: inherit;
14+ }
15+
16+ > ul { margin-top: 0; }
17+ }
18+
19+ .summaryTable td:first-child[rowspan] {
20+ border-right: 1px solid #e5e5e5;
21+
22+ + td { border-left: 0; }
23+ }
24+}
lib/docs/filters/yii/clean_html.rb+18−33
@@ -2,47 +2,32 @@ module Docs · 1 unmodified line
22 class Yii
33 class CleanHtmlFilter < Filter
44 def call
5+ at_css('h1').content = 'Yii PHP Framework' if root_page?
56
6− #remove irrelevant content
7− css('div').each do |node|
8− if node['class'] == "layout-main-header"
9− node.remove
10− elsif node['class'] == "layout-main-submenu"
11− node.remove
12− elsif node['class'] == "layout-main-shortcuts"
13− node.remove
14− elsif node['class'] == "layout-main-footer"
15− node.remove
16− elsif node['class'] == "grid_3 alpha"
17− node.remove
18− elsif node['class'] == "comments"
19− node.remove
20− elsif node['class'] == "api-suggest clearfix"
21− node.remove
22− elsif node['id'] == "comments"
23− node.remove
24− elsif node['id'] == "nav"
25− node.remove
26− else
27− end
28− end
7+ css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
298
30− # Put code blocks in <pre> tags
31− css('.code').each do |node|
9+ css('.summary > p > .toggle').each do |node|
10+ node.parent.remove
11+ end
12+
13+ css('.signature', '.signature2').each do |node|
3214 node.name = 'pre'
15+ node.inner_html = node.inner_html.strip
16+ end
17+
18+ css('div.detailHeader').each do |node|
19+ node.name = 'h3'
3320 end
3421
35− #remove Hide inherited methods / properties and show links
36− css('a').each do |node|
37− if node['class'] == 'toggle'
38− node.remove
39− elsif node['class'] == 'show'
40− node.remove
41− end
22+ css('.sourceCode > .code > code').each do |node|
23+ parent = node.parent
24+ parent.name = 'pre'
25+ node.remove
26+ parent.inner_html = node.first_element_child.inner_html.strip
4227 end
4328
4429 doc
4530 end
4631 end
4732 end
48−end
33+end
lib/docs/filters/yii/entries.rb+7−16
@@ -1,30 +1,21 @@
11 module Docs
22 class Yii
33 class EntriesFilter < Docs::EntriesFilter
4−
54 def get_name
6− #class names exist in the <h1> content.
7− name = at_css('h1').content.strip
5+ at_css('h1').content.strip
86 end
97
108 def get_type
11− #need to get the table with a class of summaryTable. Then we need the content of the first td in the first tr.
12− type = css('table.summaryTable td')[0].content
13− type
9+ css('.summaryTable td').first.content
1410 end
1511
1612 def additional_entries
17− css('table.summaryTable tr[id]').inject [] do |entries,node|
18− #need to ignore inherited methods and properties
19− if (node['class'] != 'inherited' and node.parent().parent()['class'] == "summary docMethod")
20− #name should be Class.method() id will take you to the link in the summary block.
21− name = slug + "." + node['id'] + "()"
22− entries << [name, node['id']]
23− end
24− entries
13+ css('.detailHeader').inject [] do |entries, node|
14+ name = node.child.content.strip
15+ name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
16+ entries << [name, node['id']]
2517 end
2618 end
27−
2819 end
2920 end
30−end
21+end
lib/docs/scrapers/yii.rb+5−2
@@ -1,12 +1,15 @@
11 module Docs
22 class Yii < UrlScraper
3− self.name = 'Yii'
4− self.slug = 'yii'
53 self.type = 'yii'
64 self.version = '1.1.14'
75 self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
86
97 html_filters.push 'yii/clean_html', 'yii/entries'
108
9+ options[:container] = '.grid_9'
10+ options[:attribution] = <<-HTML
11+ &copy; 2008&ndash;2014 by Yii Software LLC<br>
12+ Licensed under the three clause BSD license.
13+ HTML
1114 end
1215 end
public/icons/docs/yii/16.png+0−0

Binary file not shown.

public/icons/docs/yii/16@2x.png+0−0

Binary file not shown.

public/icons/docs/yii/SOURCE+1−0
@@ -0,0 +1 @@
1+http://www.yiiframework.com/logo/