Skip to content

Commit 1543951

Browse files
committed
feat: add Hashgraph Online docs scraper
Signed-off-by: Michael Kantor <6068672+kantorcodes@users.noreply.github.com>
1 parent fc39272 commit 1543951

File tree

6 files changed

+153
-0
lines changed

6 files changed

+153
-0
lines changed

lib/docs/filters/hol/clean_html.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module Docs
2+
class Hol
3+
class CleanHtmlFilter < Filter
4+
def call
5+
@doc = at_css('article .theme-doc-markdown') || at_css('article')
6+
return doc if @doc.nil?
7+
8+
css(
9+
'.theme-doc-breadcrumbs',
10+
'.theme-doc-toc-mobile',
11+
'.theme-doc-footer',
12+
'.theme-doc-version-badge',
13+
'.pagination-nav',
14+
'.theme-edit-this-page',
15+
'.hash-link',
16+
'.anchor-link',
17+
'button.copyButtonIcon_Lhsm',
18+
'button.clean-btn',
19+
).remove
20+
21+
css('pre').each do |node|
22+
lines = node.css('.token-line')
23+
node.content = lines.map(&:content).join("\n") if lines.any?
24+
node.remove_attribute('style')
25+
26+
language = node['class'].to_s[/language-([a-z0-9_-]+)/i, 1]
27+
language ||= node.at_css('code')&.[]('class').to_s[/language-([a-z0-9_-]+)/i, 1]
28+
node['data-language'] = language if language
29+
30+
wrapper = node.ancestors('.theme-code-block').first
31+
wrapper.replace(node) if wrapper
32+
end
33+
34+
css('.table-of-contents').remove
35+
css('*[class]').remove_attribute('class')
36+
css('*[style]').remove_attribute('style')
37+
38+
doc
39+
end
40+
end
41+
end
42+
end

lib/docs/filters/hol/entries.rb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module Docs
2+
class Hol
3+
class EntriesFilter < Docs::EntriesFilter
4+
def include_default_entry?
5+
!root_page?
6+
end
7+
8+
def get_name
9+
heading = at_css('h1')
10+
return super if heading.nil?
11+
heading.content.gsub(/\s+/, ' ').strip
12+
end
13+
14+
def get_type
15+
return standards_sdk_type if standards_sdk_doc?
16+
return registry_broker_type if registry_broker_doc?
17+
nil
18+
end
19+
20+
def additional_entries
21+
return [] if root_page?
22+
23+
css('h2[id], h3[id]').each_with_object([]) do |node, entries|
24+
section_name = node.content.gsub(/\s+/, ' ').strip
25+
next if section_name.empty?
26+
next if section_name == name
27+
entries << ["#{name}: #{section_name}", node['id']]
28+
end
29+
end
30+
31+
private
32+
33+
def standards_sdk_doc?
34+
slug.start_with?('libraries/standards-sdk/')
35+
end
36+
37+
def registry_broker_doc?
38+
slug.start_with?('registry-broker/')
39+
end
40+
41+
def standards_sdk_type
42+
sdk_slug = slug.delete_prefix('libraries/standards-sdk/').split('/').first
43+
return 'Standards SDK' if sdk_slug.nil? || sdk_slug.empty?
44+
return sdk_slug.upcase if sdk_slug.match?(/\Ahcs-\d+\z/)
45+
46+
case sdk_slug
47+
when 'registry-broker-client'
48+
'SDK Registry Broker Client'
49+
when 'utils-services'
50+
'SDK Utilities & Services'
51+
else
52+
"SDK #{sdk_slug.tr('-', ' ').split.map(&:capitalize).join(' ')}"
53+
end
54+
end
55+
56+
def registry_broker_type
57+
broker_slug = slug.delete_prefix('registry-broker/').split('/').first
58+
return 'Registry Broker' if broker_slug.nil? || broker_slug.empty?
59+
60+
case broker_slug
61+
when 'api'
62+
'Registry Broker API'
63+
when 'chat', 'encrypted-chat', 'multi-protocol-chat'
64+
'Registry Broker Chat'
65+
else
66+
"Registry Broker #{broker_slug.tr('-', ' ').split.map(&:capitalize).join(' ')}"
67+
end
68+
end
69+
end
70+
end
71+
end

lib/docs/scrapers/hol.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
class Hol < UrlScraper
3+
self.name = 'Hashgraph Online'
4+
self.slug = 'hol'
5+
self.type = 'simple'
6+
self.release = '0.1.161'
7+
self.base_url = 'https://hol.org/docs/'
8+
self.root_path = 'libraries/standards-sdk/'
9+
self.initial_paths = %w(
10+
libraries/standards-sdk/
11+
registry-broker/
12+
)
13+
self.links = {
14+
home: 'https://hol.org/',
15+
code: 'https://github.com/hashgraph-online/standards-sdk'
16+
}
17+
18+
html_filters.push 'hol/entries', 'hol/clean_html'
19+
20+
options[:trailing_slash] = true
21+
options[:only_patterns] = [
22+
%r{\A(?:libraries/standards-sdk|registry-broker)(?:/|$)},
23+
]
24+
options[:skip_patterns] = [
25+
%r{\Aregistry-broker/examples/(?:chat-demo|ping-agent-demo)/?},
26+
%r{\Aregistry-broker/getting-started/(?:faq|first-registration|installation|quick-start)/?},
27+
%r{\Aregistry-broker/(?:feature-your-agent|moltbook|partner-program|skills-upload-discovery|updating-agents)/?},
28+
]
29+
30+
options[:attribution] = <<-HTML
31+
Copyright &copy; 2025 Hashgraph Online DAO.<br>
32+
Licensed under the Apache License 2.0.
33+
HTML
34+
35+
def get_latest_version(opts)
36+
get_npm_version('@hashgraphonline/standards-sdk', opts)
37+
end
38+
end
39+
end

public/icons/docs/hol/16.png

2.21 KB
Loading

public/icons/docs/hol/16@2x.png

3.5 KB
Loading

public/icons/docs/hol/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://hol.org/logo.png

0 commit comments

Comments
 (0)