From d6274d6b26d0690b8b09b9bee7bcbe1ae8745789 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Sat, 18 May 2024 01:29:25 +0200 Subject: [PATCH] Include license etc. as misc pages, based on main page --- lib/docs/filters/click/entries.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/docs/filters/click/entries.rb b/lib/docs/filters/click/entries.rb index 09b3a761..9512eb8a 100644 --- a/lib/docs/filters/click/entries.rb +++ b/lib/docs/filters/click/entries.rb @@ -1,8 +1,19 @@ module Docs class Click class EntriesFilter < Docs::EntriesFilter - - def initialize(*) + TYPE_BY_SLUG = {} + + def call + if root_page? + css('section').each do |node| + next if ['documentation', 'api-reference'].include?(node['id']) + type = node.at_css('h2').content.strip + node.css('li > a').each do |toclink| + slug = toclink['href'].split('/')[-2] + TYPE_BY_SLUG[slug] = type + end + end + end super end @@ -11,15 +22,15 @@ module Docs end def get_type - return at_css('h1').content.strip + TYPE_BY_SLUG[slug.split('/').first] || at_css('h1').content.strip end def include_default_entry? - false + TYPE_BY_SLUG.include?(slug.split('/').first) end def additional_entries - return [] if root_page? + return [] if root_page? || TYPE_BY_SLUG.include?(slug.split('/').first) if slug == 'api/' entries = []