Update Python documentation (3.10.7)

Include h2 entries for reference, tutorial, using as suggested in https://github.com/freeCodeCamp/devdocs/issues/696#issuecomment-1238951073
pull/1812/head
Simon Legner 2 years ago
parent dbe0b56365
commit 87549933c7

@ -17,7 +17,7 @@ module Docs
def get_name def get_name
name = at_css('h1').content name = at_css('h1').content
name.remove! %r{\A[\d\.]+ } # remove list number name.remove! %r{\A[\d\.]+ } unless include_h2? # remove list number
name.remove! "\u{00B6}" # remove pilcrow sign name.remove! "\u{00B6}" # remove pilcrow sign
name.remove! %r{ [\u{2013}\u{2014}].+\z} # remove text after em/en dash name.remove! %r{ [\u{2013}\u{2014}].+\z} # remove text after em/en dash
name.remove! 'Built-in' name.remove! 'Built-in'
@ -29,8 +29,8 @@ module Docs
return 'Language Reference' if slug.start_with? 'reference' return 'Language Reference' if slug.start_with? 'reference'
return 'Python/C API' if slug.start_with? 'c-api' return 'Python/C API' if slug.start_with? 'c-api'
return 'Tutorial' if slug.start_with? 'tutorial' return 'Tutorial' if slug.start_with? 'tutorial'
return 'Distributing' if slug.start_with? 'distributing' return 'Software Packaging & Distribution' if slug.start_with? 'distributing'
return 'Distributing' if slug.start_with? 'distutils' return 'Software Packaging & Distribution' if slug.start_with? 'distutils'
return 'Basics' unless slug.start_with? 'library/' return 'Basics' unless slug.start_with? 'library/'
return 'Basics' if slug.start_with? 'library/index' return 'Basics' if slug.start_with? 'library/index'
@ -48,7 +48,7 @@ module Docs
type = 'Internet Data Handling' type = 'Internet Data Handling'
end end
type.remove! %r{\A\d+\.\s+} # remove list number type.remove! %r{\A\d+\.\s+} unless include_h2? # remove list number
type.remove! "\u{00b6}" # remove paragraph character type.remove! "\u{00b6}" # remove paragraph character
type.sub! ' and ', ' & ' type.sub! ' and ', ' & '
[' Services', ' Modules', ' Specific', 'Python '].each { |str| type.remove!(str) } [' Services', ' Modules', ' Specific', 'Python '].each { |str| type.remove!(str) }
@ -56,6 +56,10 @@ module Docs
REPLACE_TYPES[type] || type REPLACE_TYPES[type] || type
end end
def include_h2?
return slug.start_with?('reference') || slug.start_with?('tutorial') || slug.start_with?('using')
end
def include_default_entry? def include_default_entry?
return true if slug == 'library/asyncio' return true if slug == 'library/asyncio'
!at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Superseded)) !at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Superseded))
@ -74,6 +78,13 @@ module Docs
entries << [node['id'] + '()', node['id']] entries << [node['id'] + '()', node['id']]
end end
if include_h2?
css('section[id] > h2').each do |node|
name = node.content.remove("\u{00b6}")
entries << [name, node.parent['id']]
end
end
entries entries
end end

@ -22,7 +22,7 @@ module Docs
HTML HTML
version '3.10' do version '3.10' do
self.release = '3.10.6' self.release = '3.10.7'
self.base_url = "https://docs.python.org/#{self.version}/" self.base_url = "https://docs.python.org/#{self.version}/"
html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html' html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'

Loading…
Cancel
Save