mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add leaflet doc
This commit is contained in:
parent
b1c37f9404
commit
c8291a7428
6 changed files with 94 additions and 0 deletions
23
lib/docs/filters/leaflet/clean_html.rb
Normal file
23
lib/docs/filters/leaflet/clean_html.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
module Docs
|
||||||
|
class Leaflet
|
||||||
|
class CleanHtmlFilter < Filter
|
||||||
|
def call
|
||||||
|
css('#toc', '.expander').remove
|
||||||
|
|
||||||
|
# remove "This reference reflects Leaflet 1.2.0."
|
||||||
|
css('h2 ~ p').each do |node|
|
||||||
|
node.remove
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
# syntax highlighting
|
||||||
|
css('code.lang-js').each do |node|
|
||||||
|
node.parent['data-language'] = 'javascript'
|
||||||
|
node.parent.content = node.content
|
||||||
|
end
|
||||||
|
|
||||||
|
doc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
33
lib/docs/filters/leaflet/entries.rb
Normal file
33
lib/docs/filters/leaflet/entries.rb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
module Docs
|
||||||
|
class Leaflet
|
||||||
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
def additional_entries
|
||||||
|
entries = []
|
||||||
|
type = nil
|
||||||
|
subtype = nil
|
||||||
|
|
||||||
|
css('*').each do |node|
|
||||||
|
if node.name == 'h2' && node['id']
|
||||||
|
type = node.content
|
||||||
|
subtype = nil
|
||||||
|
entries << [type, node['id'], type]
|
||||||
|
elsif node.name == 'h3'
|
||||||
|
subtype = node.content
|
||||||
|
elsif node.name == 'tr' && node['id']
|
||||||
|
value = node.css('td > code > b').first.content
|
||||||
|
if subtype && subtype.end_with?(' options')
|
||||||
|
name = "#{subtype}: #{value}"
|
||||||
|
elsif subtype
|
||||||
|
name = "#{type} #{subtype.downcase}: #{value}"
|
||||||
|
else
|
||||||
|
name = "#{type}: #{value}"
|
||||||
|
end
|
||||||
|
entries << [name, node['id'], type]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
37
lib/docs/scrapers/leaflet.rb
Normal file
37
lib/docs/scrapers/leaflet.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
module Docs
|
||||||
|
class Leaflet < UrlScraper
|
||||||
|
self.name = 'Leaflet'
|
||||||
|
self.type = 'leaflet'
|
||||||
|
self.slug = 'leaflet'
|
||||||
|
self.links = {
|
||||||
|
home: 'http://leafletjs.com/',
|
||||||
|
code: 'https://github.com/Leaflet/Leaflet'
|
||||||
|
}
|
||||||
|
|
||||||
|
html_filters.push 'leaflet/entries', 'leaflet/clean_html', 'title'
|
||||||
|
|
||||||
|
options[:container] = '.container'
|
||||||
|
options[:skip_links] = true
|
||||||
|
|
||||||
|
options[:attribution] = <<-HTML
|
||||||
|
© 2017 <a href="http://agafonkin.com/en">Vladimir Agafonkin</a>.
|
||||||
|
Maps © <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors.</p>
|
||||||
|
HTML
|
||||||
|
|
||||||
|
version '1.2' do
|
||||||
|
self.release = '1.2.0'
|
||||||
|
self.base_url = "http://leafletjs.com/reference-#{release}.html"
|
||||||
|
end
|
||||||
|
|
||||||
|
version '1.1' do
|
||||||
|
self.release = '1.1.0'
|
||||||
|
self.base_url = "http://leafletjs.com/reference-#{release}.html"
|
||||||
|
end
|
||||||
|
|
||||||
|
version '1.0' do
|
||||||
|
self.release = '1.0.3'
|
||||||
|
self.base_url = "http://leafletjs.com/reference-#{release}.html"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
BIN
public/icons/docs/leaflet/16.png
Normal file
BIN
public/icons/docs/leaflet/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 826 B |
BIN
public/icons/docs/leaflet/16@2x.png
Normal file
BIN
public/icons/docs/leaflet/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
1
public/icons/docs/leaflet/SOURCE
Normal file
1
public/icons/docs/leaflet/SOURCE
Normal file
|
@ -0,0 +1 @@
|
||||||
|
http://leafletjs.com/docs/images/favicon.ico
|
Loading…
Reference in a new issue