Browse Source

Merge pull request #2500 from dorimon-1/vertx

Add vertx docs
Simon Legner 6 months ago
parent
commit
bc77916eb6

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2025-05-28",
+    "New documentation: <a href=\"/vertx/\">Vert.x</a>"
+  ],
   [
     "2025-02-23",
     "New documentation: <a href=\"/threejs/\">Three.js</a>"

+ 40 - 0
lib/docs/filters/vertx/clean_html.rb

@@ -0,0 +1,40 @@
+module Docs
+  class Vertx
+    class CleanHtmlFilter < Filter
+      def call
+        css('footer', 'hr', 'header', 'nav', '.navbar', '.topbar', '.bg-bg-warning').remove
+        xpath('//*[@id="docs-layout"]/div/div[3]').remove
+        xpath('//*[@id="docs-layout"]/div/div[1]').remove
+        xpath('//main/div[last()]').remove
+        xpath('//main/div[1]').remove
+        css('#changelog').remove if root_page?
+
+        # Set id attributes on <h3> instead of an empty <a>
+        css('h3').each do |node|
+          anchor = node.at_css('a')
+          node['id'] = anchor['id'] if anchor && anchor['id']
+        end
+
+        # Make proper table headers
+        css('td.header').each do |node|
+          node.name = 'th'
+        end
+
+        # Remove code highlighting
+        css('pre').each do |node|
+          node['data-language'] = node.at_css('code')['data-lang'] if node.at_css('code')
+          node.content = node.content
+        end
+
+        # ❗ Skip <img> tags with data: URIs
+        css('img').each do |img|
+          src = img['src']
+          img.remove if src&.start_with?('data:')
+        end
+
+        doc
+      end
+    end
+  end
+end
+

+ 42 - 0
lib/docs/filters/vertx/entries.rb

@@ -0,0 +1,42 @@
+module Docs
+  class Vertx
+    class EntriesFilter < Docs::EntriesFilter
+      # Determines the default name of the page entry
+      def get_name
+        node = at_css('h1')
+        return nil unless node
+
+        result = node.content.strip
+        result << ' event' if type == 'Events'
+        result << '()' if node['class'].to_s.include?('function')
+        result
+      end
+
+      # Determines the type of the default entry (used for sidebar grouping)
+      def get_type
+        return nil if root_page?
+
+        node = at_xpath('/html/body/div/div/div[2]/main/div[1]/div[1]')
+        node ? node.text.strip : 'Miscellaneous'
+      end
+
+      # Returns additional entries from subheadings (usually <h2>)
+      def additional_entries
+        # return [] if root_page?
+        #
+        # css('h2').map do |node|
+        #   name = node.content.strip
+        #   id = node['id']
+        #   [name, id, type]
+        # end
+        []
+      end
+
+      # Determines whether to include the default entry for the page
+      def include_default_entry?
+        !at_css('.obsolete')
+      end
+    end
+  end
+end
+

+ 46 - 0
lib/docs/scrapers/vertx.rb

@@ -0,0 +1,46 @@
+module Docs
+  class Vertx < UrlScraper
+    self.name = 'Vert.x'
+    self.slug = 'vertx'
+    self.type = 'vertx'
+    self.links = {
+      home: 'http://vertx.io',
+      code: 'https://github.com/eclipse-vertx/vert.x'
+    }
+
+    html_filters.push 'vertx/entries', 'vertx/clean_html'
+
+    options[:attribution] = <<-HTML
+      © 2025 Eclipse Vert.x™</br>
+      Eclipse Vert.x™ is open source and dual-licensed under the Eclipse Public License 2.0 and the Apache License 2.0.</br>
+      Website design by Michel Krämer.
+    HTML
+
+    options[:skip_patterns] = [
+      /api/,
+      /5.0.0/,
+      /apidocs/,
+      /blog/,
+    ]
+
+    version '5' do
+      self.release = '5.0.0'
+      self.base_url = "https://vertx.io/docs/"
+    end
+
+    version '4' do
+      self.release = '4.5.15'
+      self.base_url = "https://vertx.io/docs/#{self.release}"
+    end
+
+    version '3' do
+      self.release = '3.9.16'
+      self.base_url = "https://vertx.io/docs/#{self.release}"
+    end
+
+    def get_latest_version(opts)
+      doc = fetch_doc('https://repo1.maven.org/maven2/io/vertx/vertx-stack-manager/maven-metadata.xml', opts)
+      doc.css('version')[-1].text
+    end
+  end
+end

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


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


+ 1 - 0
public/icons/docs/vertx/SOURCE

@@ -0,0 +1 @@
+https://avatars.githubusercontent.com/u/8124623?s=200&v=4