GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs: module page titles should not start with a link to themselves by nedbat · Pull Request #117099 · python/cpython

Conversation

@nedbat

@nedbat nedbat commented Mar 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The :mod: role used in the title of module pages turns into a link, but the link is to the same page. That's distracting and unhelpful. This uses the ! prefix to instruct Sphinx to not make a link.

This was done with this thrown-together program:

"""
Change every module page in the CPython docs 
so that the title doesn't link to itself.
"""

from pathlib import Path

# Edge cases:
# - modules with a blank line at the top.
# - modules that already had the !-prefix to suppress the link.
# - had to fix the rule length
# - pages that started with a link, but to the main module page.
#       unittest.mock-examples.rst
# - pages with slightly off names:
#       xml.sax.xmlreader is in xml.sax.reader.rst
#       xml.etree.ElementTree is in xml.etree.elementtree.rst
#       xml.parsers.expat is in pyexpat.rst
#       xml.sax.saxutils is in xml.sax.utils.rst
# - pages with two links in the title!
#       copyreg.rst

def fix_one_file(fpath):
    text = fpath.read_text().lstrip()
    if not text.startswith(":mod:`"):
        return
    if text.startswith(":mod:`!"):
        return
    lines = text.splitlines(keepends=True)
    modname = lines[0].split("`")[1]
    if modname != fpath.stem:
        print(f"WUT: {modname=}, {fpath.stem=}")
    lines[0] = lines[0].replace(":mod:`", ":mod:`!")
    lines[1] = lines[1][0] * (len(lines[0]) - 1) + "\n"
    fpath.write_text("".join(lines))
    print(f"Updated {fpath}")

for fname in Path(".").glob("**/*.rst"):
    fix_one_file(fname)

📚 Documentation preview 📚: https://cpython-previews--117099.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nedbat
nedbat requested review from AlexWaygood and hugovk March 20, 2024 20:27
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Mar 20, 2024
@nedbat nedbat added the skip issue label Mar 20, 2024
@nedbat

nedbat commented Mar 20, 2024

Copy link
Copy Markdown
Member Author

This is only marked Draft because I didn't want to ping 29 other people for review. Can that be stopped?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Mar 20, 2024

Copy link
Copy Markdown
Member

This is only marked Draft because I didn't want to ping 29 other people for review. Can that be stopped?

I don't know of a way of avoiding that, unfortunately... It's not possible for me to deselect any of the codeowners from the list of people who are going to be requested for review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood
AlexWaygood reviewed Mar 20, 2024
View reviewed changes
Comment thread Doc/library/__future__.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nedbat
docs: module page titles should not start with a link to themselves
1485c51
AlexWaygood
AlexWaygood reviewed Mar 20, 2024
View reviewed changes
Comment thread Doc/library/copyreg.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood
AlexWaygood approved these changes Mar 20, 2024
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I agree that these are distracting for readers, and serve no purpose.

While I agree with @CAM-Gerlach's comments on Discord that a Sphinx extension might be a cleaner way of fixing this, I'm personally happy to merge this unless somebody wants to volunteer to actually do that. I think we should prioritise the experience for readers of the docs, and this PR improves the experience of reading the docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk and serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@bedevere-app bedevere-app Bot added the awaiting merge label Mar 20, 2024
@nedbat

nedbat commented Mar 20, 2024

Copy link
Copy Markdown
Member Author

Since I don't want to ping 29 code owners, and am a little bit interested in learning about Sphinx internals, let's wait on this to see how the CAM+Ned tag team manages on tweaking Sphinx.

AlexWaygood and hugovk reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JacobCoffee
JacobCoffee approved these changes Mar 20, 2024
View reviewed changes
ezio-melotti
ezio-melotti approved these changes Mar 20, 2024
View reviewed changes
erlend-aasland
erlend-aasland approved these changes May 7, 2024
View reviewed changes
@nedbat
nedbat marked this pull request as ready for review May 8, 2024 19:20
@nedbat
nedbat requested review from a team, FFY00, barneygale, berkerpeksag, encukou, ericvsmith, ethanfurman, gpshead, hauntsaninja, pablogsal, pfmoore, pradyunsg and rhettinger as code owners May 8, 2024 19:20
@nedbat
nedbat requested a review from vsajip as a code owner May 8, 2024 19:20
@bedevere-app bedevere-app Bot removed the awaiting merge label May 8, 2024
@nedbat
nedbat requested review from 1st1, asvetlov, corona10, gvanrossum, kumaraditya303, serhiy-storchaka, tiran and willingc as code owners May 8, 2024 19:20
@bedevere-app bedevere-app Bot added the awaiting review label May 8, 2024
@nedbat

nedbat commented May 8, 2024

Copy link
Copy Markdown
Member Author

Everyone: I know this might ping many people. My apologies. The changes were auto-created across all of the module pages.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes May 8, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

How we did not notice this earlier?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 8, 2024
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.12 only security fixes labels May 8, 2024
@AlexWaygood
AlexWaygood merged commit bcb435e into python:main May 8, 2024
@miss-islington-app

miss-islington-app Bot commented May 8, 2024

Copy link
Copy Markdown

Thanks @nedbat for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label May 8, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 8, 2024
@nedbat @miss-islington
docs: module page titles should not start with a link to themselves (p…
34cf8ee
…ythonGH-117099)

(cherry picked from commit bcb435e)

Co-authored-by: Ned Batchelder <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 8, 2024
@nedbat @miss-islington
docs: module page titles should not start with a link to themselves (p…
a16ecc9
…ythonGH-117099)

(cherry picked from commit bcb435e)

Co-authored-by: Ned Batchelder <[email protected]>
@bedevere-app

bedevere-app Bot commented May 8, 2024

Copy link
Copy Markdown

GH-118790 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 8, 2024
@bedevere-app

bedevere-app Bot commented May 8, 2024

Copy link
Copy Markdown

GH-118791 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 8, 2024
AlexWaygood pushed a commit that referenced this pull request May 8, 2024
@miss-islington @nedbat
[3.12] docs: module page titles should not start with a link to thems…
b83b3cb
…elves (GH-117099) (#118791)

docs: module page titles should not start with a link to themselves (GH-117099)
(cherry picked from commit bcb435e)

Co-authored-by: Ned Batchelder <[email protected]>
AlexWaygood pushed a commit that referenced this pull request May 8, 2024
@miss-islington @nedbat
[3.13] docs: module page titles should not start with a link to thems…
c33bba6
…elves (GH-117099) (#118790)

docs: module page titles should not start with a link to themselves (GH-117099)
(cherry picked from commit bcb435e)

Co-authored-by: Ned Batchelder <[email protected]>
@nedbat
nedbat deleted the nedbat/dont-self-link-module-pages branch May 21, 2024 22:13
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@erlend-aasland erlend-aasland erlend-aasland approved these changes
@ezio-melotti ezio-melotti ezio-melotti approved these changes
@JacobCoffee JacobCoffee JacobCoffee approved these changes
@AlexWaygood AlexWaygood AlexWaygood approved these changes
@hugovk hugovk Awaiting requested review from hugovk
@barneygale barneygale Awaiting requested review from barneygale barneygale is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner
@encukou encukou Awaiting requested review from encukou encukou is a code owner
@hauntsaninja hauntsaninja Awaiting requested review from hauntsaninja hauntsaninja is a code owner
@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman is a code owner
@pfmoore pfmoore Awaiting requested review from pfmoore pfmoore is a code owner
@pradyunsg pradyunsg Awaiting requested review from pradyunsg pradyunsg is a code owner
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith is a code owner
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner
@vsajip vsajip Awaiting requested review from vsajip vsajip is a code owner
@tiran tiran Awaiting requested review from tiran
@corona10 corona10 Awaiting requested review from corona10 corona10 is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@nedbat @AlexWaygood @serhiy-storchaka @erlend-aasland @ezio-melotti @JacobCoffee
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.