History

Merge pull request #2500 from dorimon-1/vertx

Add vertx docs

Simon Legner committed 1 year ago

Commit bc779162 parents c6b1fd0 e6d89417 files · +131 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/news.json +4 −0
  2. lib/docs/filters/vertx/clean_html.rb +40 −0
  3. lib/docs/filters/vertx/entries.rb +42 −0
  4. lib/docs/scrapers/vertx.rb +46 −0
  5. public/icons/docs/vertx/16.png +0 −0
  6. public/icons/docs/vertx/16@2x.png +0 −0
  7. public/icons/docs/vertx/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
1[1[
2 [
3 "2025-05-28",
4 "New documentation: <a href=\"/vertx/\">Vert.x</a>"
5 ],
2 [6 [
3 "2025-02-23",7 "2025-02-23",
4 "New documentation: <a href=\"/threejs/\">Three.js</a>"8 "New documentation: <a href=\"/threejs/\">Three.js</a>"
lib/docs/filters/vertx/clean_html.rb+40−0
@@ -0,0 +1,40 @@
1module Docs
2 class Vertx
3 class CleanHtmlFilter < Filter
4 def call
5 css('footer', 'hr', 'header', 'nav', '.navbar', '.topbar', '.bg-bg-warning').remove
6 xpath('//*[@id="docs-layout"]/div/div[3]').remove
7 xpath('//*[@id="docs-layout"]/div/div[1]').remove
8 xpath('//main/div[last()]').remove
9 xpath('//main/div[1]').remove
10 css('#changelog').remove if root_page?
11
12 # Set id attributes on <h3> instead of an empty <a>
13 css('h3').each do |node|
14 anchor = node.at_css('a')
15 node['id'] = anchor['id'] if anchor && anchor['id']
16 end
17
18 # Make proper table headers
19 css('td.header').each do |node|
20 node.name = 'th'
21 end
22
23 # Remove code highlighting
24 css('pre').each do |node|
25 node['data-language'] = node.at_css('code')['data-lang'] if node.at_css('code')
26 node.content = node.content
27 end
28
29 # ❗ Skip <img> tags with data: URIs
30 css('img').each do |img|
31 src = img['src']
32 img.remove if src&.start_with?('data:')
33 end
34
35 doc
36 end
37 end
38 end
39end
40
lib/docs/filters/vertx/entries.rb+42−0
@@ -0,0 +1,42 @@
1module Docs
2 class Vertx
3 class EntriesFilter < Docs::EntriesFilter
4 # Determines the default name of the page entry
5 def get_name
6 node = at_css('h1')
7 return nil unless node
8
9 result = node.content.strip
10 result << ' event' if type == 'Events'
11 result << '()' if node['class'].to_s.include?('function')
12 result
13 end
14
15 # Determines the type of the default entry (used for sidebar grouping)
16 def get_type
17 return nil if root_page?
18
19 node = at_xpath('/html/body/div/div/div[2]/main/div[1]/div[1]')
20 node ? node.text.strip : 'Miscellaneous'
21 end
22
23 # Returns additional entries from subheadings (usually <h2>)
24 def additional_entries
25 # return [] if root_page?
26 #
27 # css('h2').map do |node|
28 # name = node.content.strip
29 # id = node['id']
30 # [name, id, type]
31 # end
32 []
33 end
34
35 # Determines whether to include the default entry for the page
36 def include_default_entry?
37 !at_css('.obsolete')
38 end
39 end
40 end
41end
42
lib/docs/scrapers/vertx.rb+46−0
@@ -0,0 +1,46 @@
1module Docs
2 class Vertx < UrlScraper
3 self.name = 'Vert.x'
4 self.slug = 'vertx'
5 self.type = 'vertx'
6 self.links = {
7 home: 'http://vertx.io',
8 code: 'https://github.com/eclipse-vertx/vert.x'
9 }
10
11 html_filters.push 'vertx/entries', 'vertx/clean_html'
12
13 options[:attribution] = <<-HTML
14 © 2025 Eclipse Vert.x™</br>
15 Eclipse Vert.x™ is open source and dual-licensed under the Eclipse Public License 2.0 and the Apache License 2.0.</br>
16 Website design by Michel Krämer.
17 HTML
18
19 options[:skip_patterns] = [
20 /api/,
21 /5.0.0/,
22 /apidocs/,
23 /blog/,
24 ]
25
26 version '5' do
27 self.release = '5.0.0'
28 self.base_url = "https://vertx.io/docs/"
29 end
30
31 version '4' do
32 self.release = '4.5.15'
33 self.base_url = "https://vertx.io/docs/#{self.release}"
34 end
35
36 version '3' do
37 self.release = '3.9.16'
38 self.base_url = "https://vertx.io/docs/#{self.release}"
39 end
40
41 def get_latest_version(opts)
42 doc = fetch_doc('https://repo1.maven.org/maven2/io/vertx/vertx-stack-manager/maven-metadata.xml', opts)
43 doc.css('version')[-1].text
44 end
45 end
46end
public/icons/docs/vertx/16.png+0−0

Binary file not shown.

public/icons/docs/vertx/16@2x.png+0−0

Binary file not shown.

public/icons/docs/vertx/SOURCE+1−0
@@ -0,0 +1 @@
1https://avatars.githubusercontent.com/u/8124623?s=200&v=4