History

Update DuckDB documentation (1.1.3)

Simon Legner committed 1 year ago

Commit deedda31 parent 58002165 files · +34 −46Browse files

Unified · Split

5 files
  1. assets/javascripts/news.json +4 −0
  2. lib/docs/filters/duckdb/attribution.rb +12 −0
  3. lib/docs/filters/duckdb/clean_html.rb +10 −11
  4. lib/docs/filters/duckdb/entries.rb +1 −1
  5. lib/docs/scrapers/duckdb.rb +7 −34
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
1[1[
2 [
3 "2024-11-23",
4 "New documentation: <a href=\"/duckdb/\">DuckDB</a>"
5 ],
2 [6 [
3 "2024-08-20",7 "2024-08-20",
4 "New documentation: <a href=\"/man/\">Linux man pages</a>"8 "New documentation: <a href=\"/man/\">Linux man pages</a>"
lib/docs/filters/duckdb/attribution.rb+12−0
@@ -0,0 +1,12 @@
1# frozen_string_literal: true
2
3module Docs
4 class Duckdb
5 class AttributionFilter < Docs::AttributionFilter
6 def attribution_link
7 url = current_url.to_s.sub! 'http://localhost:8000', 'https://duckdb.org'
8 %(<a href="#{url}" class="_attribution-link">#{url}</a>)
9 end
10 end
11 end
12end
lib/docs/filters/duckdb/clean_html.rb+10−11
@@ -3,27 +3,26 @@ module Docs · 2 unmodified lines
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 # First extract the main content5 # First extract the main content
6 @doc = at_css('main')6 @doc = at_css('#main_content_wrap', 'main')
7 return doc if @doc.nil?7 return doc if @doc.nil?
8 8
9 doc.prepend_child at_css('.title').remove
10 at_css('.title').name = 'h1'
11
9 # Remove navigation and header elements12 # Remove navigation and header elements
10 css('.headerline', '.landingmenu', '.search_icon', '#sidebar', '.pagemeta', '.toc_menu', '.section-nav').remove13 css('.headerline', '.headlinebar', '.landingmenu', '.search_icon', '#sidebar', '.pagemeta', '.toc_menu', '.section-nav').remove
11 14
12 # Clean up code blocks15 # Clean up code blocks
13 css('pre').each do |node|16 css('div.highlighter-rouge').each do |node|
14 # Detect language from class or parent div17 node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
15 if node['class']&.include?('sql') || node.at_css('code.sql')
16 node['data-language'] = 'sql'
17 elsif node['class']&.include?('language-sql')
18 node['data-language'] = 'sql'
19 end
20 node.content = node.content.strip18 node.content = node.content.strip
19 node.name = 'pre'
21 end20 end
22 21
23 # Remove unnecessary attributes but keep essential ones22 # Remove unnecessary attributes
24 css('div, span, p').each do |node|23 css('div, span, p').each do |node|
25 node.remove_attribute('style')24 node.remove_attribute('style')
26 node.remove_attribute('class') unless node['class'] =~ /highlight/25 node.remove_attribute('class')
27 end26 end
28 27
29 # Remove empty elements28 # Remove empty elements
lib/docs/filters/duckdb/entries.rb+1−1
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
2 class Duckdb2 class Duckdb
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 at_css('h1')&.content || 'DuckDB'5 at_css('h1', '.title').content
6 end6 end
7 7
8 def get_type8 def get_type
lib/docs/scrapers/duckdb.rb+7−34
@@ -8,7 +8,13 @@ module Docs · 7 unmodified lines
8 code: 'https://github.com/duckdb/duckdb'8 code: 'https://github.com/duckdb/duckdb'
9 }9 }
10 10
11 # https://duckdb.org/docs/guides/offline-copy.html
12 # curl -O https://duckdb.org/duckdb-docs.zip; bsdtar xf duckdb-docs.zip; cd duckdb-docs; python -m http.server
13 self.release = '1.1.3'
14 self.base_url = 'http://localhost:8000/docs/'
15
11 html_filters.push 'duckdb/entries', 'duckdb/clean_html'16 html_filters.push 'duckdb/entries', 'duckdb/clean_html'
17 text_filters.replace 'attribution', 'duckdb/attribution'
12 18
13 options[:container] = '.documentation'19 options[:container] = '.documentation'
14 20
@@ -29,41 +35,8 @@ module Docs · 14 unmodified lines
29 Licensed under the MIT License.35 Licensed under the MIT License.
30 HTML36 HTML
31 37
32 version '1.1' do
33 self.release = '1.1.x'
34 self.base_url = 'http://localhost:8000/docs/'
35 end
36
37 # version '1.0' do
38 # self.release = '1.0.x'
39 # self.base_url = "https://duckdb.org/docs/archive/#{self.version}/"
40
41 # html_filters.push 'duckdb/clean_html'
42 # end
43
44 # version '0.9' do
45 # self.release = '0.9.x'
46 # self.base_url = "https://duckdb.org/docs/archive/#{self.version}/"
47
48 # html_filters.push 'duckdb/clean_html'
49 # end
50
51 # version '0.8' do
52 # self.release = '0.8.x'
53 # self.base_url = "https://duckdb.org/docs/archive/#{self.version}/"
54
55 # html_filters.push 'duckdb/clean_html'
56 # end
57
58 # version '0.7' do
59 # self.release = '0.7.x'
60 # self.base_url = "https://duckdb.org/docs/archive/#{self.version}/"
61
62 # html_filters.push 'duckdb/clean_html'
63 # end
64
65 def get_latest_version(opts)38 def get_latest_version(opts)
66 get_github_tags('duckdb', 'duckdb', opts)39 get_github_tags('duckdb', 'duckdb', opts)[0]['name']
67 end40 end
68 end41 end
69end42end