Skip to content

Do not build notebooks when doing linkcheck#272

Merged
nvaytet merged 3 commits intomainfrom
no-build-when-linkcheck
Jan 23, 2026
Merged

Do not build notebooks when doing linkcheck#272
nvaytet merged 3 commits intomainfrom
no-build-when-linkcheck

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Jan 17, 2026

This saves quite a lot of build time.

Comment on lines 29 to +30
commands = python -m sphinx -W -j2 -v -b html -d {toxworkdir}/docs_doctrees docs html
python -m sphinx -W -j2 -v -b doctest -d {toxworkdir}/docs_doctrees docs html
python -m sphinx -W -j2 -v -b doctest -d {toxworkdir}/docs_doctrees -D nbsphinx_execute=never docs html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doctest, linkcheck is 15 lines lower down, did you edit the wrong one or is the PR title wrong?

Copy link
Member Author

@nvaytet nvaytet Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant to edit the linkcheck line.

However, can we also skip building when doing doctest? Do I remember correctly that doctest is testing snippets in the docs, but not what is run in notebook cells?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, probably?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jl-wynen do you know if not running notebooks for doctest is ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it use the cached results anyway since we build the docs in the line above?

I would think that we don't need to execute notebooks for doctest because we don't have code samples in the notebooks. But we do need to execute them for linkcheck so we can check the links in notebooks. Would be nice if we could reuse the cached results from the docs build in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to run the notebooks just to check links in the markdown cells?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think linkcheck can handle markdown or notebooks on its own. AFAIK, it operates on the parse tree generated by docutils which require rst.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I may well be wrong!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbsphinx will still render rst files from the notebooks, it just won't execute the code in the cells (so there will be no outputs in the generated docs).

To prove it, I tried to insert a bad link in one of the notebooks in essdiffraction and it found it:

(user-guide/dream/dream-advanced-powder-reduction: line   12) broken    https://scipppp.github.io/ - 404 Client Error: Not Found for url: https://scipppp.github.io/

Other links are checked and validated properly:
Screenshot_20260123_110009

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I have no objections.

@jl-wynen
Copy link
Member

Did you also try whether doctest still works like this?

@nvaytet
Copy link
Member Author

nvaytet commented Jan 23, 2026

Did you also try whether doctest still works like this?

I don't think we have tests in notebooks, so I don't see why it wouldn't?

The tests still run in essdiffraction:

Document: generated/modules/ess.powder.smoothing.lowpass
--------------------------------------------------------
1 items passed all tests:
   6 tests in default
6 tests in 1 items.
6 passed and 0 failed.
Test passed.

Document: generated/modules/ess.powder.types.CorrectedDetector
--------------------------------------------------------------
1 items passed all tests:
   4 tests in default
4 tests in 1 items.
4 passed and 0 failed.
Test passed.

@nvaytet nvaytet merged commit a817cfc into main Jan 23, 2026
2 checks passed
@nvaytet nvaytet deleted the no-build-when-linkcheck branch January 23, 2026 11:06
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 this pull request may close these issues.

3 participants