diff --git a/lib/docs/filters/leaflet/clean_html.rb b/lib/docs/filters/leaflet/clean_html.rb new file mode 100644 index 00000000..c8d000f3 --- /dev/null +++ b/lib/docs/filters/leaflet/clean_html.rb @@ -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 diff --git a/lib/docs/filters/leaflet/entries.rb b/lib/docs/filters/leaflet/entries.rb new file mode 100644 index 00000000..c246d5ad --- /dev/null +++ b/lib/docs/filters/leaflet/entries.rb @@ -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 diff --git a/lib/docs/scrapers/leaflet.rb b/lib/docs/scrapers/leaflet.rb new file mode 100644 index 00000000..5e939394 --- /dev/null +++ b/lib/docs/scrapers/leaflet.rb @@ -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 Vladimir Agafonkin. + Maps © OpenStreetMap contributors.
+ 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 diff --git a/public/icons/docs/leaflet/16.png b/public/icons/docs/leaflet/16.png new file mode 100644 index 00000000..d2627fe3 Binary files /dev/null and b/public/icons/docs/leaflet/16.png differ diff --git a/public/icons/docs/leaflet/16@2x.png b/public/icons/docs/leaflet/16@2x.png new file mode 100644 index 00000000..8ebfbc05 Binary files /dev/null and b/public/icons/docs/leaflet/16@2x.png differ diff --git a/public/icons/docs/leaflet/SOURCE b/public/icons/docs/leaflet/SOURCE new file mode 100644 index 00000000..80b6994d --- /dev/null +++ b/public/icons/docs/leaflet/SOURCE @@ -0,0 +1 @@ +http://leafletjs.com/docs/images/favicon.ico