History

Add C++ documentation

Thibaut committed 12 years ago

Commit 7d2b35b1 parent 63ca69114 files · +121 −0Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +2 −2
  4. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  5. assets/javascripts/views/pages/c.coffee +1 −0
  6. assets/stylesheets/global/_icons.scss +2 −1
  7. assets/stylesheets/pages/_c.scss +14 −0
  8. lib/docs/filters/c/clean_html.rb +8 −0
  9. lib/docs/filters/cpp/entries.rb +50 −0
  10. lib/docs/filters/cpp/fix_urls.rb +12 −0
  11. lib/docs/scrapers/cpp.rb +30 −0
  12. public/icons/docs/cpp/16.png +0 −0
  13. public/icons/docs/cpp/16@2x.png +0 −0
  14. public/icons/docs/cpp/SOURCE +2 −0
assets/images/icons.png+0−0

Binary file not shown.

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

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+2−2
@@ -39,7 +39,7 @@ app.templates.aboutPage = -> """ · 38 unmodified lines
3939 <ul>
4040 <li><a href="https://www.heroku.com">Heroku</a> and <a href="http://newrelic.com">New Relic</a> for providing awesome free service
4141 <li>Daniel Bruce for the <a href="http://www.entypo.com">Entypo</a> pictograms
42− <li><a href="http://www.jeremykratz.com/">Jeremy Kratz</a> for the C logo
42+ <li><a href="http://www.jeremykratz.com/">Jeremy Kratz</a> for the C/C++ logo
4343 </ul>
4444
4545 <h2 class="_lined-heading" id="faq">Questions & Answsers</h2>
@@ -86,7 +86,7 @@ credits = [ · 40 unmodified lines
8686 'MIT',
8787 'https://raw.github.com/jashkenas/backbone/master/LICENSE'
8888 ], [
89− 'C',
89+ 'C<br>C++',
9090 'cppreference.com',
9191 'CC BY-SA',
9292 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA'
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -24,7 +24,10 @@ newsItem = (date, news) -> · 23 unmodified lines
2424 result
2525
2626 app.news = [
27− [ 1394928000000, # March 16, 2013
27+ [ 1396137600000, # March 30, 2014
28+ """ New <a href="/cpp/">C++</a> documentation """,
29+ ], [
30+ 1394928000000, # March 16, 2014
2831 """ New <a href="/yii/">Yii</a> documentation """,
2932 ], [
3033 1394236800000, # March 8, 2014
assets/javascripts/views/pages/c.coffee+1−0
@@ -3,4 +3,5 @@ · 2 unmodified lines
33 class app.views.CPage extends app.views.BasePage
44 afterRender: ->
55 @highlightCode @findAll('pre.source-c, .source-c > pre'), 'c'
6+ @highlightCode @findAll('pre.source-cpp, .source-cpp > pre'), 'cpp'
67 return
assets/stylesheets/global/_icons.scss+2−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 width: 1rem;
55 height: 1rem;
66 background-image: image-url('icons.png');
7− background-size: 5rem 8rem;
7+ background-size: 5rem 9rem;
88 }
99
1010 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -51,3 +51,4 @@ · 40 unmodified lines
5151 ._icon-c:before { background-position: -2rem -7rem; }
5252 %icon-path { background-position: -3rem -7rem; }
5353 ._icon-yii:before { background-position: -4rem -7rem; }
54+._icon-cpp:before { background-position: 0 -8rem; }
assets/stylesheets/pages/_c.scss+14−0
@@ -19,4 +19,18 @@ · 18 unmodified lines
1919 color: $textColorLight;
2020 }
2121 .t-sdsc-nopad dl, .t-sdsc-nopad dd { margin: 0; }
22+
23+ td > h5 {
24+ margin: 0;
25+ line-height: inherit;
26+ }
27+
28+ .t-inheritance-diagram {
29+ display: table;
30+ margin: 1rem 0;
31+ padding: .375rem;
32+ font-size: .75rem;
33+ border: 1px solid #ccc;
34+ border-radius: 2px;
35+ }
2236 }
lib/docs/filters/c/clean_html.rb+8−0
@@ -30,6 +30,14 @@ module Docs · 29 unmodified lines
3030 node.name = 'code'
3131 end
3232
33+ css('div > a > img[alt="About this image"]').each do |node|
34+ node.parent.parent.remove
35+ end
36+
37+ css('area[href]').each do |node|
38+ node['href'] = node['href'].sub('.html', '')
39+ end
40+
3341 doc
3442 end
3543 end
lib/docs/filters/cpp/entries.rb+50−0
@@ -0,0 +1,50 @@
1+module Docs
2+ class Cpp
3+ class EntriesFilter < Docs::EntriesFilter
4+ REPLACE_NAMES = {
5+ 'Error directive' => '#error directive',
6+ 'Filename and line information' => '#line directive',
7+ 'Implementation defined behavior control' => '#pragma directive',
8+ 'Replacing text macros' => '#define directive',
9+ 'Source file inclusion' => '#include directive' }
10+
11+ def get_name
12+ name = at_css('#firstHeading').content.strip
13+ name.sub! 'C++ concepts: ', ''
14+ name.sub! 'C++ keywords: ', ''
15+ name.sub! 'C++ ', ''
16+ name.sub! %r{\s\(.+\)}, ''
17+ name.sub! %r{\AStandard library header <(.+)>\z}, '\1'
18+ name = name.split(',').first
19+ REPLACE_NAMES[name] || name
20+ end
21+
22+ def get_type
23+ if at_css('#firstHeading').content.include?('C++ keyword')
24+ 'Keywords'
25+ elsif type = at_css('.t-navbar > div:nth-child(4) > :first-child').try(:content)
26+ type.strip!
27+ type.sub! ' library', ''
28+ type.sub! ' utilities', ''
29+ type.sub! 'C++ ', ''
30+ type.capitalize!
31+ type
32+ end
33+ end
34+
35+ def additional_entries
36+ return [] unless include_default_entry?
37+ names = at_css('#firstHeading').content.gsub(%r{\(.+?\)}, '').split(',')[1..-1]
38+ names.each(&:strip!).reject! do |name|
39+ name.size <= 2 || name == '...' || name =~ /\A[<>]/ || name.start_with?('operator')
40+ end
41+ names.map { |name| [name] }
42+ end
43+
44+ def include_default_entry?
45+ return @include_default_entry if defined? @include_default_entry
46+ @include_default_entry = at_css('.t-navbar > div:nth-child(4) > a') && at_css('#firstHeading').content !~ /\A\s*operator./
47+ end
48+ end
49+ end
50+end
lib/docs/filters/cpp/fix_urls.rb+12−0
@@ -0,0 +1,12 @@
1+module Docs
2+ class Cpp
3+ class FixUrlsFilter < Filter
4+ def call
5+ html.gsub! File.join(Cpp.base_url, Cpp.root_path), Cpp.base_url[0..-2]
6+ html.gsub! %r{#{Cpp.base_url}([^"']+?)\.html}, "#{Cpp.base_url}\\1"
7+ html.gsub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
8+ html
9+ end
10+ end
11+ end
12+end
lib/docs/scrapers/cpp.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Cpp < FileScraper
3+ self.name = 'C++'
4+ self.slug = 'cpp'
5+ self.type = 'c'
6+ self.dir = '/Users/Thibaut/DevDocs/Docs/C/en/cpp'
7+ self.base_url = 'http://en.cppreference.com/w/cpp/'
8+ self.root_path = 'header.html'
9+
10+ html_filters.insert_before 'clean_html', 'c/fix_code'
11+ html_filters.push 'cpp/entries', 'c/clean_html', 'title'
12+ text_filters.push 'cpp/fix_urls'
13+
14+ options[:container] = '#content'
15+ options[:title] = false
16+ options[:root_title] = 'C++ Programming Language'
17+ options[:skip] = %w(
18+ language/extending_std.html
19+ language/history.html
20+ regex/ecmascript.html
21+ regex/regex_token_iterator/operator_cmp.html
22+ )
23+ options[:only_patterns] = [/\.html\z/]
24+
25+ options[:attribution] = <<-HTML
26+ &copy; cppreference.com<br>
27+ Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
28+ HTML
29+ end
30+end
public/icons/docs/cpp/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/cpp/SOURCE+2−0
@@ -0,0 +1,2 @@
1+http://dribbble.com/shots/799814-Standard-C-Logo
2+with authorization from Jeremy Kratz