History

Add leaflet doc

Simon Legner committed 8 years ago

Commit c8291a71 parent b1c37f96 files · +92 −-2Browse files

Unified · Split

6 files
  1. lib/docs/filters/leaflet/clean_html.rb +23 −0
  2. lib/docs/filters/leaflet/entries.rb +33 −0
  3. lib/docs/scrapers/leaflet.rb +37 −0
  4. public/icons/docs/leaflet/16.png +0 −0
  5. public/icons/docs/leaflet/16@2x.png +0 −0
  6. public/icons/docs/leaflet/SOURCE +1 −0
lib/docs/filters/leaflet/clean_html.rb+23−0
@@ -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+33−0
@@ -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+37−0
@@ -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+0−0

Binary file not shown.

public/icons/docs/leaflet/16@2x.png+0−0

Binary file not shown.

public/icons/docs/leaflet/SOURCE+1−0
@@ -0,0 +1 @@
1+http://leafletjs.com/docs/images/favicon.ico

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t