Unified · Split
| @@ -1,8 +1,19 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Click | 2 | class Click |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | TYPE_BY_SLUG = {} | |
| 5 | def initialize(*) | 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 | ||
| 6 | super | 17 | super |
| 7 | end | 18 | end |
| 8 | 19 | ||
| @@ -11,15 +22,15 @@ module Docs · 2 unmodified lines | |||
| 11 | end | 22 | end |
| 12 | 23 | ||
| 13 | def get_type | 24 | def get_type |
| 14 | return at_css('h1').content.strip | 25 | TYPE_BY_SLUG[slug.split('/').first] || at_css('h1').content.strip |
| 15 | end | 26 | end |
| 16 | 27 | ||
| 17 | def include_default_entry? | 28 | def include_default_entry? |
| 18 | false | 29 | TYPE_BY_SLUG.include?(slug.split('/').first) |
| 19 | end | 30 | end |
| 20 | 31 | ||
| 21 | def additional_entries | 32 | def additional_entries |
| 22 | return [] if root_page? | 33 | return [] if root_page? || TYPE_BY_SLUG.include?(slug.split('/').first) |
| 23 | 34 | ||
| 24 | if slug == 'api/' | 35 | if slug == 'api/' |
| 25 | entries = [] | 36 | entries = [] |