Docs: use a Sphinx extension to eliminate excessive links#145130
Docs: use a Sphinx extension to eliminate excessive links#145130nedbat merged 4 commits intopython:mainfrom
Conversation
|
I had a good idea: instead of writing a linter to change .rst files (pinging everyone, expecting reviews, hardcoding what's excessive, etc), now we have a Sphinx extension that does it all on the fly during the build. |
|
Of course: if we like this, I'll publish linklint for real. |
|
Some methods aren't unlinking properly, like ZipFile.close, but I think that's because the .rst is wrong: the methods aren't indented under the class. Is that a mistake in the .rst? Sphinx understands that "close" is "ZipFile.close", or is that because the .rst has |
|
I see many classes document their methods that way, so there's more work to do. |
|
In general I think this is a good idea, no big source change+pings+reviews. We have been careful not to use third-party extensions that downstream redistributors might not have installed, and this extension would be fine: we can list it in Comparing some pages that were mentioned during the discussion:
We could possibly omit links for the repeated
Unlinks the second pair of
Unlinks repeats 👍 |
0e075de to
d6100ca
Compare
|
I've updated the extension to recognize methods in different class contexts as well. It also prints a message at the end of the build. It now reports: |
ZipFile.close() is now unlinked in its own description. |
This style wasn’t always supported, so many classes have one entry for the class itself and another section like «XYZ objects» and methods indexed like |
Thanks. I think linklint properly understands both forms, but I won't be surprised if there are still outliers. The docs are large and diverse! |
|
Sharing an idea: if linklint produced an XML report, we could use diff-cover in CI to lint only the new or modified documentation lines in CPython PRs, without forcing changes to the existing documentation. |
That is an interesting idea! I'm hoping that the Sphinx extension can do what is needed at build time without having to change the source files at all. |
3ccab96 to
eb0d3f2
Compare

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