diff --git a/assets/images/icons.png b/assets/images/icons.png index 4a8fe500..e451327b 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index 6d27e38e..33d88791 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index d1bd731b..fb092787 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,5 +1,8 @@ [ [ + "2016-02-14", + "New documentation: CakePHP" + ], [ "2016-01-31", "New documentations: Erlang and Tcl/Tk" ], [ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 0a3deaaf..d974c553 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -99,6 +99,11 @@ credits = [ 'cppreference.com', 'CC BY-SA', 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA' + ], [ + 'CakePHP', + '2005-2016 The Cake Software Foundation, Inc.', + 'MIT', + 'https://raw.githubusercontent.com/cakephp/cakephp/master/LICENSE.txt' ], [ 'Chai', '2011-2015 Jake Luer', diff --git a/assets/stylesheets/global/_classes.scss b/assets/stylesheets/global/_classes.scss index 33d209f4..389300cf 100644 --- a/assets/stylesheets/global/_classes.scss +++ b/assets/stylesheets/global/_classes.scss @@ -70,6 +70,11 @@ @extend %label; } +%label-yellow { + background: $noteBackground; + border-color: $noteBorder; +} + %note-green, %label-green { background: $noteGreenBackground; border-color: $noteGreenBorder; diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index df20b04d..6b3c51be 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -94,7 +94,7 @@ %icon-check-white { background-position: -9rem -6rem; } %icon-light { background-position: 0 -7rem; } %icon-light-white { background-position: -1rem -7rem; } -._icon-iojs:before { background-position: -2rem -7rem; @extend %darkIconFix !optional; } +._icon-cakephp:before { background-position: -2rem -7rem; } ._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; } ._icon-clojure:before { background-position: -4rem -7rem; } ._icon-symfony:before { background-position: -5rem -7rem; } diff --git a/assets/stylesheets/pages/_cakephp.scss b/assets/stylesheets/pages/_cakephp.scss index 2e24da6f..c7ef5d15 100644 --- a/assets/stylesheets/pages/_cakephp.scss +++ b/assets/stylesheets/pages/_cakephp.scss @@ -1,16 +1,17 @@ ._cakephp { - h2 { @extend %block-heading; } + @extend %simple; - h3 { @extend %block-label, %label-blue; } + h3 > .source { float: right; } + h3 > a, span.label, span.php-keyword1 { font-weight: normal; } - h3 > a { float: right; } - - h3 > a, - span.label, - span.php-keyword1 { - font-weight: normal; + h4 { + margin: 1.5em 0; + @extend %block-label; } - .tree > dd { margin-left: 0px; } - .list { margin-left: 20px; } + dl { margin: 1em 0; } + + .info { @extend %note; } + code { @extend %label; } + p > .label, dt > .label { @extend %label, %label-yellow; } } diff --git a/lib/docs/core/scrapers/file_scraper.rb b/lib/docs/core/scrapers/file_scraper.rb index 8c087213..58a252da 100644 --- a/lib/docs/core/scrapers/file_scraper.rb +++ b/lib/docs/core/scrapers/file_scraper.rb @@ -8,6 +8,7 @@ module Docs def inherited(subclass) super subclass.base_url = base_url + subclass.dir = dir end end diff --git a/lib/docs/filters/cakephp/clean_html.rb b/lib/docs/filters/cakephp/clean_html.rb index f6c20e17..8a09a9fc 100644 --- a/lib/docs/filters/cakephp/clean_html.rb +++ b/lib/docs/filters/cakephp/clean_html.rb @@ -2,44 +2,50 @@ module Docs class Cakephp class CleanHtmlFilter < Filter def call - if root_page? - css('.section').remove - end + css('.breadcrumbs', 'a.permalink', 'a.anchor').remove - css('.breadcrumbs', '.info', 'a.permalink').remove + css('.section', '#content', '.description', '.list').each do |node| + node.before(node.children).remove + end css('h1').drop(1).each do |node| node.name = 'h2' end + css('> h6').each do |node| + node.name = 'h2' + end + + css('h6').each do |node| + node.name = 'h4' + end + css('.property-name').each do |node| node.name = 'h3' end + css('var').each do |node| + node.name = 'code' + end + # Move dummy anchor to method and property name + css('.method-detail').each do |node| node.at_css('.method-name')['id'] = node.at_css('a')['id'] end + css('.property-detail').each do |node| node.at_css('.property-name')['id'] = node['id'] node.remove_attribute('id') end # Break out source link to separate element + css('.method-name', '.property-name').each do |node| source = node.at_css('a') - source.add_previous_sibling("#{source.content}") + source.before(%(#{source.content})) source.content = 'source' - end - - # These are missing in upstream documentation. Not sure why. - css('.section > h2').each do |node| - if node.content == "Method Detail" - node['id'] = 'methods' - end - if node.content == 'Properties summary' - node['id'] = 'properties' - end + source['class'] = 'source' end css('.method-signature').each do |node| @@ -51,8 +57,15 @@ module Docs node.content = node.content.strip end - # Pages don't share a nice common base css tag. - doc.children + css('code code').each do |node| + node.before(node.children).remove + end + + css('code').each do |node| + node.inner_html = node.inner_html.squish + end + + doc end end end diff --git a/lib/docs/filters/cakephp/entries.rb b/lib/docs/filters/cakephp/entries.rb index 56ca78dc..b0f0a001 100644 --- a/lib/docs/filters/cakephp/entries.rb +++ b/lib/docs/filters/cakephp/entries.rb @@ -1,55 +1,63 @@ module Docs class Cakephp class EntriesFilter < Docs::EntriesFilter - INCLUDE_PAGE_TYPES = { - 'class' => true, - 'function' => true, - 'namespace' => false, - } - - def get_page_type - page_type = slug.split('-')[0] + def page_type + @page_type ||= slug.split('-').first end - def include_default_entry? - INCLUDE_PAGE_TYPES[get_page_type] + def slug_without_page_type + @slug_without_page_type ||= slug.split('-').last end def get_name - case get_page_type - when 'class' - slug.split('.').last - when 'function' - at_css('h1').content.split(' ')[1] + case page_type + when 'class' + slug_without_page_type.split('.').last.concat(' (class)') + when 'function' + at_css('h1').content.remove('Function ') + when 'namespace', 'package' + slug_without_page_type.split('.').tap do |path| + path.shift if path.length > 1 + end.join('\\').concat(" (#{page_type})") end end def get_type - case get_page_type - when 'class' - slug.split('.')[1..-2].join('\\') - when 'function' - 'Global Functions' + return 'Global' if slug == 'namespace-None' + case page_type + when 'class', 'namespace', 'package' + if (node = at_css('.info')) && node.content =~ /Located at\s+((?:\w+\/?)+)/ # for 2.x docs + path = $1.split('/') + else + path = slug_without_page_type.split('.') + end + path.shift if path.length > 1 && path[0] == 'Cake' + path.pop if path.length > 1 + path.pop if path.last == 'Exception' + path.join('\\') + when 'function' + 'Global' end end def additional_entries + return [] unless page_type == 'class' + class_name = name.remove(' (class)') + return [] if class_name.end_with?('Exception') entries = [] - if get_page_type == 'class' - css('.method-name').each do |node| - name = get_name + '::' + node.at_css('.name').content.strip + '()' - id = node['id'] - entries << [name, id, get_type] - end - css('.property-name').each do |node| - name = get_name + '::' + node.at_css('.name').content.strip - id = node['id'] - entries << [name, id, get_type] - end + + css('.method-name').each do |node| + break if node.parent.previous_element.content =~ /\AMethods.*from/ + entries << ["#{class_name}::#{node.at_css('.name').content.strip}()", node['id']] end + + css('.property-name').each do |node| + break if node.parent.parent['class'].include?('used') + entries << ["#{class_name}::#{node.at_css('.name').content.strip}", node['id']] + end + entries end - end end end diff --git a/lib/docs/scrapers/cakephp.rb b/lib/docs/scrapers/cakephp.rb index 24dbb4dc..609b57dc 100644 --- a/lib/docs/scrapers/cakephp.rb +++ b/lib/docs/scrapers/cakephp.rb @@ -2,9 +2,7 @@ module Docs class Cakephp < FileScraper self.name = 'CakePHP' self.type = 'cakephp' - self.version = '3.1' - self.dir = '' - self.base_url = "http://api.cakephp.org/#{version}/" + self.dir = '/Users/Thibaut/DevDocs/Docs/CakePHP' self.root_path = 'index.html' self.links = { home: 'http://cakephp.org/', @@ -15,12 +13,33 @@ module Docs options[:container] = '#right.columns.nine' - # CakePHP docs include full source code. Ignore it. options[:skip_patterns] = [/\Asource-/] options[:attribution] = <<-HTML - © 2005–2015 The Cake Software Foundation, Inc.
- Licensed under the MIT License. + © 2005–2016 The Cake Software Foundation, Inc.
+ Licensed under the MIT License.
+ CakePHP is a registered trademark of Cake Software Foundation, Inc.
+ We are not endorsed by or affiliated with CakePHP. HTML + + version '3.2' do # http://api.cakephp.org/3.2/cakephp-api-documentation.zip + self.release = '3.2.2' + self.base_url = 'http://api.cakephp.org/3.2/' + end + + version '3.1' do # http://api.cakephp.org/3.1/cakephp-api-documentation.zip + self.release = '3.1.10' + self.base_url = 'http://api.cakephp.org/3.1/' + end + + version '2.8' do # http://api.cakephp.org/2.8/cakephp-api-documentation.zip + self.release = '2.8.0' + self.base_url = 'http://api.cakephp.org/2.8/' + end + + version '2.7' do # http://api.cakephp.org/2.7/cakephp-api-documentation.zip + self.release = '2.7.10' + self.base_url = 'http://api.cakephp.org/2.7/' + end end end diff --git a/public/icons/docs/cakephp/16.png b/public/icons/docs/cakephp/16.png index 41e8d0aa..687a5b39 100644 Binary files a/public/icons/docs/cakephp/16.png and b/public/icons/docs/cakephp/16.png differ diff --git a/public/icons/docs/cakephp/16@2x.png b/public/icons/docs/cakephp/16@2x.png index d4c668e5..fcddfbb0 100644 Binary files a/public/icons/docs/cakephp/16@2x.png and b/public/icons/docs/cakephp/16@2x.png differ