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

Sphinx linkcheck fails for GitHub link with anchor in CI #1272

Closed
serixscorpio opened this issue Jul 8, 2023 · 6 comments · Fixed by #1279
Closed

Sphinx linkcheck fails for GitHub link with anchor in CI #1272

serixscorpio opened this issue Jul 8, 2023 · 6 comments · Fixed by #1279

Comments

@serixscorpio
Copy link
Contributor

Problem

Sphinx linkcheck fails for https://github.com/pypa/pip/blob/main/setup.py#L11 in CI.

image

This is likely due to Github making the file viewer require Javascript, which breaks linkcheck's anchor checks.

Approaches

From specific to general:

  1. Remove this link or remove the anchor portion of this link. This might degrade clarity of documentation and future use of github links with anchor would break CI.
  2. Ignore linkcheck for this single link. However, if another github link with anchor is added to documentation, CI would break again.
  3. Disable linkcheck for github links with anchor. A regex can be used to detect github links with anchor. See also feature request to Sphinx: Allow disabling linkcheck anchor checks for specific URLs sphinx-doc/sphinx#11484. But github links with anchor (current and in the future) can rot.
  4. Ignore Github links altogether. However, there are many github links currently in use.

For now I'm leaning towards approach 2 or 3.

@webknjaz
Copy link
Member

webknjaz commented Jul 8, 2023

There were attempts in the past to fix this for GitHub but were reverted: sphinx-doc/sphinx#9016 (comment).

I think that prefixing the anchors with user-content- — these do exist in the actual HTML, unlike the generated ones: https://github.com/sphinx-doc/sphinx/pull/9260/files#diff-a00408d73754dd42b50d138c9927590014dcdd58f079c57c7cfe89a33fb9575aR663.

@di di mentioned this issue Aug 1, 2023
@di
Copy link
Sponsor Member

di commented Aug 1, 2023

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2023

@di oh, it looks like they've changed the HTML layout to remove those anchors from the initial HTTP response entirely, and it's all being rendered on the front end now. I suppose we just need to mass-ignore any GH code-line anchors, after all...

@di
Copy link
Sponsor Member

di commented Aug 1, 2023

I'm just going to drop the anchor here, it doesn't seem specifically necessary.

@webknjaz
Copy link
Member

webknjaz commented Aug 1, 2023

@chrysle
Copy link
Contributor

chrysle commented Sep 19, 2023

There is the config value linkcheck_anchors_ignore for Sphinx. I think we could employ this to allow adding GitHub anchors.

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

Successfully merging a pull request may close this issue.

4 participants