mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
module Docs
|
|
class Crystal < UrlScraper
|
|
self.type = 'crystal'
|
|
self.release = '0.27.0'
|
|
self.base_url = 'https://crystal-lang.org/'
|
|
self.root_path = "api/#{release}/index.html"
|
|
self.initial_paths = %w(docs/index.html)
|
|
self.links = {
|
|
home: 'https://crystal-lang.org/',
|
|
code: 'https://github.com/crystal-lang/crystal'
|
|
}
|
|
|
|
html_filters.push 'crystal/entries', 'crystal/clean_html'
|
|
|
|
options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//]
|
|
options[:skip_patterns] = [/debug/i]
|
|
|
|
options[:replace_paths] = {
|
|
"api/#{release}/" => "api/#{release}/index.html",
|
|
'docs/' => 'docs/index.html'
|
|
}
|
|
|
|
options[:attribution] = ->(filter) {
|
|
if filter.slug.start_with?('docs')
|
|
<<-HTML
|
|
To the extent possible under law, the persons who contributed to this work
|
|
have waived<br>all copyright and related or neighboring rights to this work
|
|
by associating CC0 with it.
|
|
HTML
|
|
else
|
|
<<-HTML
|
|
© 2012–2018 Manas Technology Solutions.<br>
|
|
Licensed under the Apache License, Version 2.0.
|
|
HTML
|
|
end
|
|
}
|
|
|
|
def get_latest_version(opts)
|
|
body = fetch('https://crystal-lang.org/api', opts)
|
|
body.scan(/Crystal Docs ([0-9.]+)/)[0][0]
|
|
end
|
|
end
|
|
end
|