See https://github.com/freeCodeCamp/devdocs/issues/696#issuecomment-1243554434
Unified · Split
| @@ -61,11 +61,13 @@ module Docs · 60 unmodified lines | ||
| 61 | 61 | end |
| 62 | 62 | |
| 63 | 63 | def include_default_entry? |
| 64 | + return false if slug.starts_with?('genindex') | |
| 64 | 65 | return true if slug == 'library/asyncio' |
| 65 | 66 | !at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Superseded)) |
| 66 | 67 | end |
| 67 | 68 | |
| 68 | 69 | def additional_entries |
| 70 | + return additional_entries_index if slug.starts_with?('genindex') | |
| 69 | 71 | return [] if root_page? || slug.start_with?('library/index') || !include_default_entry? || name == 'errno' |
| 70 | 72 | clean_id_attributes |
| 71 | 73 | entries = [] |
| @@ -99,6 +101,28 @@ module Docs · 27 unmodified lines | ||
| 99 | 101 | node.remove |
| 100 | 102 | end |
| 101 | 103 | end |
| 104 | + | |
| 105 | + def additional_entries_index | |
| 106 | + css('.genindextable td > ul > li').each_with_object [] do |node, entries| | |
| 107 | + name = node.children.first | |
| 108 | + next unless name.text? | |
| 109 | + name = name.text.strip() | |
| 110 | + next if name[/^\w/] || name[/^-+\w/] | |
| 111 | + node.css('> ul > li > a').each do |inner_node| | |
| 112 | + inner_name = inner_node.text.strip() | |
| 113 | + next if inner_name[/\[\d+\]/] | |
| 114 | + type = case inner_name | |
| 115 | + when 'operator' | |
| 116 | + 'Operators' | |
| 117 | + when 'in regular expressions' | |
| 118 | + 'Regular Expression' | |
| 119 | + else | |
| 120 | + 'Symbols' | |
| 121 | + end | |
| 122 | + entries << ["#{name} (#{inner_name})", inner_node['href'], type] | |
| 123 | + end | |
| 124 | + end | |
| 125 | + end | |
| 102 | 126 | end |
| 103 | 127 | end |
| 104 | 128 | end |
| @@ -7,7 +7,7 @@ module Docs · 6 unmodified lines | ||
| 7 | 7 | code: 'https://github.com/python/cpython' |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | − options[:skip_patterns] = [/genindex/, /whatsnew/] | |
| 10 | + options[:skip_patterns] = [/whatsnew/] | |
| 11 | 11 | options[:skip] = %w( |
| 12 | 12 | library/2to3.html |
| 13 | 13 | library/formatter.html |