From 4ad6715ec13819b4c0ba9a0bae3f0831b6620651 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 16 Feb 2025 12:02:59 +0100 Subject: [PATCH] Add OpenLayers documentation (10.4.0) --- assets/javascripts/news.json | 4 ++++ assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_openlayers.scss | 10 +++++++++ lib/docs/filters/openlayers/clean_html.rb | 18 ++++++++++++++++ lib/docs/filters/openlayers/entries.rb | 22 ++++++++++++++++++++ lib/docs/scrapers/openlayers.rb | 24 ++++++++++++++++++++++ public/icons/docs/openlayers/16.png | Bin 0 -> 419 bytes public/icons/docs/openlayers/16@2x.png | Bin 0 -> 840 bytes public/icons/docs/openlayers/SOURCE | 2 ++ 9 files changed, 81 insertions(+) create mode 100644 assets/stylesheets/pages/_openlayers.scss create mode 100644 lib/docs/filters/openlayers/clean_html.rb create mode 100644 lib/docs/filters/openlayers/entries.rb create mode 100644 lib/docs/scrapers/openlayers.rb create mode 100644 public/icons/docs/openlayers/16.png create mode 100644 public/icons/docs/openlayers/16@2x.png create mode 100644 public/icons/docs/openlayers/SOURCE diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 052f4918..2c393d97 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2025-02-16", + "New documentation: OpenLayers" + ], [ "2024-11-23", "New documentation: DuckDB" diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index ca75b69e..b45e7b60 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -97,6 +97,7 @@ 'pages/nushell', 'pages/octave', 'pages/openjdk', + 'pages/openlayers', 'pages/perl', 'pages/phalcon', 'pages/phaser', diff --git a/assets/stylesheets/pages/_openlayers.scss b/assets/stylesheets/pages/_openlayers.scss new file mode 100644 index 00000000..50628b2f --- /dev/null +++ b/assets/stylesheets/pages/_openlayers.scss @@ -0,0 +1,10 @@ +._openlayers { + @extend %simple; + .nameContainer { + @extend %block-label; + > * { display: inline-block; margin: 0; } + > .tag-source { float: right; } + } + .card { @extend %box; margin-bottom: 1rem; padding: 1rem; } + .signature, .type-signature { @extend %code; } +} diff --git a/lib/docs/filters/openlayers/clean_html.rb b/lib/docs/filters/openlayers/clean_html.rb new file mode 100644 index 00000000..713306c2 --- /dev/null +++ b/lib/docs/filters/openlayers/clean_html.rb @@ -0,0 +1,18 @@ +module Docs + class Openlayers + class CleanHtmlFilter < Filter + def call + @doc = at_css('section') + + at_css('h2').name = 'h1' if at_css('h2') + + css('pre.prettyprint').each do |node| + node['data-language'] = node['class'].include?('html') ? 'html' : 'js' + node.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/openlayers/entries.rb b/lib/docs/filters/openlayers/entries.rb new file mode 100644 index 00000000..05e18850 --- /dev/null +++ b/lib/docs/filters/openlayers/entries.rb @@ -0,0 +1,22 @@ +module Docs + class Openlayers + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h2').text.split('~').last.strip + end + + def get_type + slug[/ol_([^_]+)_/, 1] or 'ol' + end + + def additional_entries + css('h4.name').each_with_object [] do |node, entries| + node['id'] = node.previous_element['id'] + name = node.children.find {|n| n.text? }.text.strip + name.prepend "#{self.name}." + entries << [name, node['id']] + end + end + end + end +end diff --git a/lib/docs/scrapers/openlayers.rb b/lib/docs/scrapers/openlayers.rb new file mode 100644 index 00000000..1c957fbd --- /dev/null +++ b/lib/docs/scrapers/openlayers.rb @@ -0,0 +1,24 @@ +module Docs + class Openlayers < UrlScraper + self.name = 'OpenLayers' + self.type = 'openlayers' + self.slug = 'openlayers' + self.release = '10.4.0' + self.base_url = "https://openlayers.org/en/latest/apidoc/" + self.links = { + home: 'https://openlayers.org/', + code: 'https://github.com/openlayers/openlayers' + } + + html_filters.push 'openlayers/entries', 'openlayers/clean_html' + + options[:attribution] = <<-HTML + © 2005-present, OpenLayers Contributors All rights reserved. + Licensed under the BSD 2-Clause License. + HTML + + def get_latest_version(opts) + get_npm_version('ol', opts) + end + end +end diff --git a/public/icons/docs/openlayers/16.png b/public/icons/docs/openlayers/16.png new file mode 100644 index 0000000000000000000000000000000000000000..fe90ebfbfba1e25db4758974593ef3a56ec3e23d GIT binary patch literal 419 zcmV;U0bKrxP)#LK4GqW>nw|vg(KOVaT z$UM7jr*!6bBPA&^D?hXd3N&>wz6sR!evwt*do&zr+HCC=hG1x3WJgw=%0KzAQS({0 zylK$kKjy5?6lF19e)QbA#^hkg1TNa1ODz9@67To>uKfxm@5aN)Cg8jQ#1P9Ok%*ql z<={9DK0V;T0fYdMZq$8vfNk5zX0src34#!kWx1wl8Y-0vT-QbO30Sxu!m%6R{u$Ky z8`^TFN-P^F8jTiHsZ=kY&!gMz;^hk{wSD`!)9HXZ+VE|G1xXY|Syk1RVHmJ13j>*^ z30>Dg9c{+`%#tLXrqgLRlgWV0^EbbpP{$@!I2_gziG)e!d1Y#k_7~uSYt|n_2zvkk N002ovPDHLkV1j2*!3Y2V literal 0 HcmV?d00001 diff --git a/public/icons/docs/openlayers/16@2x.png b/public/icons/docs/openlayers/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c39658a1350fa71e4099bc460939f5dfd90f0d36 GIT binary patch literal 840 zcmV-O1GoH%P)ugv4;17rQJkS64!ggSnq}ZcW zfa7E}oVw+wq0j6rEtrqw!tF2bAb=1uG(L}4BXI0|9mvi; zy#SYod%0+D z+7Y?7BIx=Wq$P5Mbd5uv-2z*q065Xs1W*62$|dJ{Mmjy08X+MEvUK2oGeU<`nyaG& z#HEk_w)5cOuOBIv^H3LaaxUEON|T(2IXSggn$vv&<`mKD^upN>E1`7Bi7QNjvQztgRLVW!b8N_)l{sN3p6w&)pb~)<|N0GDX0-2ea!oVKQ!`l|K*&9=Amoqy%iwzA8D0+zVE{JF}nnPBr^}G18 zs;UZyhK5i|FpQWpy0tuy%zO&rCIW!~?c{RmqE3*aQmJ%>g@q$@Kul|ED~7{i6p6$T z&x|LQpZkosyoQ`eB*HqRodpF218TKe4~Z}ujZLMcrK{qC$K%0ZFo;qH7Z7ttxtKi< zET9y+LwC8Db{Y(ZM%WG+85u>z#l=DC%{x0gF&d4cl*K