Add C++ documentation

pull/76/head
Thibaut 11 years ago
parent 63ca6912cd
commit 7d2b35bfe8

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

@ -39,7 +39,7 @@ app.templates.aboutPage = -> """
<ul>
<li><a href="https://www.heroku.com">Heroku</a> and <a href="http://newrelic.com">New Relic</a> for providing awesome free service
<li>Daniel Bruce for the <a href="http://www.entypo.com">Entypo</a> pictograms
<li><a href="http://www.jeremykratz.com/">Jeremy Kratz</a> for the C logo
<li><a href="http://www.jeremykratz.com/">Jeremy Kratz</a> for the C/C++ logo
</ul>
<h2 class="_lined-heading" id="faq">Questions & Answsers</h2>
@ -86,7 +86,7 @@ credits = [
'MIT',
'https://raw.github.com/jashkenas/backbone/master/LICENSE'
], [
'C',
'C<br>C++',
'cppreference.com',
'CC BY-SA',
'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA'

@ -24,7 +24,10 @@ newsItem = (date, news) ->
result
app.news = [
[ 1394928000000, # March 16, 2013
[ 1396137600000, # March 30, 2014
""" New <a href="/cpp/">C++</a> documentation """,
], [
1394928000000, # March 16, 2014
""" New <a href="/yii/">Yii</a> documentation """,
], [
1394236800000, # March 8, 2014

@ -3,4 +3,5 @@
class app.views.CPage extends app.views.BasePage
afterRender: ->
@highlightCode @findAll('pre.source-c, .source-c > pre'), 'c'
@highlightCode @findAll('pre.source-cpp, .source-cpp > pre'), 'cpp'
return

@ -4,7 +4,7 @@
width: 1rem;
height: 1rem;
background-image: image-url('icons.png');
background-size: 5rem 8rem;
background-size: 5rem 9rem;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@ -51,3 +51,4 @@
._icon-c:before { background-position: -2rem -7rem; }
%icon-path { background-position: -3rem -7rem; }
._icon-yii:before { background-position: -4rem -7rem; }
._icon-cpp:before { background-position: 0 -8rem; }

@ -19,4 +19,18 @@
color: $textColorLight;
}
.t-sdsc-nopad dl, .t-sdsc-nopad dd { margin: 0; }
td > h5 {
margin: 0;
line-height: inherit;
}
.t-inheritance-diagram {
display: table;
margin: 1rem 0;
padding: .375rem;
font-size: .75rem;
border: 1px solid #ccc;
border-radius: 2px;
}
}

@ -30,6 +30,14 @@ module Docs
node.name = 'code'
end
css('div > a > img[alt="About this image"]').each do |node|
node.parent.parent.remove
end
css('area[href]').each do |node|
node['href'] = node['href'].sub('.html', '')
end
doc
end
end

@ -0,0 +1,50 @@
module Docs
class Cpp
class EntriesFilter < Docs::EntriesFilter
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' }
def get_name
name = at_css('#firstHeading').content.strip
name.sub! 'C++ concepts: ', ''
name.sub! 'C++ keywords: ', ''
name.sub! 'C++ ', ''
name.sub! %r{\s\(.+\)}, ''
name.sub! %r{\AStandard library header <(.+)>\z}, '\1'
name = name.split(',').first
REPLACE_NAMES[name] || name
end
def get_type
if at_css('#firstHeading').content.include?('C++ keyword')
'Keywords'
elsif type = at_css('.t-navbar > div:nth-child(4) > :first-child').try(:content)
type.strip!
type.sub! ' library', ''
type.sub! ' utilities', ''
type.sub! 'C++ ', ''
type.capitalize!
type
end
end
def additional_entries
return [] unless include_default_entry?
names = at_css('#firstHeading').content.gsub(%r{\(.+?\)}, '').split(',')[1..-1]
names.each(&:strip!).reject! do |name|
name.size <= 2 || name == '...' || name =~ /\A[<>]/ || name.start_with?('operator')
end
names.map { |name| [name] }
end
def include_default_entry?
return @include_default_entry if defined? @include_default_entry
@include_default_entry = at_css('.t-navbar > div:nth-child(4) > a') && at_css('#firstHeading').content !~ /\A\s*operator./
end
end
end
end

@ -0,0 +1,12 @@
module Docs
class Cpp
class FixUrlsFilter < Filter
def call
html.gsub! File.join(Cpp.base_url, Cpp.root_path), Cpp.base_url[0..-2]
html.gsub! %r{#{Cpp.base_url}([^"']+?)\.html}, "#{Cpp.base_url}\\1"
html.gsub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
html
end
end
end
end

@ -0,0 +1,30 @@
module Docs
class Cpp < FileScraper
self.name = 'C++'
self.slug = 'cpp'
self.type = 'c'
self.dir = '/Users/Thibaut/DevDocs/Docs/C/en/cpp'
self.base_url = 'http://en.cppreference.com/w/cpp/'
self.root_path = 'header.html'
html_filters.insert_before 'clean_html', 'c/fix_code'
html_filters.push 'cpp/entries', 'c/clean_html', 'title'
text_filters.push 'cpp/fix_urls'
options[:container] = '#content'
options[:title] = false
options[:root_title] = 'C++ Programming Language'
options[:skip] = %w(
language/extending_std.html
language/history.html
regex/ecmascript.html
regex/regex_token_iterator/operator_cmp.html
)
options[:only_patterns] = [/\.html\z/]
options[:attribution] = <<-HTML
&copy; cppreference.com<br>
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -0,0 +1,2 @@
http://dribbble.com/shots/799814-Standard-C-Logo
with authorization from Jeremy Kratz
Loading…
Cancel
Save