mirror of https://github.com/freeCodeCamp/devdocs
commit
45d6e22dca
@ -1,4 +1,4 @@
|
||||
._c {
|
||||
._cppref {
|
||||
> h2, > h3 { @extend %block-heading; }
|
||||
> h4 { @extend %block-label, %label-blue; }
|
||||
.fmbox { @extend %note; }
|
@ -1,11 +0,0 @@
|
||||
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
|
@ -1,11 +0,0 @@
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
module Docs
|
||||
class C
|
||||
class Cppref
|
||||
class FixCodeFilter < Filter
|
||||
def call
|
||||
css('div > span.source-c', 'div > span.source-cpp').each do |node|
|
@ -1,42 +0,0 @@
|
||||
module Docs
|
||||
class C < FileScraper
|
||||
self.type = '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[:decode_and_clean_paths] = true
|
||||
options[:container] = '#content'
|
||||
options[:title] = false
|
||||
options[:root_title] = 'C Programming Language'
|
||||
options[:skip] = %w(language/history.html)
|
||||
options[:skip_patterns] = [/experimental/]
|
||||
|
||||
options[:fix_urls] = ->(url) do
|
||||
url.sub! %r{\A.+/http%3A/}, 'http://'
|
||||
url.sub! 'http://en.cppreference.com/upload.cppreference.com', 'http://upload.cppreference.com'
|
||||
url
|
||||
end
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© cppreference.com<br>
|
||||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
|
||||
link = doc.at_css('a[title^="File:"]')
|
||||
date = link.content.scan(/(\d+)\./)[0][0]
|
||||
DateTime.strptime(date, '%Y%m%d').to_time.to_i
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def file_path_for(*)
|
||||
URI.unescape(super)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,52 +0,0 @@
|
||||
module Docs
|
||||
class Cpp < FileScraper
|
||||
self.name = 'C++'
|
||||
self.slug = 'cpp'
|
||||
self.type = 'c'
|
||||
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[:decode_and_clean_paths] = true
|
||||
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[:skip_patterns] = [/experimental/]
|
||||
options[:only_patterns] = [/\.html\z/]
|
||||
|
||||
options[:fix_urls] = ->(url) do
|
||||
url = CGI.unescape(url)
|
||||
url.sub! %r{\A.+/http%3A/}, 'http://'
|
||||
url.sub! 'http://en.cppreference.com/upload.cppreference.com', 'http://upload.cppreference.com'
|
||||
url
|
||||
end
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© cppreference.com<br>
|
||||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
|
||||
HTML
|
||||
|
||||
# Same as get_latest_version in lib/docs/scrapers/c.rb
|
||||
def get_latest_version(opts)
|
||||
doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
|
||||
link = doc.at_css('a[title^="File:"]')
|
||||
date = link.content.scan(/(\d+)\./)[0][0]
|
||||
DateTime.strptime(date, '%Y%m%d').to_time.to_i
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def file_path_for(*)
|
||||
URI.unescape(super)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
module Docs
|
||||
class C < Cppref
|
||||
self.name = 'c'
|
||||
self.slug = 'c'
|
||||
self.base_url = 'https://en.cppreference.com/w/c/'
|
||||
|
||||
html_filters.insert_before 'cppref/clean_html', 'c/entries'
|
||||
|
||||
options[:root_title] = 'C Programming Language'
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
module Docs
|
||||
class Cpp < Cppref
|
||||
self.name = 'C++'
|
||||
self.slug = 'cpp'
|
||||
self.base_url = 'https://en.cppreference.com/w/cpp/'
|
||||
|
||||
html_filters.insert_before 'cppref/clean_html', 'cpp/entries'
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
module Docs
|
||||
class Cppref < UrlScraper
|
||||
self.abstract = true
|
||||
self.type = 'cppref'
|
||||
self.root_path = 'header'
|
||||
|
||||
html_filters.insert_before 'clean_html', 'cppref/fix_code'
|
||||
html_filters.push 'cppref/clean_html', 'title'
|
||||
|
||||
options[:decode_and_clean_paths] = true
|
||||
options[:container] = '#content'
|
||||
options[:title] = false
|
||||
options[:skip] = %w(language/history.html)
|
||||
|
||||
options[:skip_patterns] = [
|
||||
/experimental/
|
||||
]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© cppreference.com<br>
|
||||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
|
||||
HTML
|
||||
|
||||
# Check if the 'headers' page has changed
|
||||
def get_latest_version(opts)
|
||||
doc = fetch_doc(self.base_url + self.root_path, opts)
|
||||
date = doc.at_css('#footer-info-lastmod').content
|
||||
date = date.match(/[[:digit:]]{1,2} .* [[:digit:]]{4}/).to_s
|
||||
date = DateTime.strptime(date, '%e %B %Y').to_time.to_i
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in new issue