mirror of https://github.com/freeCodeCamp/devdocs
parent
63ca6912cd
commit
7d2b35bfe8
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
@ -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
|
||||
© cppreference.com<br>
|
||||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 663 B |
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…
Reference in new issue