File tree Expand file tree Collapse file tree 6 files changed +123
-0
lines changed
public/icons/docs/couchdb Expand file tree Collapse file tree 6 files changed +123
-0
lines changed Original file line number Diff line number Diff line change 1+ module Docs
2+ class Couchdb
3+ class CleanHtmlFilter < Filter
4+ def call
5+ css ( 'h1' ) . each do |node |
6+ node . content = node . content . gsub ( /\d *\. |\P {ASCII}/ , '' ) . split ( '.' ) . last
7+ end
8+
9+ css ( 'h2' , 'h3' ) . each do |node |
10+ node . content = node . content . gsub ( /\P {ASCII}/ , '' ) . split ( '.' ) . last
11+ end
12+
13+ css ( 'pre' ) . each do |node |
14+ node . content = node . content . strip
15+
16+ classes = node . parent . parent . classes
17+ if classes . include? 'highlight-bash'
18+ node [ 'data-language' ] = 'bash'
19+ else
20+ node [ 'data-language' ] = 'javascript'
21+ end
22+
23+ node . parent . parent . replace ( node )
24+ end
25+
26+ doc
27+ end
28+ end
29+ end
30+ end
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ https://docs.couchdb.org/en/stable/_static/favicon.ico
You can’t perform that action at this time.
0 commit comments