-
Notifications
You must be signed in to change notification settings - Fork 2k
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
linkcheck could also check local (internal) links #5208
Comments
+0: It might be useful. But all we can check is only inside sphinx-document. If users copy extra file in deploy script, we'll misdetect broken links. And it is hard if local hyperlink is absolute path. We don't know where the document will be placed. |
At least this could be an optional feature; I'd guess there are a lot of sphinx deployments which do not add anything manually and just stick to what sphinx generates. |
Agreed. I also believe it is useful. |
https://github.com/sphinx-doc/sphinx/pull/7103/files#diff-bb67587af94a24f53692228ea27061edR252 at least includes the local link in the json output |
Is there any updates to this issue? Could use a local linkchecker in my sphinx docs. |
It seems nobody sends a PR for us. How about you? It's time to contribute :-) |
Close #5208: linkcheck: Support checks for local links
Apologies if this is a bit off-topic, but I noticed that linkcheck is reporting broken links for all my local links. I suspect it's due to a problem with how my team is using local links. Example: "overview.rst" links to "detail.rst" like so: The HTML output is fine, but linkcheck fails because it looks for a file named Is the "right way" to solve this to use document cross-references instead of links? Thank you! |
https://github.com/sphinx-doc/sphinx/blob/master/sphinx/builders/linkcheck.py .. index: this
.. _that:
.. _this:
This
=====
:ref:`this` - which references ``.. _this:`` -
works between all docs included in the sphinx build.
:ref:`that` does as well.
:ref:`also <this>`
:ref:`also <that>`
`this`_ works because there's a "this" heading
`this <this.html>`_
`this <this.rst>`_
`this <this>`_
`this <this.html>`__
`this <this.rst>`__
`this <this>`__
This will log an error about
the duplicate reference if it's in any doc in the build:
.. _this:
|
Docs for hyperlinking with docutils and Sphinx: https://www.sphinx-doc.org/en/1.8/usage/restructuredtext/roles.html#ref-role https://www.sphinx-doc.org/en/1.8/usage/restructuredtext/basics.html#hyperlinks https://www.sphinx-doc.org/en/1.8/usage/restructuredtext/roles.html#role-doc : :doc:`this`
:doc:`this one <this>` ^^ that'll work in Sphinx but not in a GH rst render. Could you omit the extension from the link? (There's a conf.py option to remove the .HTML from sphinx-generated links: `anchor text <this>`_ Trying to remember what the trailing double underscore does for hyperlinks? `anchor text <this>`__ |
Yes, |
@tk0miya This seems to be problematic with something like: .. figure:: architecture.png
:target: ../../_images/architecture.png Target ( Is there a workaround? |
Could you raise an exception in linkcheck and drop into ipdb/pdb++? python -m venv sphinx
source ./sphinx/bin/activate
echo "${VIRTUAL_ENV}"
pip install -e git+https://github.com/sphinx-doc/sphinx#egg=sphinx
pip install pdbpp pytest-cov
# cd "${VIRTUAL_ENV}/src/sphinx"
cd ./sphinx/src/sphinx
# create an Exception (where?) and a test_ function
pytest --pdb |
@westurner Was that a reply for me? What is the intent of the steps you posted? |
That may be the best bet for debugging why the Things to test in a test that raises an exception so that you can interactively pdb to debug:
To add a temporary exception In the linkcheck callable in order to write a test that recreates the error conditions and/or just fix the bug: if x.attr == '../../_images/architecture.png':
raise Exception() |
Hmm... it's difficult situation. The target file will be available only on building HTML. Because the files under |
@westurner Thank you for the instructions to investigate the issue. Luckily, not needed here but I'll bookmark mentally :) |
Subject: linkcheck currently doesn't check local (internal) links, but this would be useful.
Problem
See above.
Procedure to reproduce the problem
Create a template project with sphinx-quickstart, put the following in index.rst
Run
make linkcheck
Error logs / results
Expected results
Also a check for the local link.
Reproducible project / your project
N/A
Environment info
The text was updated successfully, but these errors were encountered: