History

Merge pull request #2648 from spamguy/couchdb

Implementation of CouchDB docs.

Simon Legner committed 9 months ago

Commit 8919a9f2 parents 69db669 72f87427 files · +124 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/news.json +4 −0
  2. lib/docs/filters/couchdb/clean_html.rb +29 −0
  3. lib/docs/filters/couchdb/entries.rb +53 −0
  4. lib/docs/scrapers/couchdb.rb +39 −0
  5. public/icons/docs/couchdb/16.png +0 −0
  6. public/icons/docs/couchdb/16@2x.png +0 −0
  7. public/icons/docs/couchdb/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2026-02-14",
4+ "New documentation: <a href=\"/couchdb/\">CouchDB</a>"
5+ ],
26 [
37 "2025-10-19",
48 "New documentations: <a href=\"/lit/\">Lit</a>, <a href=\"/graphviz/\">Graphviz</a>, <a href=\"/bun/\">Bun</a>"
lib/docs/filters/couchdb/clean_html.rb+29−0
@@ -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
lib/docs/filters/couchdb/entries.rb+53−0
@@ -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
lib/docs/scrapers/couchdb.rb+39−0
@@ -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 &copy; 2025 The Apache Software Foundation &mdash; 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
public/icons/docs/couchdb/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/couchdb/SOURCE+1−0
@@ -0,0 +1 @@
1+https://docs.couchdb.org/en/stable/_static/favicon.ico

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t