mirror of https://github.com/freeCodeCamp/devdocs
parent
d062b2aed9
commit
5b6d9d983b
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
@ -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
|
@ -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; }
|
||||
}
|
@ -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
|
@ -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
|
@ -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(/<br>\n?/, "\n").gsub("\n</p>\n", "</p>\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
|
@ -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
|
@ -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<br>
|
||||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,2 @@
|
||||
http://dribbble.com/shots/799814-Standard-C-Logo
|
||||
with authorization from Jeremy Kratz
|
Loading…
Reference in new issue