Implementation of CouchDB docs.
Unified · Split
| @@ -1,4 +1,8 @@ | |||
| 1 | [ | 1 | [ |
| 2 | [ | ||
| 3 | "2026-02-14", | ||
| 4 | "New documentation: <a href=\"/couchdb/\">CouchDB</a>" | ||
| 5 | ], | ||
| 2 | [ | 6 | [ |
| 3 | "2025-10-19", | 7 | "2025-10-19", |
| 4 | "New documentations: <a href=\"/lit/\">Lit</a>, <a href=\"/graphviz/\">Graphviz</a>, <a href=\"/bun/\">Bun</a>" | 8 | "New documentations: <a href=\"/lit/\">Lit</a>, <a href=\"/graphviz/\">Graphviz</a>, <a href=\"/bun/\">Bun</a>" |
| @@ -0,0 +1,29 @@ | |||
| 1 | module Docs | ||
| 2 | class Couchdb | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | css('.section-number').remove | ||
| 6 | css('.headerlink').remove | ||
| 7 | |||
| 8 | css('.sig-name').each do |node| | ||
| 9 | node.name = 'code' | ||
| 10 | end | ||
| 11 | |||
| 12 | css('pre').each do |node| | ||
| 13 | node.content = node.content.strip | ||
| 14 | |||
| 15 | classes = node.parent.parent.classes | ||
| 16 | if classes.include? 'highlight-bash' | ||
| 17 | node['data-language'] = 'bash' | ||
| 18 | else | ||
| 19 | node['data-language'] = 'javascript' | ||
| 20 | end | ||
| 21 | |||
| 22 | node.parent.parent.replace(node) | ||
| 23 | end | ||
| 24 | |||
| 25 | doc | ||
| 26 | end | ||
| 27 | end | ||
| 28 | end | ||
| 29 | end | ||
| @@ -0,0 +1,53 @@ | |||
| 1 | module Docs | ||
| 2 | class Couchdb | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | SLUG_MAP = { | ||
| 5 | 'api' => 'API', | ||
| 6 | 'json' => 'JSON Structures', | ||
| 7 | 'cluster' => 'Cluster Management', | ||
| 8 | 'replication' => 'Replication', | ||
| 9 | 'maintenance' => 'Maintenance', | ||
| 10 | 'partitioned' => 'Partitioned Databases' | ||
| 11 | } | ||
| 12 | |||
| 13 | def get_name | ||
| 14 | at_css('h1').content.gsub(/\P{ASCII}/, '').split('.').last | ||
| 15 | end | ||
| 16 | |||
| 17 | def get_type | ||
| 18 | if slug.start_with?('ddocs/views') | ||
| 19 | 'Views' | ||
| 20 | elsif slug.start_with?('ddocs') | ||
| 21 | 'Design Documents' | ||
| 22 | else | ||
| 23 | SLUG_MAP[slug[/^(.+?)[-\/]/, 1]] || name | ||
| 24 | end | ||
| 25 | end | ||
| 26 | |||
| 27 | def additional_entries | ||
| 28 | needs_breakup = [ | ||
| 29 | 'JSON Structure Reference', | ||
| 30 | 'Design Documents', | ||
| 31 | 'Partitioned Databases' | ||
| 32 | ] | ||
| 33 | |||
| 34 | if needs_breakup.include?(name) | ||
| 35 | entries = [] | ||
| 36 | |||
| 37 | css('section > section').each do |node| | ||
| 38 | h2 = node.at_css('h2') | ||
| 39 | |||
| 40 | if h2.present? | ||
| 41 | name = node.at_css('h2').content.split('.').last | ||
| 42 | entries << [name, node['id']] | ||
| 43 | end | ||
| 44 | end | ||
| 45 | |||
| 46 | entries | ||
| 47 | else | ||
| 48 | [] | ||
| 49 | end | ||
| 50 | end | ||
| 51 | end | ||
| 52 | end | ||
| 53 | end | ||
| @@ -0,0 +1,39 @@ | |||
| 1 | module Docs | ||
| 2 | class Couchdb < UrlScraper | ||
| 3 | self.name = 'CouchDB' | ||
| 4 | self.type = 'couchdb' | ||
| 5 | self.root_path = 'index.html' | ||
| 6 | |||
| 7 | self.links = { | ||
| 8 | home: 'https://couchdb.apache.org/', | ||
| 9 | code: 'https://github.com/apache/couchdb' | ||
| 10 | } | ||
| 11 | |||
| 12 | html_filters.push 'couchdb/clean_html', 'couchdb/entries' | ||
| 13 | |||
| 14 | options[:container] = 'div[itemprop=articleBody]' | ||
| 15 | options[:only_patterns] = [ | ||
| 16 | /api\//, | ||
| 17 | /cluster\//, | ||
| 18 | /ddocs\//, | ||
| 19 | /replication\//, | ||
| 20 | /maintenance\//, | ||
| 21 | /partitioned-dbs\//, | ||
| 22 | /json\-structure*/ | ||
| 23 | ] | ||
| 24 | options[:rate_limit] = 50 # Docs are subject to Cloudflare limiters. | ||
| 25 | options[:attribution] = <<-HTML | ||
| 26 | Copyright © 2025 The Apache Software Foundation — Licensed under the Apache License 2.0 | ||
| 27 | HTML | ||
| 28 | |||
| 29 | version '3.5' do | ||
| 30 | self.release = '3.5.1' | ||
| 31 | self.base_url = "https://docs.couchdb.org/en/#{self.release}" | ||
| 32 | end | ||
| 33 | |||
| 34 | def get_latest_version(opts) | ||
| 35 | doc = fetch_doc('https://couchdb.apache.org/', opts) | ||
| 36 | doc.at_css('.download-pane > h2').content.split(' ').last | ||
| 37 | end | ||
| 38 | end | ||
| 39 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://docs.couchdb.org/en/stable/_static/favicon.ico | ||