Add leaflet doc

This commit is contained in:
Simon Legner 2017-12-12 23:32:55 +01:00 committed by Thibaut Courouble
parent b1c37f9404
commit c8291a7428
6 changed files with 94 additions and 0 deletions

View 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

View 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

View 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
&copy; 2017 <a href="http://agafonkin.com/en">Vladimir Agafonkin</a>.
Maps &copy; <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

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1 @@
http://leafletjs.com/docs/images/favicon.ico