mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
pony: finish scraper and filters
This commit is contained in:
parent
333b67d57d
commit
eb82f6024c
6 changed files with 59 additions and 16 deletions
|
@ -568,6 +568,12 @@ credits = [
|
||||||
'CC BY',
|
'CC BY',
|
||||||
'https://creativecommons.org/licenses/by/3.0/'
|
'https://creativecommons.org/licenses/by/3.0/'
|
||||||
], [
|
], [
|
||||||
|
'Pony',
|
||||||
|
'2016-2018, The Pony Developers & 2014-2015, Causality Ltd.',
|
||||||
|
'BSD',
|
||||||
|
'https://raw.githubusercontent.com/ponylang/ponyc/master/LICENSE'
|
||||||
|
],
|
||||||
|
[
|
||||||
'PostgreSQL',
|
'PostgreSQL',
|
||||||
'1996-2018 The PostgreSQL Global Development Group<br>© 1994 The Regents of the University of California',
|
'1996-2018 The PostgreSQL Global Development Group<br>© 1994 The Regents of the University of California',
|
||||||
'PostgreSQL',
|
'PostgreSQL',
|
||||||
|
|
15
lib/docs/filters/pony/clean_html.rb
Normal file
15
lib/docs/filters/pony/clean_html.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
module Docs
|
||||||
|
class Pony
|
||||||
|
class CleanHtmlFilter < Filter
|
||||||
|
def call
|
||||||
|
css('.headerlink').remove
|
||||||
|
|
||||||
|
css('pre').each do |node|
|
||||||
|
node.content = node.content
|
||||||
|
end
|
||||||
|
|
||||||
|
doc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +0,0 @@
|
||||||
module Docs
|
|
||||||
class Pony
|
|
||||||
class ContainerFilter < Filter
|
|
||||||
def call
|
|
||||||
css('article')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -2,11 +2,33 @@ module Docs
|
||||||
class Pony
|
class Pony
|
||||||
class EntriesFilter < Docs::EntriesFilter
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
def get_name
|
def get_name
|
||||||
context[:html_title].sub(/ - .*/, '')
|
title = context[:html_title].sub(/ - .*/, '').split(' ').last
|
||||||
|
title = "1. #{type}" if title == 'Package'
|
||||||
|
title
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_type
|
def get_type
|
||||||
subpath.split('-')[0][0..-1]
|
subpath.split(/-([^a-z])/)[0][0..-1].sub('-', '/')
|
||||||
|
end
|
||||||
|
|
||||||
|
def additional_entries
|
||||||
|
return [] if root_page? || name.start_with?("1. ")
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
|
||||||
|
css('h3').each do |node|
|
||||||
|
member_name = node.content
|
||||||
|
|
||||||
|
is_field = member_name.start_with?('let ')
|
||||||
|
member_name = member_name[4..-1] if is_field
|
||||||
|
|
||||||
|
member_name = member_name.scan(/^([a-zA-Z0-9_]+)/)[0][0]
|
||||||
|
member_name += '()' unless is_field
|
||||||
|
|
||||||
|
entries << ["#{name}.#{member_name}", node['id']]
|
||||||
|
end
|
||||||
|
|
||||||
|
entries
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
module Docs
|
module Docs
|
||||||
class Pony < UrlScraper
|
class Pony < UrlScraper
|
||||||
self.type = 'pony'
|
self.type = 'simple'
|
||||||
self.release = '0.25.0'
|
self.release = '0.30.0'
|
||||||
self.base_url = 'https://stdlib.ponylang.io/'
|
self.base_url = 'https://stdlib.ponylang.io/'
|
||||||
|
self.links = {
|
||||||
|
home: 'https://www.ponylang.io/',
|
||||||
|
code: 'https://github.com/ponylang/ponyc'
|
||||||
|
}
|
||||||
|
|
||||||
html_filters.push 'pony/container', 'pony/entries'
|
html_filters.push 'pony/clean_html', 'pony/entries'
|
||||||
|
|
||||||
options[:attribution] = <<-HTML
|
options[:attribution] = <<-HTML
|
||||||
© 2016-2018, The Pony Developers<br>
|
© 2016-2018, The Pony Developers<br>
|
||||||
© 2014-2015, Causality Ltd.<br>
|
© 2014-2015, Causality Ltd.<br>
|
||||||
Licensed under the <a href="https://github.com/ponylang/ponyc/blob/master/LICENSE">BSD 2-Clause License</a>
|
Licensed under the BSD 2-Clause License.
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
|
options[:container] = 'article'
|
||||||
options[:trailing_slash] = false
|
options[:trailing_slash] = false
|
||||||
options[:skip_patterns] = [/src/]
|
options[:skip_patterns] = [/src/, /stdlib--index/]
|
||||||
|
|
||||||
|
def get_latest_version(opts)
|
||||||
|
get_latest_github_release('ponylang', 'ponyc', opts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in a new issue