diff --git a/lib/docs/filters/hol/clean_html.rb b/lib/docs/filters/hol/clean_html.rb new file mode 100644 index 0000000000..ddc33c92ce --- /dev/null +++ b/lib/docs/filters/hol/clean_html.rb @@ -0,0 +1,42 @@ +module Docs + class Hol + class CleanHtmlFilter < Filter + def call + @doc = at_css('article .theme-doc-markdown') || at_css('article') + return doc if @doc.nil? + + css( + '.theme-doc-breadcrumbs', + '.theme-doc-toc-mobile', + '.theme-doc-footer', + '.theme-doc-version-badge', + '.pagination-nav', + '.theme-edit-this-page', + '.hash-link', + '.anchor-link', + 'button.copyButtonIcon_Lhsm', + 'button.clean-btn', + ).remove + + css('pre').each do |node| + lines = node.css('.token-line') + node.content = lines.map(&:content).join("\n") if lines.any? + node.remove_attribute('style') + + language = node['class'].to_s[/language-([a-z0-9_-]+)/i, 1] + language ||= node.at_css('code')&.[]('class').to_s[/language-([a-z0-9_-]+)/i, 1] + node['data-language'] = language if language + + wrapper = node.ancestors('.theme-code-block').first + wrapper.replace(node) if wrapper + end + + css('.table-of-contents').remove + css('*[class]').remove_attribute('class') + css('*[style]').remove_attribute('style') + + doc + end + end + end +end diff --git a/lib/docs/filters/hol/entries.rb b/lib/docs/filters/hol/entries.rb new file mode 100644 index 0000000000..8a713403b8 --- /dev/null +++ b/lib/docs/filters/hol/entries.rb @@ -0,0 +1,77 @@ +module Docs + class Hol + class EntriesFilter < Docs::EntriesFilter + def include_default_entry? + !root_page? + end + + def get_name + heading = at_css('h1') + return super if heading.nil? + normalized_heading_text(heading) + end + + def get_type + return standards_sdk_type if standards_sdk_doc? + return registry_broker_type if registry_broker_doc? + nil + end + + def additional_entries + return [] if root_page? + + css('h2[id], h3[id]').each_with_object([]) do |node, entries| + section_name = normalized_heading_text(node) + next if section_name.empty? + next if section_name == name + entries << ["#{name}: #{section_name}", node['id']] + end + end + + private + + def normalized_heading_text(node) + fragment = node.dup + fragment.css('a').remove + fragment.content.gsub(/\s+/, ' ').strip + end + + def standards_sdk_doc? + slug.start_with?('libraries/standards-sdk/') + end + + def registry_broker_doc? + slug.start_with?('registry-broker/') + end + + def standards_sdk_type + sdk_slug = slug.delete_prefix('libraries/standards-sdk/').split('/').first + return 'Standards SDK' if sdk_slug.nil? || sdk_slug.empty? + return sdk_slug.upcase if sdk_slug.match?(/\Ahcs-\d+\z/) + + case sdk_slug + when 'registry-broker-client' + 'SDK Registry Broker Client' + when 'utils-services' + 'SDK Utilities & Services' + else + "SDK #{sdk_slug.tr('-', ' ').split.map(&:capitalize).join(' ')}" + end + end + + def registry_broker_type + broker_slug = slug.delete_prefix('registry-broker/').split('/').first + return 'Registry Broker' if broker_slug.nil? || broker_slug.empty? + + case broker_slug + when 'api' + 'Registry Broker API' + when 'chat', 'encrypted-chat', 'multi-protocol-chat' + 'Registry Broker Chat' + else + "Registry Broker #{broker_slug.tr('-', ' ').split.map(&:capitalize).join(' ')}" + end + end + end + end +end diff --git a/lib/docs/scrapers/hol.rb b/lib/docs/scrapers/hol.rb new file mode 100644 index 0000000000..d0d75cdc2f --- /dev/null +++ b/lib/docs/scrapers/hol.rb @@ -0,0 +1,39 @@ +module Docs + class Hol < UrlScraper + self.name = 'Hashgraph Online' + self.slug = 'hol' + self.type = 'simple' + self.release = '0.1.161' + self.base_url = 'https://hol.org/docs/' + self.root_path = 'libraries/standards-sdk/' + self.initial_paths = %w( + libraries/standards-sdk/ + registry-broker/ + ) + self.links = { + home: 'https://hol.org/', + code: 'https://github.com/hashgraph-online/standards-sdk' + } + + html_filters.push 'hol/entries', 'hol/clean_html' + + options[:trailing_slash] = true + options[:only_patterns] = [ + %r{\A(?:libraries/standards-sdk|registry-broker)(?:/|$)}, + ] + options[:skip_patterns] = [ + %r{\Aregistry-broker/examples/(?:chat-demo|ping-agent-demo)/?}, + %r{\Aregistry-broker/getting-started/(?:faq|first-registration|installation|quick-start)/?}, + %r{\Aregistry-broker/(?:feature-your-agent|moltbook|partner-program|skills-upload-discovery|updating-agents)/?}, + ] + + options[:attribution] = <<-HTML + Copyright © 2025 Hashgraph Online DAO.
+ Licensed under the Apache License 2.0. + HTML + + def get_latest_version(opts) + get_npm_version('@hashgraphonline/standards-sdk', opts) + end + end +end diff --git a/public/icons/docs/hol/16.png b/public/icons/docs/hol/16.png new file mode 100644 index 0000000000..7f02caa6f5 Binary files /dev/null and b/public/icons/docs/hol/16.png differ diff --git a/public/icons/docs/hol/16@2x.png b/public/icons/docs/hol/16@2x.png new file mode 100644 index 0000000000..3ce67785b7 Binary files /dev/null and b/public/icons/docs/hol/16@2x.png differ diff --git a/public/icons/docs/hol/SOURCE b/public/icons/docs/hol/SOURCE new file mode 100644 index 0000000000..e70d09455a --- /dev/null +++ b/public/icons/docs/hol/SOURCE @@ -0,0 +1 @@ +https://hol.org/logo.png