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
WIP: add crossrefs checker for documentation linting #9082
Conversation
@Zac-HD will do a proper PR out of this in the next days. |
Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
Signed-off-by: Oleg Hoefling <oleg.hoefling@gmail.com>
c711942
to
5465afc
Compare
I'd also like to consider proposing this upstream as The only changes involved would be to drop the Thoughts? |
Glad that you liked it! It's a great idea to keep the internal inventory in
I have another script for |
If we're going that far... how hard would it be to just implement the suggestion? For safety maybe only if you pass a |
Awesome!
If that's the case they don't want to include that checker in Sphinx directly, consider making this a standalone package on PyPI? This would allow to reuse it nicely. 👍 |
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Done with the initial impl that also includes suggestions, will now prepare a PR for https://github.com/sphinx-doc/sphinx. Also updated the PR description, just for the sake of completeness.
This would be awesome, but I don't have any clue on how to implement this properly. I researched the inplace modification of ReST files with Sphinx when implementing my first doc checkers two years ago. Unfortunately, Sphinx doesn't offer anything that can parse ReST and write ReST back (something like what Another issue is that it's quite hard to trace the ReST source in docstrings - this is something not resolved with the impl in this PR as well. When a hardcoded URL is dropped in a docstring, Sphinx will display a wrong and totally misleading line number to the |
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
The upstream PR is at sphinx-doc/sphinx#9626. |
Closing this since the Sphinx maintainers seem to agree on adding the feature to Sphinx directly. |
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This partly addresses #9081.
This PR adds a new no-op Sphinx builder named
crossrefcheck
that checks whether a hardcoded URL in the text can be replaced with a crossreference from one of the inventories configured inintersphinx_mapping
. If yes,crossrefcheck
will emit a warning like this:If a replacement suggestion is printed, the hardcoded URL can be safely replaced with that suggestion.
Usage
Caveats
The builder is not able to catch the URLs for the internal docs. This is because no information is known about the URL the docs will be hosted at. Thus, if links to
https://docs.pytest.org
should be checked as well, it is best to extendintersphinx_mapping
. Example:If a URL is reported without a suggestion, it usually indicates that either: