Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 635: fix duplicate labels #2742

Merged
merged 2 commits into from
Jul 28, 2022
Merged

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jul 28, 2022

Fix these warnings:

pep-0635.rst:403: WARNING: duplicate label patterns, other instance in pep-0634.rst
pep-0635.rst:592: WARNING: duplicate label literal_pattern, other instance in pep-0634.rst
pep-0635.rst:681: WARNING: duplicate label capture_pattern, other instance in pep-0634.rst
pep-0635.rst:740: WARNING: duplicate label wildcard_pattern, other instance in pep-0634.rst
pep-0635.rst:907: WARNING: duplicate label sequence_pattern, other instance in pep-0634.rst
pep-0635.rst:967: WARNING: duplicate label mapping_pattern, other instance in pep-0634.rst
pep-0635.rst:1014: WARNING: duplicate label class_pattern, other instance in pep-0634.rst

Like #2735, we still get the same anchors in both:

Also remove redundant emacs metadata.

Preview

https://pep-previews--2742.org.readthedocs.build/pep-0635/

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

LG (although I think it's a silly requirement that labels must be unique across all PEPs -- it doesn't scale).

@hugovk hugovk merged commit 3d63099 into python:main Jul 28, 2022
@hugovk hugovk deleted the pep635-fix-duplicate-labels branch July 28, 2022 19:10
@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Jul 29, 2022

It is a little tedious, but the whole point of Sphinx cross-references is to be able to cross reference objects across documents, even if things get moved around—the solution here is namespacing the target names by the PEP number, which still preserves the generated in-page fragments without the number. That's what the Python docs do as well, though its not as clean as here (since they have to rely on full page titles, and which don't get auto-elided).

@gvanrossum
Copy link
Member

A PEP shouldn’t have to repeat its own local namespace though IMO. (But I don’t know what Sphinx is capable of.)

@CAM-Gerlach
Copy link
Member

This works for references to, e.g., classes, functions and methods, since they are globally unique when fully qualified and don't depend on the file structure, but not so generic ref targets.

Here "namespaces" are only a convention, which can be flexible applied on a per-project (or even per-reference) basis—there is no formalized mechanism for automatic per-document namespacing. Outside of special cases like ours, it wouldn't really work well as it would defeat much of the portability and robustness of ref targets over implicit internal links, as if the document/content was ever moved, renamed, etc. it would break—and even there, it wouldn't work for things like PEP 639 (which makes extensive use of refs to avoid things breaking when I move ancillary sections out to separate files).

We could possibly implement bespoke hacks in a custom ref role and the PEP transforms to do something like this, but this might just be more trouble for authors than its worth since they might expect the standard behavior, like in the Python docs, and would have to implicitly know and remember to prepend the PEP number to references in other PEPs or the refs will not work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants