File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11module Docs
22 class Click
33 class EntriesFilter < Docs ::EntriesFilter
4-
5- def initialize ( *)
4+ TYPE_BY_SLUG = { }
5+
6+ def call
7+ if root_page?
8+ css ( 'section' ) . each do |node |
9+ next if [ 'documentation' , 'api-reference' ] . include? ( node [ 'id' ] )
10+ type = node . at_css ( 'h2' ) . content . strip
11+ node . css ( 'li > a' ) . each do |toclink |
12+ slug = toclink [ 'href' ] . split ( '/' ) [ -2 ]
13+ TYPE_BY_SLUG [ slug ] = type
14+ end
15+ end
16+ end
617 super
718 end
819
@@ -11,15 +22,15 @@ def get_name
1122 end
1223
1324 def get_type
14- return at_css ( 'h1' ) . content . strip
25+ TYPE_BY_SLUG [ slug . split ( '/' ) . first ] || at_css ( 'h1' ) . content . strip
1526 end
1627
1728 def include_default_entry?
18- false
29+ TYPE_BY_SLUG . include? ( slug . split ( '/' ) . first )
1930 end
2031
2132 def additional_entries
22- return [ ] if root_page?
33+ return [ ] if root_page? || TYPE_BY_SLUG . include? ( slug . split ( '/' ) . first )
2334
2435 if slug == 'api/'
2536 entries = [ ]
You can’t perform that action at this time.
0 commit comments