Skip to content

DOC Sphinx linkcheck may not work as expected as there are broken links on scikit-learn  #34319

Closed

Description

@DeaMariaLeon

EDIT:
scikit-learn uses Sphinx linkcheck but it seems that it doesn't check the whole docs webpage.

I used https://validator.w3.org/checklink to search for broken links. I just checked 2 pages and found 2 broken links.

  1. link: https://www.probabl.ai/lp/scikit-learn - found in doc/templates/index.html - Sponsors where added here: DOC Financial supporters #33704

  2. link: https://github.com/scikit-learn/administrative/tree/master/meeting_notes found in doc/governance.rst
    (This one not as critical)


For history purposes: #23577, PRs #23631, #32969

I'll open a PR to fix the two links above but this is what I found so far:

Image

Activity

  1. added
    Needs Triage
    on Jun 17, 2026
  2. added and removed
    Needs Triage
    on Jun 17, 2026
  3. AnneBeyer commented on Jun 17, 2026

    @AnneBeyer
    Member

    Thank you for checking, @DeaMariaLeon! I don't think fixing broken links even needs an issue. :)
    Especially the probabl one should be fixed asap!

  4. DeaMariaLeon commented on Jun 17, 2026

    @DeaMariaLeon
    MemberAuthor

    Thanks for letting me know @AnneBeyer. Maybe I should change the title of the issue because my question/concern is:

    scikit-learn uses Sphinx linkcheck but it seems to me that it's not covering the whole docs webpage.

    The link can be easily fixed (and asap like you say).

  5. changed the title [-]DOC Broken links on scikit-learn website[/-] [+]DOC Sphinx `linkcheck` may not work as expected as there are broken links on scikit-learn [/+] on Jun 17, 2026
  6. moved this to In progress in Labson Jun 27, 2026
  7. MarieSacksick commented on Jul 2, 2026

    @MarieSacksick
    Contributor
  8. StefanieSenger commented on Jul 6, 2026

    @StefanieSenger
    Member

    So if we run make linkcheck manually from time to time, we wouldn't catch all the failing links? Do we want to keep doing the manual check from time to time or would it be easy to fix? See #25024 for reference, since this is a great first time contributor issue.

  9. DeaMariaLeon commented on Jul 6, 2026

    @DeaMariaLeon
    MemberAuthor

    So if we run make linkcheck manually from time to time, we wouldn't catch all the failing links?

    Right, we don't catch all the broken links. There are some links listed in doc.conf.py that are supposed to be skipped, but the ones I found are different.

    Do we want to keep doing the manual check from time to time or would it be easy to fix?

    I believe that there is nothing to fix; linkcheck is a built-in "Sphinx builder".

    I just tried running make linkcheck again, and my laptop got super hot. I'm not sure I want to run it again. :-/
    The first time I let it run until the end, it didn't find the links I initially reported (e.g., to probabl and to the calendar).

    So, I think we need a different way to check for broken links.

  10. DeaMariaLeon commented on Jul 7, 2026

    @DeaMariaLeon
    MemberAuthor
  11. DeaMariaLeon commented on Jul 8, 2026

    @DeaMariaLeon
    MemberAuthor

    Findings and recap:

    • Sphinx's linkcheck is not run in the CI and it misses broken links
    • lychee has a GitHub Action, but I was able to run it locally with Docker:
      • When testing against the live web, a DNS-dead domain kills the run and no report is written.
      • Testing against a locally built documentation runs the test to the end, but more investigation is needed to avoid false positives.
      • Added 403 to the accepted HTTP response statuses -- this apparently happens with websites that don't allow bots to connect.

    To use it, I first built the documentation with make html-noplot.
    Then:

    DOCS="$(pwd)/doc/_build/html/stable"
    OUT="$(pwd)/link-check"
    mkdir -p "$OUT"
    
    docker run --rm -v "$DOCS":/docs:ro -v "$OUT":/out lycheeverse/lychee \
     --output /out/broken_links_report.txt \
     --timeout 30 \
     --max-concurrency 32 \
     --accept '200..=206,403,429' \
     --exclude docs/whats_new/v0*.* \
     --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36' \
     '/docs/**/*.html'
    

    Found broken links:


    This is the report that was created (hence better flags needed)

    broken_links_report.txt

    So, we need to decide if using this library is an option. Also, if I open a "good first issue" to fix the links.

  12. moved this from In progress to PR waiting for reviews in Labson Jul 13, 2026
  13. moved this from PR waiting for reviews to In progress in Labson Jul 16, 2026
  14. lesteve commented on Aug 3, 2026

    @lesteve
    Member

    make linkcheck is probably not perfect but good enough I would say. There may be some reasons why it didn't catch some of the links you pointed to, for example the probabl link is in an html template template/funding_links.html and maybe linkcheck only handles rst not entirerly sure ...

    To clear up some possible confusion, make linkcheck is run manually indeed from time to time (every few years?). In the meantime, people do open issues about broken links they bump into from time to time and we fix them.

    Although not ideal I think this is fine sticking to this manual approach. In other words, I don't think it is worth it trying to come up with an automated way of creating issues for each problematic links.

    One potential reason make linkcheck takes time, is likely because make linkcheck runs the full examples.

    If you find a better tool that linkcheck why not but at the same time, I am not sure this is super high priority ...

    A few advantages of make linkcheck:

    • we already have some ignore list where some links are fine but reported as broken (false positives), for example because the website blocks some automated requests
    • it knows about rst and reports the issue in terms of the rst source.

    In the past what happened is:

    Here is a hacky script I found in my notes to generate part of the content of the issue.

    from pathlib import Path
    path = Path("~/dev/scikit-learn/doc/_build/linkcheck/output.json").expanduser()
    # format is jsonlines
    import json
    links_info = [json.loads(line) for line in path.read_text().splitlines()]
    
    import pandas as pd
    df = pd.DataFrame(links_info)
    print(df.columns)
    print(df['status'].value_counts())
    
    broken = df[df['status'] == 'broken']
    # print github-friendly markdown list 
    broken_info = [f"- [ ] `{each['uri']}` {each['filename']}\n  ```\n  {each['info']}\n  ```" for each in broken.to_records()]
    print('\n'.join(broken_info))

    I think I had a script to update automatically the issue when PR were created and merged, not sure where it is, but it was something like https://gist.github.com/lesteve/478d52599d394ec5e7f56dbf0827a5e9 based on a previous script by Thomas Pfan.

  15. DeaMariaLeon commented on Aug 3, 2026

    @DeaMariaLeon
    MemberAuthor

    Everything you comment here I already knew. But:

    • I never said that I wanted an automatic tool.
    • I found the broken links using lychee, like I had written earlier.
    • It's fast since it's written in Rust, links to ignore can also be specified.
    • lychee is easy to run in a Docker container (I shared what I did above as well).

    I corrected the broken links and the problem is solved as far as I'm concerned.

  16. moved this from In progress to Done in Labson Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions