Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-84232: Fixpydoc docs.python.org link generation (GH-139995)#143098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 1 commit intopython:3.14frommiss-islington:backport-f9704f1-3.14
Dec 23, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion.gitattributes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -82,8 +82,10 @@ Include/opcode.h generated
Include/opcode_ids.h generated
Include/token.h generated
Lib/_opcode_metadata.py generated
Lib/keyword.py generated
Lib/idlelib/help.html generated
Lib/keyword.py generated
Lib/pydoc_data/topics.py generated
Lib/pydoc_data/module_docs.py generated
Lib/test/certdata/*.pem generated
Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
Expand Down
6 changes: 3 additions & 3 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,15 +40,15 @@ repos:
files:^Apple
-id:ruff-format
name:Run Ruff (format) on Doc/
args:[--check]
args:[--exit-non-zero-on-fix]
files:^Doc/
-id:ruff-format
name:Run Ruff (format) on Tools/build/check_warnings.py
args:[--check, --config=Tools/build/.ruff.toml]
args:[--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
files:^Tools/build/check_warnings.py
-id:ruff-format
name:Run Ruff (format) on Tools/wasm/
args:[--check, --config=Tools/wasm/.ruff.toml]
args:[--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
files:^Tools/wasm/

-repo:https://github.com/psf/black-pre-commit-mirror
Expand Down
3 changes: 2 additions & 1 deletionDoc/Makefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,7 +140,8 @@ doctest:
pydoc-topics: BUILDER = pydoc-topics
pydoc-topics: build
@echo"Building finished; now run this:"\
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"\
"&& cp build/pydoc-topics/module_docs.py ../Lib/pydoc_data/module_docs.py"

.PHONY: gettext
gettext: BUILDER = gettext
Expand Down
26 changes: 26 additions & 0 deletionsDoc/tools/extensions/pydoc_topics.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -109,6 +109,7 @@ class PydocTopicsBuilder(TextBuilder):
def init(self) -> None:
super().init()
self.topics: dict[str, str] = {}
self.module_docs: dict[str, str] = {}

def get_outdated_docs(self) -> str:
# Return a string describing what an update build will build.
Expand All@@ -130,6 +131,15 @@ def write_documents(self, _docnames: Set[str]) -> None:
continue
doc_labels.setdefault(docname, []).append((topic_label, label_id))

py_domain = env.domains['py']
for module_name, module_info in py_domain.data['modules'].items():
docname = module_info[0]
if docname.startswith('library/'):
doc_file = docname.replace('library/', '')
self.module_docs[module_name] = (
f"{doc_file}#module-{module_name}"
)

for docname, label_ids in status_iterator(
doc_labels.items(),
"building topics... ",
Expand DownExpand Up@@ -161,6 +171,22 @@ def finish(self) -> None:
"""
self.outdir.joinpath("topics.py").write_text(topics, encoding="utf-8")

module_docs_repr = "\n".join(
f" '{module}': '{doc_file}',"
for module, doc_file in sorted(self.module_docs.items())
)
module_docs = f"""\
# Autogenerated by Sphinx on {asctime()}
# as part of the release process.

module_docs = {{
{module_docs_repr}
}}
"""
self.outdir.joinpath("module_docs.py").write_text(
module_docs, encoding="utf-8"
)


def _display_labels(item: tuple[str, Sequence[tuple[str, str]]]) -> str:
_docname, label_ids = item
Expand Down
16 changes: 13 additions & 3 deletionsLib/pydoc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -579,10 +579,20 @@ def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')):
(file.startswith(basedir) and
not file.startswith(os.path.join(basedir, 'site-packages')))) and
object.__name__ not in ('xml.etree', 'test.test_pydoc.pydoc_mod')):
if docloc.startswith(("http://", "https://")):
docloc = "{}/{}.html".format(docloc.rstrip("/"), object.__name__.lower())

try:
from pydoc_data import module_docs
except ImportError:
module_docs = None

if module_docs and object.__name__ in module_docs.module_docs:
doc_name = module_docs.module_docs[object.__name__]
if docloc.startswith(("http://", "https://")):
docloc = "{}/{}".format(docloc.rstrip("/"), doc_name)
else:
docloc = os.path.join(docloc, doc_name)
else:
docloc =os.path.join(docloc, object.__name__.lower() + ".html")
docloc =None
else:
docloc = None
return docloc
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2026 Movatter.jp