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 @@
1[1[
2 [2 [
3 "2016-02-14",
4 "New documentation: <a href=\"/cakephp/\">CakePHP</a>"
5 ], [
3 "2016-01-31",6 "2016-01-31",
4 "New documentations: <a href=\"/erlang/\">Erlang</a> and <a href=\"/tcl_tk/\">Tcl/Tk</a>"7 "New documentations: <a href=\"/erlang/\">Erlang</a> and <a href=\"/tcl_tk/\">Tcl/Tk</a>"
5 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -99,6 +99,11 @@ credits = [ · 98 unmodified lines
99 'cppreference.com',99 'cppreference.com',
100 'CC BY-SA',100 'CC BY-SA',
101 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA'101 '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'
102 ], [107 ], [
103 'Chai',108 'Chai',
104 '2011-2015 Jake Luer',109 '2011-2015 Jake Luer',
assets/stylesheets/global/_classes.scss+5−0
@@ -70,6 +70,11 @@ · 69 unmodified lines
70 @extend %label;70 @extend %label;
71}71}
72 72
73%label-yellow {
74 background: $noteBackground;
75 border-color: $noteBorder;
76}
77
73%note-green, %label-green {78%note-green, %label-green {
74 background: $noteGreenBackground;79 background: $noteGreenBackground;
75 border-color: $noteGreenBorder;80 border-color: $noteGreenBorder;
assets/stylesheets/global/_icons.scss+1−1
@@ -94,7 +94,7 @@ · 93 unmodified lines
94%icon-check-white { background-position: -9rem -6rem; }94%icon-check-white { background-position: -9rem -6rem; }
95%icon-light { background-position: 0 -7rem; }95%icon-light { background-position: 0 -7rem; }
96%icon-light-white { background-position: -1rem -7rem; }96%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; }
98._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; }98._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; }
99._icon-clojure:before { background-position: -4rem -7rem; }99._icon-clojure:before { background-position: -4rem -7rem; }
100._icon-symfony:before { background-position: -5rem -7rem; }100._icon-symfony:before { background-position: -5rem -7rem; }
assets/stylesheets/pages/_cakephp.scss+11−10
@@ -1,16 +1,17 @@
1._cakephp {1._cakephp {
2 h2 { @extend %block-heading; }2 @extend %simple;
3 3
4 h3 { @extend %block-label, %label-blue; }4 h3 > .source { float: right; }
5 h3 > a, span.label, span.php-keyword1 { font-weight: normal; }
5 6
6 h3 > a { float: right; }7 h4 {
7 8 margin: 1.5em 0;
8 h3 > a,9 @extend %block-label;
9 span.label,
10 span.php-keyword1 {
11 font-weight: normal;
12 }10 }
13 11
14 .tree > dd { margin-left: 0px; }12 dl { margin: 1em 0; }
15 .list { margin-left: 20px; }13
14 .info { @extend %note; }
15 code { @extend %label; }
16 p > .label, dt > .label { @extend %label, %label-yellow; }
16}17}
lib/docs/core/scrapers/file_scraper.rb+1−0
@@ -8,6 +8,7 @@ module Docs · 7 unmodified lines
8 def inherited(subclass)8 def inherited(subclass)
9 super9 super
10 subclass.base_url = base_url10 subclass.base_url = base_url
11 subclass.dir = dir
11 end12 end
12 end13 end
13 14
lib/docs/filters/cakephp/clean_html.rb+30−17
@@ -2,44 +2,50 @@ module Docs · 1 unmodified line
2 class Cakephp2 class Cakephp
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if root_page?5 css('.breadcrumbs', 'a.permalink', 'a.anchor').remove
6 css('.section').remove
7 end
8 6
9 css('.breadcrumbs', '.info', 'a.permalink').remove7 css('.section', '#content', '.description', '.list').each do |node|
8 node.before(node.children).remove
9 end
10 10
11 css('h1').drop(1).each do |node|11 css('h1').drop(1).each do |node|
12 node.name = 'h2'12 node.name = 'h2'
13 end13 end
14 14
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
15 css('.property-name').each do |node|23 css('.property-name').each do |node|
16 node.name = 'h3'24 node.name = 'h3'
17 end25 end
18 26
27 css('var').each do |node|
28 node.name = 'code'
29 end
30
19 # Move dummy anchor to method and property name31 # Move dummy anchor to method and property name
32
20 css('.method-detail').each do |node|33 css('.method-detail').each do |node|
21 node.at_css('.method-name')['id'] = node.at_css('a')['id']34 node.at_css('.method-name')['id'] = node.at_css('a')['id']
22 end35 end
36
23 css('.property-detail').each do |node|37 css('.property-detail').each do |node|
24 node.at_css('.property-name')['id'] = node['id']38 node.at_css('.property-name')['id'] = node['id']
25 node.remove_attribute('id')39 node.remove_attribute('id')
26 end40 end
27 41
28 # Break out source link to separate element42 # Break out source link to separate element
43
29 css('.method-name', '.property-name').each do |node|44 css('.method-name', '.property-name').each do |node|
30 source = node.at_css('a')45 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>))
32 source.content = 'source'47 source.content = 'source'
33 end48 source['class'] = 'source'
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
43 end49 end
44 50
45 css('.method-signature').each do |node|51 css('.method-signature').each do |node|
@@ -51,8 +57,15 @@ module Docs · 5 unmodified lines
51 node.content = node.content.strip57 node.content = node.content.strip
52 end58 end
53 59
54 # Pages don't share a nice common base css tag.60 css('code code').each do |node|
55 doc.children61 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
56 end69 end
57 end70 end
58 end71 end
lib/docs/filters/cakephp/entries.rb+40−32
@@ -1,55 +1,63 @@
1module Docs1module Docs
2 class Cakephp2 class Cakephp
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 INCLUDE_PAGE_TYPES = {4 def page_type
5 'class' => true,5 @page_type ||= slug.split('-').first
6 'function' => true,
7 'namespace' => false,
8 }
9
10 def get_page_type
11 page_type = slug.split('-')[0]
12 end6 end
13 7
14 def include_default_entry?8 def slug_without_page_type
15 INCLUDE_PAGE_TYPES[get_page_type]9 @slug_without_page_type ||= slug.split('-').last
16 end10 end
17 11
18 def get_name12 def get_name
19 case get_page_type13 case page_type
20 when 'class'14 when 'class'
21 slug.split('.').last15 slug_without_page_type.split('.').last.concat(' (class)')
22 when 'function'16 when 'function'
23 at_css('h1').content.split(' ')[1]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})")
24 end22 end
25 end23 end
26 24
27 def get_type25 def get_type
28 case get_page_type26 return 'Global' if slug == 'namespace-None'
29 when 'class'27 case page_type
30 slug.split('.')[1..-2].join('\\')28 when 'class', 'namespace', 'package'
31 when 'function'29 if (node = at_css('.info')) && node.content =~ /Located at\s+((?:\w+\/?)+)/ # for 2.x docs
32 'Global Functions'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'
33 end40 end
34 end41 end
35 42
36 def additional_entries43 def additional_entries
44 return [] unless page_type == 'class'
45 class_name = name.remove(' (class)')
46 return [] if class_name.end_with?('Exception')
37 entries = []47 entries = []
38 if get_page_type == 'class'48
39 css('.method-name').each do |node|49 css('.method-name').each do |node|
40 name = get_name + '::' + node.at_css('.name').content.strip + '()'50 break if node.parent.previous_element.content =~ /\AMethods.*from/
41 id = node['id']51 entries << ["#{class_name}::#{node.at_css('.name').content.strip}()", 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
49 end52 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
50 entries59 entries
51 end60 end
52
53 end61 end
54 end62 end
55end63end
lib/docs/scrapers/cakephp.rb+25−6
@@ -2,9 +2,7 @@ module Docs · 1 unmodified line
2 class Cakephp < FileScraper2 class Cakephp < FileScraper
3 self.name = 'CakePHP'3 self.name = 'CakePHP'
4 self.type = 'cakephp'4 self.type = 'cakephp'
5 self.version = '3.1'5 self.dir = '/Users/Thibaut/DevDocs/Docs/CakePHP'
6 self.dir = ''
7 self.base_url = "http://api.cakephp.org/#{version}/"
8 self.root_path = 'index.html'6 self.root_path = 'index.html'
9 self.links = {7 self.links = {
10 home: 'http://cakephp.org/',8 home: 'http://cakephp.org/',
@@ -15,12 +13,33 @@ module Docs · 4 unmodified lines
15 13
16 options[:container] = '#right.columns.nine'14 options[:container] = '#right.columns.nine'
17 15
18 # CakePHP docs include full source code. Ignore it.
19 options[:skip_patterns] = [/\Asource-/]16 options[:skip_patterns] = [/\Asource-/]
20 17
21 options[:attribution] = <<-HTML18 options[:attribution] = <<-HTML
22 &copy; 2005&ndash;2015 The Cake Software Foundation, Inc.<br>19 &copy; 2005&ndash;2016 The Cake Software Foundation, Inc.<br>
23 Licensed under the MIT License.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.
24 HTML23 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
25 end44 end
26end45end
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