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
200 '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',200 '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
201 'MIT',201 'MIT',
202 'https://raw.github.com/jashkenas/underscore/master/LICENSE'202 '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'
203 ]208 ]
204]209]
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -24,7 +24,10 @@ newsItem = (date, news) -> · 23 unmodified lines
24 result24 result
25 25
26app.news = [26app.news = [
27 [ 1394236800000, # March 8, 201427 [ 1394928000000, # March 16, 2013
28 """ New <a href="/yii/">Yii</a> documentation """,
29 ], [
30 1394236800000, # March 8, 2014
28 """ Added path bar. """,31 """ Added path bar. """,
29 ], [32 ], [
30 1393027200000, # February 22, 201433 1393027200000, # February 22, 2014
assets/javascripts/views/pages/yii.coffee+15−0
@@ -0,0 +1,15 @@
1#= require views/pages/base
2
3class 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
48 'pages/rfc',48 'pages/rfc',
49 'pages/sphinx',49 'pages/sphinx',
50 'pages/underscore',50 '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
50._icon-moment:before { background-position: -1rem -7rem; }50._icon-moment:before { background-position: -1rem -7rem; }
51._icon-c:before { background-position: -2rem -7rem; }51._icon-c:before { background-position: -2rem -7rem; }
52%icon-path { background-position: -3rem -7rem; }52%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
2 class Yii2 class Yii
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 at_css('h1').content = 'Yii PHP Framework' if root_page?
5 6
6 #remove irrelevant content7 css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
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
29 8
30 # Put code blocks in <pre> tags9 css('.summary > p > .toggle').each do |node|
31 css('.code').each do |node|10 node.parent.remove
11 end
12
13 css('.signature', '.signature2').each do |node|
32 node.name = 'pre'14 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'
33 end20 end
34 21
35 #remove Hide inherited methods / properties and show links22 css('.sourceCode > .code > code').each do |node|
36 css('a').each do |node|23 parent = node.parent
37 if node['class'] == 'toggle'24 parent.name = 'pre'
38 node.remove25 node.remove
39 elsif node['class'] == 'show'26 parent.inner_html = node.first_element_child.inner_html.strip
40 node.remove
41 end
42 end27 end
43 28
44 doc29 doc
45 end30 end
46 end31 end
47 end32 end
48end33end
lib/docs/filters/yii/entries.rb+7−16
@@ -1,30 +1,21 @@
1module Docs1module Docs
2 class Yii2 class Yii
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
5 def get_name4 def get_name
6 #class names exist in the <h1> content.5 at_css('h1').content.strip
7 name = at_css('h1').content.strip
8 end6 end
9 7
10 def get_type8 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.9 css('.summaryTable td').first.content
12 type = css('table.summaryTable td')[0].content
13 type
14 end10 end
15 11
16 def additional_entries12 def additional_entries
17 css('table.summaryTable tr[id]').inject [] do |entries,node|13 css('.detailHeader').inject [] do |entries, node|
18 #need to ignore inherited methods and properties14 name = node.child.content.strip
19 if (node['class'] != 'inherited' and node.parent().parent()['class'] == "summary docMethod")15 name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
20 #name should be Class.method() id will take you to the link in the summary block.16 entries << [name, node['id']]
21 name = slug + "." + node['id'] + "()"
22 entries << [name, node['id']]
23 end
24 entries
25 end17 end
26 end18 end
27
28 end19 end
29 end20 end
30end21end
lib/docs/scrapers/yii.rb+5−2
@@ -1,12 +1,15 @@
1module Docs1module Docs
2 class Yii < UrlScraper2 class Yii < UrlScraper
3 self.name = 'Yii'
4 self.slug = 'yii'
5 self.type = 'yii'3 self.type = 'yii'
6 self.version = '1.1.14'4 self.version = '1.1.14'
7 self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'5 self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
8 6
9 html_filters.push 'yii/clean_html', 'yii/entries'7 html_filters.push 'yii/clean_html', 'yii/entries'
10 8
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
11 end14 end
12end15end
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 @@
1http://www.yiiframework.com/logo/