From c8291a742813be8798639cdebe8abe4584105951 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 12 Dec 2017 23:32:55 +0100 Subject: [PATCH] Add leaflet doc --- lib/docs/filters/leaflet/clean_html.rb | 23 +++++++++++++++ lib/docs/filters/leaflet/entries.rb | 33 ++++++++++++++++++++++ lib/docs/scrapers/leaflet.rb | 37 +++++++++++++++++++++++++ public/icons/docs/leaflet/16.png | Bin 0 -> 826 bytes public/icons/docs/leaflet/16@2x.png | Bin 0 -> 1879 bytes public/icons/docs/leaflet/SOURCE | 1 + 6 files changed, 94 insertions(+) create mode 100644 lib/docs/filters/leaflet/clean_html.rb create mode 100644 lib/docs/filters/leaflet/entries.rb create mode 100644 lib/docs/scrapers/leaflet.rb create mode 100644 public/icons/docs/leaflet/16.png create mode 100644 public/icons/docs/leaflet/16@2x.png create mode 100644 public/icons/docs/leaflet/SOURCE 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 0000000000000000000000000000000000000000..d2627fe32348d7e437b096a5bb2f196b7a23572e GIT binary patch literal 826 zcmV-A1I7G_P)f(DfYJP2Zr5dxw?K~{1Mi#bNngC0GJx$Q#MToSW>9YSvEK?Dy< zL?jT=__3_nxVy76^Jd=b_qw}0%*Se-x}fS;|N2+c)yKyWx6F2-=yW*>5+SI-0OiJ= z0_bVGksyg}P#-US!^~fquAO9{Ik9&Z0H9h;v#v4{oG%38fRw^BGrVUL6xEE@>S+>Z zAC7%gIw=*7vu6jU3k*C!KZGiX9f4L~6aodQq(~AYgcP9=^vTjfcmJAtI2)GKq|I$r z1*)zJ;`7Q#fSFr|djP5EH4&Ob1e0d4xr3AfS>`69n*K$HYL_uNdGDc=B&o#C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