Browse Source

Add OpenLayers documentation (10.4.0)

Simon Legner 9 months ago
parent
commit
4ad6715ec1

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
 [
+  [
+    "2025-02-16",
+    "New documentation: <a href=\"/openlayers/\">OpenLayers</a>"
+  ],
   [
   [
     "2024-11-23",
     "2024-11-23",
     "New documentation: <a href=\"/duckdb/\">DuckDB</a>"
     "New documentation: <a href=\"/duckdb/\">DuckDB</a>"

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -97,6 +97,7 @@
         'pages/nushell',
         'pages/nushell',
         'pages/octave',
         'pages/octave',
         'pages/openjdk',
         'pages/openjdk',
+        'pages/openlayers',
         'pages/perl',
         'pages/perl',
         'pages/phalcon',
         'pages/phalcon',
         'pages/phaser',
         'pages/phaser',

+ 10 - 0
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; }
+}

+ 18 - 0
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

+ 22 - 0
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

+ 24 - 0
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
+      &copy; 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

BIN
public/icons/docs/openlayers/16.png


BIN
public/icons/docs/openlayers/16@2x.png


+ 2 - 0
public/icons/docs/openlayers/SOURCE

@@ -0,0 +1,2 @@
+https://github.com/openlayers
+https://avatars.githubusercontent.com/u/240579?s=64