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

gh-97908: CAPI docs: Remove repeated struct names from member docs #100054

Merged
merged 7 commits into from
May 29, 2023

Conversation

encukou
Copy link
Member

@encukou encukou commented Dec 6, 2022

Members with repeated struct names were interpreted as e.g. PyType_Spec.PyType_Spec.name,
showing up incorrectly wrong in the search and index, and complicating automation.

This removes the duplicated names, but keeps old HTML anchors so that external links continue to work.
I don't see a better way than raw HTML to add custom anchors with dots.

Most PyMemberDef fields were already fixed in GH-99014, old anchors are added for those too.

Edit: PyMemberDef and PyGetSetDef were only marked up in 3.12 (gh-97909), so they don't need “old” URL anchors.

@encukou
Copy link
Member Author

encukou commented Dec 6, 2022

(I've included and reverted a hack to find these. I don't think it's worth keeping, at least without better error reporting. Eventually I hope we'll grow general checks that docs correspond to code.)

@netlify
Copy link

netlify bot commented Dec 6, 2022

Deploy Preview for python-cpython-preview ready!

Name Link
🔨 Latest commit cc57955
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/638f6c9df0890f000965d292
😎 Deploy Preview https://deploy-preview-100054--python-cpython-preview.netlify.app/c-api/structures
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

These were only marked up in 3.12 (pythongh-97909), so they don't need
backcompat backflips.
@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Dec 7, 2022

I don't see a better way than raw HTML to add custom anchors with dots.

I can think of a few practical solutions here that should work, that would be cross-builder, less hacky, and more concise, clean and precise, and should be able to fix internal and intersphinx references as well:

  • Add a custom directive .. literal-target:: or similar that could be used anywhere to add a literal explicit target (without normalizing the label); this would be the most general solution, but users would have to specify the fully qualified raw label name (as you do here)
  • Add a custom directive .. alias:: or similar that could be used as a child of any domain directive (like .. c:member::), that would list alias(es) of that domain directive. A little less general, but simpler for users to use, as they only have to specifiy the immediate alias name
  • As a the most specific solution to this problem, but potentially requiring the least work by users, in our custom extension (that you inserted the check into), we could potentially add some custom code to fix the issue and retain the existing cross-references as well as new fixed ones.

I have some meetings now, but I'll explore these further and report back later tonight

@encukou
Copy link
Member Author

encukou commented Dec 7, 2022

Sounds good! But it also sounds like it could use a longer discussion, since there's no obvious better way :(

Unless there's a problem with raw, let's use it for now, and file an issue for the improvement? I'd like to unblock #96996 which will also need to retain anchors.

@CAM-Gerlach
Copy link
Member

Yeah, I guess that makes the most sense, unless @AA-Turner has a better solution—I intended to get to it yesterday, but I've been busy since then helping students with their Python final projects, so I haven't had the chance to continue to dig into it and prototype something.

@encukou encukou added the needs backport to 3.12 bug and security fixes label May 25, 2023
@encukou encukou merged commit 1668b41 into python:main May 29, 2023
19 checks passed
@miss-islington
Copy link
Contributor

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@encukou encukou deleted the struct-name-repeats branch May 29, 2023 11:54
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 29, 2023
…ocs (pythonGH-100054)

And add raw HTML fragments to keep old links working.
(cherry picked from commit 1668b41)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-bot
Copy link

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

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label May 29, 2023
ambv pushed a commit that referenced this pull request Jun 5, 2023
…docs (GH-100054) (#105057)

And add raw HTML fragments to keep old links working.
(cherry picked from commit 1668b41)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants