Update C/C++ documentation

Fixes #688.
Fixes #736.
pull/775/head
Thibaut Courouble 7 years ago
parent 4956a9ee38
commit 472f03d5b0

@ -46,6 +46,8 @@
+ div { margin-left: .5em; }
}
> table { margin: 0; }
}
.t-dcl-rev-aux > td:empty { padding: 0; }

@ -39,7 +39,10 @@ module Docs
end
def read_file(path)
File.read(path) rescue nil
File.read(path)
rescue
puts "Failed to open file: #{path}"
nil
end
end
end

@ -4,12 +4,17 @@ module Docs
def call
css('h1').remove if root_page?
css('.t-dcl-rev-aux td[rowspan]').each do |node|
rowspan = node['rowspan'].to_i
node['rowspan'] = node.ancestors('tbody').css('tr').length if rowspan > 3
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', '.t-example-live-link',
'.t-dcl-rev-num > .t-dcl-rev-aux ~ tr:not(.t-dcl-rev-aux) > td:nth-child(2)').remove
css('#bodyContent', '.mw-content-ltr', 'span[style]', 'div[class^="t-ref"]',
css('#bodyContent', '.mw-content-ltr', 'span[style]', 'div[class^="t-ref"]', '.t-image',
'th > div', 'td > div', '.t-dsc-see', '.mainpagediv', 'code > b', 'tbody').each do |node|
node.before(node.children).remove
end
@ -78,7 +83,7 @@ module Docs
end
node.inner_html = node.inner_html.strip
node << '.' if node.content =~ /[a-zA-Z0-9\)]\z/
node.remove if node.content.blank?
node.remove if node.content.blank? && !node.at_css('img')
end
css('pre').each do |node|
@ -100,6 +105,10 @@ module Docs
node.content = node.content
end
css('img').each do |node|
node['src'] = node['src'].sub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
end
doc
end
end

@ -4,7 +4,6 @@ module Docs
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

@ -9,6 +9,7 @@ module Docs
html_filters.push 'c/entries', 'c/clean_html', 'title'
text_filters.push 'c/fix_urls'
options[:decode_and_clean_paths] = true
options[:container] = '#content'
options[:title] = false
options[:root_title] = 'C Programming Language'
@ -25,5 +26,11 @@ module Docs
&copy; cppreference.com<br>
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
private
def file_path_for(*)
URI.unescape(super)
end
end
end

@ -11,6 +11,7 @@ module Docs
html_filters.push 'cpp/entries', 'c/clean_html', 'title'
text_filters.push 'cpp/fix_urls'
options[:decode_and_clean_paths] = true
options[:container] = '#content'
options[:title] = false
options[:root_title] = 'C++ Programming Language'
@ -33,5 +34,11 @@ module Docs
&copy; cppreference.com<br>
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
private
def file_path_for(*)
URI.unescape(super)
end
end
end

Loading…
Cancel
Save