[devdocsgjs/main: 67/69] Update Python documentation (3.10.7)
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 67/69] Update Python documentation (3.10.7)
- Date: Mon, 12 Sep 2022 18:46:56 +0000 (UTC)
commit 87549933c726b78ad9011913976f2f89ea05d155
Author: Simon Legner <Simon Legner gmail com>
Date: Wed Sep 7 16:24:11 2022 +0200
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
lib/docs/filters/python/entries_v3.rb | 19 +++++++++++++++----
lib/docs/scrapers/python.rb | 2 +-
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/lib/docs/filters/python/entries_v3.rb b/lib/docs/filters/python/entries_v3.rb
index 8a77d540..033427f4 100644
--- a/lib/docs/filters/python/entries_v3.rb
+++ b/lib/docs/filters/python/entries_v3.rb
@@ -17,7 +17,7 @@ module Docs
def get_name
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! %r{ [\u{2013}\u{2014}].+\z} # remove text after em/en dash
name.remove! 'Built-in'
@@ -29,8 +29,8 @@ module Docs
return 'Language Reference' if slug.start_with? 'reference'
return 'Python/C API' if slug.start_with? 'c-api'
return 'Tutorial' if slug.start_with? 'tutorial'
- return 'Distributing' if slug.start_with? 'distributing'
- return 'Distributing' if slug.start_with? 'distutils'
+ return 'Software Packaging & Distribution' if slug.start_with? 'distributing'
+ return 'Software Packaging & Distribution' if slug.start_with? 'distutils'
return 'Basics' unless slug.start_with? 'library/'
return 'Basics' if slug.start_with? 'library/index'
@@ -48,7 +48,7 @@ module Docs
type = 'Internet Data Handling'
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.sub! ' and ', ' & '
[' Services', ' Modules', ' Specific', 'Python '].each { |str| type.remove!(str) }
@@ -56,6 +56,10 @@ module Docs
REPLACE_TYPES[type] || type
end
+ def include_h2?
+ return slug.start_with?('reference') || slug.start_with?('tutorial') || slug.start_with?('using')
+ end
+
def include_default_entry?
return true if slug == 'library/asyncio'
!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']]
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
end
diff --git a/lib/docs/scrapers/python.rb b/lib/docs/scrapers/python.rb
index 6d64ad00..6f3c6f1e 100644
--- a/lib/docs/scrapers/python.rb
+++ b/lib/docs/scrapers/python.rb
@@ -22,7 +22,7 @@ module Docs
HTML
version '3.10' do
- self.release = '3.10.6'
+ self.release = '3.10.7'
self.base_url = "https://docs.python.org/#{self.version}/"
html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]