python: add operators, regex, symbols form index

See https://github.com/freeCodeCamp/devdocs/issues/696#issuecomment-1243554434
pull/1823/head
Simon Legner 2 years ago
parent 61362e6e6e
commit 1213629e9c

@ -61,11 +61,13 @@ module Docs
end
def include_default_entry?
return false if slug.starts_with?('genindex')
return true if slug == 'library/asyncio'
!at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Superseded))
end
def additional_entries
return additional_entries_index if slug.starts_with?('genindex')
return [] if root_page? || slug.start_with?('library/index') || !include_default_entry? || name == 'errno'
clean_id_attributes
entries = []
@ -99,6 +101,28 @@ module Docs
node.remove
end
end
def additional_entries_index
css('.genindextable td > ul > li').each_with_object [] do |node, entries|
name = node.children.first
next unless name.text?
name = name.text.strip()
next if name[/^\w/] || name[/^-+\w/]
node.css('> ul > li > a').each do |inner_node|
inner_name = inner_node.text.strip()
next if inner_name[/\[\d+\]/]
type = case inner_name
when 'operator'
'Operators'
when 'in regular expressions'
'Regular Expression'
else
'Symbols'
end
entries << ["#{name} (#{inner_name})", inner_node['href'], type]
end
end
end
end
end
end

@ -7,7 +7,7 @@ module Docs
code: 'https://github.com/python/cpython'
}
options[:skip_patterns] = [/genindex/, /whatsnew/]
options[:skip_patterns] = [/whatsnew/]
options[:skip] = %w(
library/2to3.html
library/formatter.html

Loading…
Cancel
Save