Skip to content

Commit c8291a7

Browse files
simon04Thibaut
authored andcommitted
Add leaflet doc
1 parent b1c37f9 commit c8291a7

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module Docs
2+
class Leaflet
3+
class CleanHtmlFilter < Filter
4+
def call
5+
css('#toc', '.expander').remove
6+
7+
# remove "This reference reflects Leaflet 1.2.0."
8+
css('h2 ~ p').each do |node|
9+
node.remove
10+
break
11+
end
12+
13+
# syntax highlighting
14+
css('code.lang-js').each do |node|
15+
node.parent['data-language'] = 'javascript'
16+
node.parent.content = node.content
17+
end
18+
19+
doc
20+
end
21+
end
22+
end
23+
end

lib/docs/filters/leaflet/entries.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Docs
2+
class Leaflet
3+
class EntriesFilter < Docs::EntriesFilter
4+
def additional_entries
5+
entries = []
6+
type = nil
7+
subtype = nil
8+
9+
css('*').each do |node|
10+
if node.name == 'h2' && node['id']
11+
type = node.content
12+
subtype = nil
13+
entries << [type, node['id'], type]
14+
elsif node.name == 'h3'
15+
subtype = node.content
16+
elsif node.name == 'tr' && node['id']
17+
value = node.css('td > code > b').first.content
18+
if subtype && subtype.end_with?(' options')
19+
name = "#{subtype}: #{value}"
20+
elsif subtype
21+
name = "#{type} #{subtype.downcase}: #{value}"
22+
else
23+
name = "#{type}: #{value}"
24+
end
25+
entries << [name, node['id'], type]
26+
end
27+
end
28+
29+
entries
30+
end
31+
end
32+
end
33+
end

lib/docs/scrapers/leaflet.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module Docs
2+
class Leaflet < UrlScraper
3+
self.name = 'Leaflet'
4+
self.type = 'leaflet'
5+
self.slug = 'leaflet'
6+
self.links = {
7+
home: 'http://leafletjs.com/',
8+
code: 'https://github.com/Leaflet/Leaflet'
9+
}
10+
11+
html_filters.push 'leaflet/entries', 'leaflet/clean_html', 'title'
12+
13+
options[:container] = '.container'
14+
options[:skip_links] = true
15+
16+
options[:attribution] = <<-HTML
17+
&copy; 2017 <a href="http://agafonkin.com/en">Vladimir Agafonkin</a>.
18+
Maps &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors.</p>
19+
HTML
20+
21+
version '1.2' do
22+
self.release = '1.2.0'
23+
self.base_url = "http://leafletjs.com/reference-#{release}.html"
24+
end
25+
26+
version '1.1' do
27+
self.release = '1.1.0'
28+
self.base_url = "http://leafletjs.com/reference-#{release}.html"
29+
end
30+
31+
version '1.0' do
32+
self.release = '1.0.3'
33+
self.base_url = "http://leafletjs.com/reference-#{release}.html"
34+
end
35+
36+
end
37+
end

public/icons/docs/leaflet/16.png

826 Bytes
Loading
1.83 KB
Loading

public/icons/docs/leaflet/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http://leafletjs.com/docs/images/favicon.ico

0 commit comments

Comments
 (0)