Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/docs/filters/couchdb/clean_html.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Docs
class Couchdb
class CleanHtmlFilter < Filter
def call
css('h1').each do |node|
node.content = node.content.gsub(/\d*\. |\P{ASCII}/, '').split('.').last
end

css('h2', 'h3').each do |node|
node.content = node.content.gsub(/\P{ASCII}/, '').split('.').last
end

css('pre').each do |node|
node.content = node.content.strip

classes = node.parent.parent.classes
if classes.include? 'highlight-bash'
node['data-language'] = 'bash'
else
node['data-language'] = 'javascript'
end

node.parent.parent.replace(node)
end

doc
end
end
end
end
53 changes: 53 additions & 0 deletions lib/docs/filters/couchdb/entries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module Docs
class Couchdb
class EntriesFilter < Docs::EntriesFilter
SLUG_MAP = {
'api' => 'API',
'json' => 'JSON Structures',
'cluster' => 'Cluster Management',
'replication' => 'Replication',
'maintenance' => 'Maintenance',
'partitioned' => 'Partitioned Databases'
}

def get_name
at_css('h1').content.gsub(/\P{ASCII}/, '').split('.').last
end

def get_type
if slug.start_with?('ddocs/views')
'Views'
elsif slug.start_with?('ddocs')
'Design Documents'
else
SLUG_MAP[slug[/^(.+?)[-\/]/, 1]] || name
end
end

def additional_entries
needs_breakup = [
'JSON Structure Reference',
'Design Documents',
'Partitioned Databases'
]

if needs_breakup.include?(name)
entries = []

css('section > section').each do |node|
h2 = node.at_css('h2')

if h2.present?
name = node.at_css('h2').content.split('.').last
entries << [name, node['id']]
end
end

entries
else
[]
end
end
end
end
end
39 changes: 39 additions & 0 deletions lib/docs/scrapers/couchdb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Docs
class Couchdb < UrlScraper
self.name = 'CouchDB'
self.type = 'couchdb'
self.root_path = 'index.html'

self.links = {
home: 'https://couchdb.apache.org/',
code: 'https://github.com/apache/couchdb'
}

html_filters.push 'couchdb/clean_html', 'couchdb/entries'

options[:container] = 'div[itemprop=articleBody]'
options[:only_patterns] = [
/api\//,
/cluster\//,
/ddocs\//,
/replication\//,
/maintenance\//,
/partitioned-dbs\//,
/json\-structure*/
]
options[:rate_limit] = 50 # Docs are subject to Cloudflare limiters.
options[:attribution] = <<-HTML
Copyright &copy; 2025 The Apache Software Foundation &mdash; Licensed under the Apache License 2.0
HTML

version '3.5' do
self.release = '3.5.1'
self.base_url = "https://docs.couchdb.org/en/#{self.release}"
end

def get_latest_version(opts)
doc = fetch_doc('https://couchdb.apache.org/', opts)
doc.at_css('.download-pane > h2').content.split(' ').last
end
end
end
Binary file added public/icons/docs/couchdb/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/couchdb/16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/couchdb/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://docs.couchdb.org/en/stable/_static/favicon.ico