mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Adding Yii files
This commit is contained in:
parent
306acfa819
commit
45fa50e511
5 changed files with 90 additions and 0 deletions
48
lib/docs/filters/yii/clean_html.rb
Normal file
48
lib/docs/filters/yii/clean_html.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
module Docs
|
||||
class Yii
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
|
||||
#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
|
||||
|
||||
# Put code blocks in <pre> tags
|
||||
css('.code').each do |node|
|
||||
node.name = 'pre'
|
||||
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
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/docs/filters/yii/entries.rb
Normal file
30
lib/docs/filters/yii/entries.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Docs
|
||||
class Yii
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def get_name
|
||||
#class names exist in the <h1> content.
|
||||
name = 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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
12
lib/docs/scrapers/yii.rb
Executable file
12
lib/docs/scrapers/yii.rb
Executable file
|
@ -0,0 +1,12 @@
|
|||
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'
|
||||
|
||||
end
|
||||
end
|
BIN
public/icons/docs/yii/16.png
Normal file
BIN
public/icons/docs/yii/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 890 B |
BIN
public/icons/docs/yii/16@2x.png
Normal file
BIN
public/icons/docs/yii/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
Loading…
Reference in a new issue