diff --git a/assets/images/icons.png b/assets/images/icons.png index f87d15ea..87df7c39 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 1728d3e4..46588198 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 476b3453..87468d67 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -39,6 +39,7 @@ app.templates.aboutPage = -> """

Questions & Answsers

@@ -83,6 +84,11 @@ credits = [ '2010-2014 Jeremy Ashkenas, DocumentCloud', 'MIT', 'https://raw.github.com/jashkenas/backbone/master/LICENSE' + ], [ + 'C', + 'cppreference.com', + 'CC BY-SA', + 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA' ], [ 'CoffeeScript', '2009-2014 Jeremy Ashkenas', diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee b/assets/javascripts/templates/pages/news_tmpl.coffee index a767f935..1fa38b55 100644 --- a/assets/javascripts/templates/pages/news_tmpl.coffee +++ b/assets/javascripts/templates/pages/news_tmpl.coffee @@ -24,7 +24,10 @@ newsItem = (date, news) -> result app.news = [ - [ 1392508800000, # February 16, 2013 + [ 1393027200000, # February 22, 2013 + """ New C documentation """, + ], [ + 1392508800000, # February 16, 2013 """ New Moment.js documentation """, ], [ 1392163200000, # February 12, 2013 diff --git a/assets/javascripts/views/pages/c.coffee b/assets/javascripts/views/pages/c.coffee new file mode 100644 index 00000000..aa6daf83 --- /dev/null +++ b/assets/javascripts/views/pages/c.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.CPage extends app.views.BasePage + afterRender: -> + @highlightCode @findAll('pre.source-c, .source-c > pre'), 'c' + return diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 9baf4415..1a627c4e 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -28,6 +28,7 @@ 'components/mobile'; @import 'pages/angular', + 'pages/c', 'pages/coffeescript', 'pages/d3', 'pages/ember', diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index 8d8df115..417ce20b 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -48,3 +48,4 @@ ._icon-d3:before { background-position: -4rem -6rem; } ._icon-knockout:before { background-position: 0 -7rem; } ._icon-moment:before { background-position: -1rem -7rem; } +._icon-c:before { background-position: -2rem -7rem; } diff --git a/assets/stylesheets/pages/_c.scss b/assets/stylesheets/pages/_c.scss new file mode 100644 index 00000000..9bc384e3 --- /dev/null +++ b/assets/stylesheets/pages/_c.scss @@ -0,0 +1,22 @@ +._c { + > h2, > h3 { @extend %block-heading; } + > h4 { @extend %block-label, %label-blue; } + > p > code { @extend %label; } + + .t-dcl-begin pre { + margin: 0; + padding: 0; + line-height: inherit; + background: none; + border: 0; + box-shadow: none; + } + + .t-lines > span { display: block; } // numeric/fenv, string/byte, etc. + + .t-spar { // language/switch, language/for, etc. + font-style: italic; + color: $textColorLight; + } + .t-sdsc-nopad dl, .t-sdsc-nopad dd { margin: 0; } +} diff --git a/lib/docs/filters/c/clean_html.rb b/lib/docs/filters/c/clean_html.rb new file mode 100644 index 00000000..ed7d5995 --- /dev/null +++ b/lib/docs/filters/c/clean_html.rb @@ -0,0 +1,37 @@ +module Docs + class C + class CleanHtmlFilter < Filter + def call + if root_page? + doc.inner_html = ' ' + return doc + end + + css('#siteSub', '#contentSub', '.printfooter', '.t-navbar', '.editsection', '#toc', '.t-dsc-sep', '.t-dcl-sep', + '#catlinks', '.ambox-notice', '.mw-cite-backlink', '.t-sdsc-sep:first-child:last-child').remove + + css('#bodyContent', '.mw-content-ltr', 'span[style]').each do |node| + node.before(node.children).remove + end + + css('h2 > span[id]', 'h3 > span[id]', 'h4 > span[id]', 'h5 > span[id]', 'h6 > span[id]').each do |node| + node.parent['id'] = node['id'] + node.before(node.children).remove + end + + css('table[style]', 'th[style]', 'td[style]').remove_attr('style') + + css('.t-dsc-hitem > td', '.t-dsc-header > td').each do |node| + node.name = 'th' + node.content = ' ' if node.content.empty? + end + + css('tt').each do |node| + node.name = 'code' + end + + doc + end + end + end +end diff --git a/lib/docs/filters/c/entries.rb b/lib/docs/filters/c/entries.rb new file mode 100644 index 00000000..9e8dc854 --- /dev/null +++ b/lib/docs/filters/c/entries.rb @@ -0,0 +1,44 @@ +module Docs + class C + class EntriesFilter < Docs::EntriesFilter + ADDITIONAL_NAMES = { + 'Conditional inclusion' => %w(if else elif ifdef ifndef endif).map { |s| "##{s} directive" }, + 'Function specifiers' => ['inline specifier', '_Noreturn specifier'] } + + REPLACE_NAMES = { + 'Error directive' => '#error directive', + 'Filename and line information' => '#line directive', + 'Implementation defined behavior control' => '#pragma directive', + 'Replacing text macros' => '#define directive', + 'Source file inclusion' => '#include directive', + 'Warning directive' => '#warning directive' } + + def get_name + name = at_css('#firstHeading').content.strip + name.sub! 'C keywords: ', '' + name.sub! %r{\s\(.+\)}, '' + name = name.split(',').first + REPLACE_NAMES[name] || name + end + + def get_type + if type = at_css('.t-navbar > div:nth-child(4) > :first-child').try(:content) + type.strip! + type.sub! ' library', '' + type.sub! ' utilities', '' + type + end + end + + def additional_entries + names = at_css('#firstHeading').content.split(',')[1..-1] + names.concat ADDITIONAL_NAMES[name] || [] + names.map { |name| [name] } + end + + def include_default_entry? + at_css '.t-navbar > div:nth-child(4) > a' + end + end + end +end diff --git a/lib/docs/filters/c/fix_code.rb b/lib/docs/filters/c/fix_code.rb new file mode 100644 index 00000000..ef160b7f --- /dev/null +++ b/lib/docs/filters/c/fix_code.rb @@ -0,0 +1,21 @@ +module Docs + class C + class FixCodeFilter < Filter + def call + css('div > span.source-c').each do |node| + node.inner_html = node.inner_html.gsub(/
\n?/, "\n").gsub("\n

\n", "

\n") + node.parent.name = 'pre' + node.parent['class'] = 'source-c' + node.parent.content = node.content + end + + nbsp = Nokogiri::HTML(' ').text + css('pre').each do |node| + node.content = node.content.gsub(nbsp, ' ') + end + + doc + end + end + end +end diff --git a/lib/docs/filters/c/fix_urls.rb b/lib/docs/filters/c/fix_urls.rb new file mode 100644 index 00000000..a7d15d94 --- /dev/null +++ b/lib/docs/filters/c/fix_urls.rb @@ -0,0 +1,11 @@ +module Docs + class C + class FixUrlsFilter < Filter + def call + html.gsub! File.join(C.base_url, C.root_path), C.base_url[0..-2] + html.gsub! %r{#{C.base_url}([^"']+?)\.html}, "#{C.base_url}\\1" + html + end + end + end +end diff --git a/lib/docs/scrapers/c.rb b/lib/docs/scrapers/c.rb new file mode 100644 index 00000000..a294e698 --- /dev/null +++ b/lib/docs/scrapers/c.rb @@ -0,0 +1,22 @@ +module Docs + class C < FileScraper + self.type = 'c' + self.dir = '/Users/Thibaut/DevDocs/Docs/C/en/c' + self.base_url = 'http://en.cppreference.com/w/c/' + self.root_path = 'header.html' + + html_filters.insert_before 'clean_html', 'c/fix_code' + html_filters.push 'c/entries', 'c/clean_html', 'title' + text_filters.push 'c/fix_urls' + + options[:container] = '#content' + options[:title] = false + options[:root_title] = 'C Programming Language' + options[:skip] = %w(language/history.html) + + options[:attribution] = <<-HTML + © cppreference.com
+ Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0. + HTML + end +end diff --git a/public/icons/docs/c/16.png b/public/icons/docs/c/16.png new file mode 100644 index 00000000..f53cdaab Binary files /dev/null and b/public/icons/docs/c/16.png differ diff --git a/public/icons/docs/c/16@2x.png b/public/icons/docs/c/16@2x.png new file mode 100644 index 00000000..1a9bbcb0 Binary files /dev/null and b/public/icons/docs/c/16@2x.png differ diff --git a/public/icons/docs/c/SOURCE b/public/icons/docs/c/SOURCE new file mode 100644 index 00000000..bf9dedaa --- /dev/null +++ b/public/icons/docs/c/SOURCE @@ -0,0 +1,2 @@ +http://dribbble.com/shots/799814-Standard-C-Logo +with authorization from Jeremy Kratz