History

Finish CakePHP documentation

Thibaut Courouble committed 10 years ago

Commit 5f2d9cd1 parent 26bead213 files · +117 −62Browse files

Unified · Split

13 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_classes.scss +5 −0
  6. assets/stylesheets/global/_icons.scss +1 −1
  7. assets/stylesheets/pages/_cakephp.scss +11 −10
  8. lib/docs/core/scrapers/file_scraper.rb +1 −0
  9. lib/docs/filters/cakephp/clean_html.rb +30 −17
  10. lib/docs/filters/cakephp/entries.rb +40 −32
  11. lib/docs/scrapers/cakephp.rb +25 −6
  12. public/icons/docs/cakephp/16.png +0 −0
  13. public/icons/docs/cakephp/16@2x.png +0 −0
assets/images/icons.png+0−0

Binary file not shown.

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

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
11 [
22 [
3+ "2016-02-14",
4+ "New documentation: <a href=\"/cakephp/\">CakePHP</a>"
5+ ], [
36 "2016-01-31",
47 "New documentations: <a href=\"/erlang/\">Erlang</a> and <a href=\"/tcl_tk/\">Tcl/Tk</a>"
58 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -99,6 +99,11 @@ credits = [ · 98 unmodified lines
9999 'cppreference.com',
100100 'CC BY-SA',
101101 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA'
102+ ], [
103+ 'CakePHP',
104+ '2005-2016 The Cake Software Foundation, Inc.',
105+ 'MIT',
106+ 'https://raw.githubusercontent.com/cakephp/cakephp/master/LICENSE.txt'
102107 ], [
103108 'Chai',
104109 '2011-2015 Jake Luer',
assets/stylesheets/global/_classes.scss+5−0
@@ -70,6 +70,11 @@ · 69 unmodified lines
7070 @extend %label;
7171 }
7272
73+%label-yellow {
74+ background: $noteBackground;
75+ border-color: $noteBorder;
76+}
77+
7378 %note-green, %label-green {
7479 background: $noteGreenBackground;
7580 border-color: $noteGreenBorder;
assets/stylesheets/global/_icons.scss+1−1
@@ -94,7 +94,7 @@ · 93 unmodified lines
9494 %icon-check-white { background-position: -9rem -6rem; }
9595 %icon-light { background-position: 0 -7rem; }
9696 %icon-light-white { background-position: -1rem -7rem; }
97−._icon-iojs:before { background-position: -2rem -7rem; @extend %darkIconFix !optional; }
97+._icon-cakephp:before { background-position: -2rem -7rem; }
9898 ._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; }
9999 ._icon-clojure:before { background-position: -4rem -7rem; }
100100 ._icon-symfony:before { background-position: -5rem -7rem; }
assets/stylesheets/pages/_cakephp.scss+11−10
@@ -1,16 +1,17 @@
11 ._cakephp {
2− h2 { @extend %block-heading; }
2+ @extend %simple;
33
4− h3 { @extend %block-label, %label-blue; }
4+ h3 > .source { float: right; }
5+ h3 > a, span.label, span.php-keyword1 { font-weight: normal; }
56
6− h3 > a { float: right; }
7−
8− h3 > a,
9− span.label,
10− span.php-keyword1 {
11− font-weight: normal;
7+ h4 {
8+ margin: 1.5em 0;
9+ @extend %block-label;
1210 }
1311
14− .tree > dd { margin-left: 0px; }
15− .list { margin-left: 20px; }
12+ dl { margin: 1em 0; }
13+
14+ .info { @extend %note; }
15+ code { @extend %label; }
16+ p > .label, dt > .label { @extend %label, %label-yellow; }
1617 }
lib/docs/core/scrapers/file_scraper.rb+1−0
@@ -8,6 +8,7 @@ module Docs · 7 unmodified lines
88 def inherited(subclass)
99 super
1010 subclass.base_url = base_url
11+ subclass.dir = dir
1112 end
1213 end
1314
lib/docs/filters/cakephp/clean_html.rb+30−17
@@ -2,44 +2,50 @@ module Docs · 1 unmodified line
22 class Cakephp
33 class CleanHtmlFilter < Filter
44 def call
5− if root_page?
6− css('.section').remove
7− end
5+ css('.breadcrumbs', 'a.permalink', 'a.anchor').remove
86
9− css('.breadcrumbs', '.info', 'a.permalink').remove
7+ css('.section', '#content', '.description', '.list').each do |node|
8+ node.before(node.children).remove
9+ end
1010
1111 css('h1').drop(1).each do |node|
1212 node.name = 'h2'
1313 end
1414
15+ css('> h6').each do |node|
16+ node.name = 'h2'
17+ end
18+
19+ css('h6').each do |node|
20+ node.name = 'h4'
21+ end
22+
1523 css('.property-name').each do |node|
1624 node.name = 'h3'
1725 end
1826
27+ css('var').each do |node|
28+ node.name = 'code'
29+ end
30+
1931 # Move dummy anchor to method and property name
32+
2033 css('.method-detail').each do |node|
2134 node.at_css('.method-name')['id'] = node.at_css('a')['id']
2235 end
36+
2337 css('.property-detail').each do |node|
2438 node.at_css('.property-name')['id'] = node['id']
2539 node.remove_attribute('id')
2640 end
2741
2842 # Break out source link to separate element
43+
2944 css('.method-name', '.property-name').each do |node|
3045 source = node.at_css('a')
31− source.add_previous_sibling("<span class=\"name\">#{source.content}</span>")
46+ source.before(%(<span class="name">#{source.content}</span>))
3247 source.content = 'source'
33− end
34−
35− # These are missing in upstream documentation. Not sure why.
36− css('.section > h2').each do |node|
37− if node.content == "Method Detail"
38− node['id'] = 'methods'
39− end
40− if node.content == 'Properties summary'
41− node['id'] = 'properties'
42− end
48+ source['class'] = 'source'
4349 end
4450
4551 css('.method-signature').each do |node|
@@ -51,8 +57,15 @@ module Docs · 5 unmodified lines
5157 node.content = node.content.strip
5258 end
5359
54− # Pages don't share a nice common base css tag.
55− doc.children
60+ css('code code').each do |node|
61+ node.before(node.children).remove
62+ end
63+
64+ css('code').each do |node|
65+ node.inner_html = node.inner_html.squish
66+ end
67+
68+ doc
5669 end
5770 end
5871 end
lib/docs/filters/cakephp/entries.rb+40−32
@@ -1,55 +1,63 @@
11 module Docs
22 class Cakephp
33 class EntriesFilter < Docs::EntriesFilter
4− INCLUDE_PAGE_TYPES = {
5− 'class' => true,
6− 'function' => true,
7− 'namespace' => false,
8− }
9−
10− def get_page_type
11− page_type = slug.split('-')[0]
4+ def page_type
5+ @page_type ||= slug.split('-').first
126 end
137
14− def include_default_entry?
15− INCLUDE_PAGE_TYPES[get_page_type]
8+ def slug_without_page_type
9+ @slug_without_page_type ||= slug.split('-').last
1610 end
1711
1812 def get_name
19− case get_page_type
20− when 'class'
21− slug.split('.').last
22− when 'function'
23− at_css('h1').content.split(' ')[1]
13+ case page_type
14+ when 'class'
15+ slug_without_page_type.split('.').last.concat(' (class)')
16+ when 'function'
17+ at_css('h1').content.remove('Function ')
18+ when 'namespace', 'package'
19+ slug_without_page_type.split('.').tap do |path|
20+ path.shift if path.length > 1
21+ end.join('\\').concat(" (#{page_type})")
2422 end
2523 end
2624
2725 def get_type
28− case get_page_type
29− when 'class'
30− slug.split('.')[1..-2].join('\\')
31− when 'function'
32− 'Global Functions'
26+ return 'Global' if slug == 'namespace-None'
27+ case page_type
28+ when 'class', 'namespace', 'package'
29+ if (node = at_css('.info')) && node.content =~ /Located at\s+((?:\w+\/?)+)/ # for 2.x docs
30+ path = $1.split('/')
31+ else
32+ path = slug_without_page_type.split('.')
33+ end
34+ path.shift if path.length > 1 && path[0] == 'Cake'
35+ path.pop if path.length > 1
36+ path.pop if path.last == 'Exception'
37+ path.join('\\')
38+ when 'function'
39+ 'Global'
3340 end
3441 end
3542
3643 def additional_entries
44+ return [] unless page_type == 'class'
45+ class_name = name.remove(' (class)')
46+ return [] if class_name.end_with?('Exception')
3747 entries = []
38− if get_page_type == 'class'
39− css('.method-name').each do |node|
40− name = get_name + '::' + node.at_css('.name').content.strip + '()'
41− id = node['id']
42− entries << [name, id, get_type]
43− end
44− css('.property-name').each do |node|
45− name = get_name + '::' + node.at_css('.name').content.strip
46− id = node['id']
47− entries << [name, id, get_type]
48− end
48+
49+ css('.method-name').each do |node|
50+ break if node.parent.previous_element.content =~ /\AMethods.*from/
51+ entries << ["#{class_name}::#{node.at_css('.name').content.strip}()", node['id']]
4952 end
53+
54+ css('.property-name').each do |node|
55+ break if node.parent.parent['class'].include?('used')
56+ entries << ["#{class_name}::#{node.at_css('.name').content.strip}", node['id']]
57+ end
58+
5059 entries
5160 end
52−
5361 end
5462 end
5563 end
lib/docs/scrapers/cakephp.rb+25−6
@@ -2,9 +2,7 @@ module Docs · 1 unmodified line
22 class Cakephp < FileScraper
33 self.name = 'CakePHP'
44 self.type = 'cakephp'
5− self.version = '3.1'
6− self.dir = ''
7− self.base_url = "http://api.cakephp.org/#{version}/"
5+ self.dir = '/Users/Thibaut/DevDocs/Docs/CakePHP'
86 self.root_path = 'index.html'
97 self.links = {
108 home: 'http://cakephp.org/',
@@ -15,12 +13,33 @@ module Docs · 4 unmodified lines
1513
1614 options[:container] = '#right.columns.nine'
1715
18− # CakePHP docs include full source code. Ignore it.
1916 options[:skip_patterns] = [/\Asource-/]
2017
2118 options[:attribution] = <<-HTML
22− &copy; 2005&ndash;2015 The Cake Software Foundation, Inc.<br>
23− Licensed under the MIT License.
19+ &copy; 2005&ndash;2016 The Cake Software Foundation, Inc.<br>
20+ Licensed under the MIT License.<br>
21+ CakePHP is a registered trademark of Cake Software Foundation, Inc.<br>
22+ We are not endorsed by or affiliated with CakePHP.
2423 HTML
24+
25+ version '3.2' do # http://api.cakephp.org/3.2/cakephp-api-documentation.zip
26+ self.release = '3.2.2'
27+ self.base_url = 'http://api.cakephp.org/3.2/'
28+ end
29+
30+ version '3.1' do # http://api.cakephp.org/3.1/cakephp-api-documentation.zip
31+ self.release = '3.1.10'
32+ self.base_url = 'http://api.cakephp.org/3.1/'
33+ end
34+
35+ version '2.8' do # http://api.cakephp.org/2.8/cakephp-api-documentation.zip
36+ self.release = '2.8.0'
37+ self.base_url = 'http://api.cakephp.org/2.8/'
38+ end
39+
40+ version '2.7' do # http://api.cakephp.org/2.7/cakephp-api-documentation.zip
41+ self.release = '2.7.10'
42+ self.base_url = 'http://api.cakephp.org/2.7/'
43+ end
2544 end
2645 end
public/icons/docs/cakephp/16.png+0−0

Binary file not shown.

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

Binary file not shown.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t