Improve and complete Yii documentation

This commit is contained in:
Thibaut 2014-03-16 17:01:10 -04:00
parent 55d0455a75
commit 138ee09fc9
14 changed files with 83 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -200,5 +200,10 @@ credits = [
'2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
'MIT',
'https://raw.github.com/jashkenas/underscore/master/LICENSE'
], [
'Yii',
'2008-2014 by Yii Software LLC',
'BSD',
'https://raw.github.com/yiisoft/yii/master/LICENSE'
]
]

View file

@ -24,7 +24,10 @@ newsItem = (date, news) ->
result
app.news = [
[ 1394236800000, # March 8, 2014
[ 1394928000000, # March 16, 2013
""" New <a href="/yii/">Yii</a> documentation """,
], [
1394236800000, # March 8, 2014
""" Added path bar. """,
], [
1393027200000, # February 22, 2014

View file

@ -0,0 +1,15 @@
#= require views/pages/base
class app.views.YiiPage extends app.views.BasePage
@events:
click: 'onClick'
onClick: (event) ->
return unless event.target.classList.contains 'show'
$.stopEvent(event)
source = $ '.code', event.target.parentNode.parentNode
isShown = source.style.display is 'block'
source.style.display = if isShown then 'none' else 'block'
event.target.textContent = if isShown then 'show' else 'hide'

View file

@ -48,4 +48,5 @@
'pages/rfc',
'pages/sphinx',
'pages/underscore',
'pages/yard';
'pages/yard',
'pages/yii';

View file

@ -50,3 +50,4 @@
._icon-moment:before { background-position: -1rem -7rem; }
._icon-c:before { background-position: -2rem -7rem; }
%icon-path { background-position: -3rem -7rem; }
._icon-yii:before { background-position: -4rem -7rem; }

View file

@ -0,0 +1,24 @@
._yii {
h2 { @extend %block-heading; }
> h3 { @extend %block-label, %label-blue; }
.paramNameCol { font-weight: bold; }
.signature2 { margin: .4em 0; }
.sourceCode { margin-bottom: 1em; }
.sourceCode > .code { display: none; }
.SeeAlso {
> h4 {
margin-bottom: 1em;
font-size: inherit;
}
> ul { margin-top: 0; }
}
.summaryTable td:first-child[rowspan] {
border-right: 1px solid #e5e5e5;
+ td { border-left: 0; }
}
}

View file

@ -2,47 +2,32 @@ module Docs
class Yii
class CleanHtmlFilter < Filter
def call
at_css('h1').content = 'Yii PHP Framework' if root_page?
#remove irrelevant content
css('div').each do |node|
if node['class'] == "layout-main-header"
node.remove
elsif node['class'] == "layout-main-submenu"
node.remove
elsif node['class'] == "layout-main-shortcuts"
node.remove
elsif node['class'] == "layout-main-footer"
node.remove
elsif node['class'] == "grid_3 alpha"
node.remove
elsif node['class'] == "comments"
node.remove
elsif node['class'] == "api-suggest clearfix"
node.remove
elsif node['id'] == "comments"
node.remove
elsif node['id'] == "nav"
node.remove
else
end
end
css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
# Put code blocks in <pre> tags
css('.code').each do |node|
node.name = 'pre'
css('.summary > p > .toggle').each do |node|
node.parent.remove
end
#remove Hide inherited methods / properties and show links
css('a').each do |node|
if node['class'] == 'toggle'
node.remove
elsif node['class'] == 'show'
node.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
end

View file

@ -1,30 +1,21 @@
module Docs
class Yii
class EntriesFilter < Docs::EntriesFilter
def get_name
#class names exist in the <h1> content.
name = at_css('h1').content.strip
at_css('h1').content.strip
end
def get_type
#need to get the table with a class of summaryTable. Then we need the content of the first td in the first tr.
type = css('table.summaryTable td')[0].content
type
css('.summaryTable td').first.content
end
def additional_entries
css('table.summaryTable tr[id]').inject [] do |entries,node|
#need to ignore inherited methods and properties
if (node['class'] != 'inherited' and node.parent().parent()['class'] == "summary docMethod")
#name should be Class.method() id will take you to the link in the summary block.
name = slug + "." + node['id'] + "()"
entries << [name, node['id']]
end
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
end

View file

@ -1,12 +1,15 @@
module Docs
class Yii < UrlScraper
self.name = 'Yii'
self.slug = 'yii'
self.type = 'yii'
self.version = '1.1.14'
self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
html_filters.push 'yii/clean_html', 'yii/entries'
options[:container] = '.grid_9'
options[:attribution] = <<-HTML
&copy; 2008&ndash;2014 by Yii Software LLC<br>
Licensed under the three clause BSD license.
HTML
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 890 B

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1 @@
http://www.yiiframework.com/logo/