Skip to content

Introduce Sphinx doctest builds#1406

Merged
sirosen merged 7 commits into
globus:mainfrom
sirosen:doctest
Jul 21, 2026
Merged

Introduce Sphinx doctest builds#1406
sirosen merged 7 commits into
globus:mainfrom
sirosen:doctest

Conversation

@sirosen

@sirosen sirosen commented Jul 2, 2026

Copy link
Copy Markdown
Member

In order to allow for doctest usage, but without mandating it everywhere that examples are written (today and into the future), add Sphinx config which allows for use of the doctest directive but does not automatically run all examples as doctests.
A pass over existing examples found a few items worth trying to turn into doctests, but this effort may not have been perfectly complete.

  • Setup sphinx doctest
  • Convert Timers data module docstrings to doctest
  • Add TimersClient to doctest and refine config
  • Convert GCS ConnectorTable to doctests
  • Convert scope documentation to doctests
  • Doctest part of the relative deadline doc
  • Add changelog for introduction of doctest

sirosen added 7 commits July 1, 2026 16:58
- enable the plugin
- disable default console block behavior
- new tox env
- new CI config
Improve our doctest config with
- a wrapped version of `mock.patch` which does auto-rollback
- pre-set imports for all doctests
Comment thread docs/conf.py
extensions = [
# sphinx-included extensions
"sphinx.ext.autodoc",
"sphinx.ext.doctest",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm concerned about how maintainers discover what different sphinx directives mean in this repository as we expand the number of internally-maintained & dependency extensions.

With the context of reviewing this PR which adds the sphinx.ext.doctest extension in a separate file, I was eventually able to find documentation for what testsetup:: doctest::, and testcode:: meant as symbols. If I encountered those in the context of browsing through a file though, I don't think I would've been able to backtrace why those symbols are meaningful (maybe with the exception of doctest because the extension happens to be named the same).

I think it's time that we have some in-repository documentation (a DOCUMENTATION.md or similar) that provides a central reference for which directives we're importing, which we've specialized, which we've built ourselves, etc. linking out to relevant docs like https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree with this comment: that information belongs in our contribution docs. I do not think we should block this addition on these grounds, in a case of "the perfect is the enemy of the good".

Can we describe the follow-up we would like in the form of an issue or story? (I think in-repo issue tracking would be appropriate in this case.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was able to find doctest trivially with a search for "python sphinx testcode". I think we need to discuss what level of detail is needed in our contributor documentation. 🙂

@derek-globus derek-globus Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we describe the follow-up we would like in the form of an issue or story?

Yeah sure.

I was able to find doctest trivially with a search for "python sphinx testcode". I think we need to discuss what level of detail is needed in our contributor documentation. 🙂

I wouldn't expect a contributor to know that the thing they encountered in a random docstring in the form .. SomethingSomething:: <customer-symbol> is a sphinx directive so I think that assumes too much contextual knowledge.

It took me a while to figure out where to find documentation around these directives while I was reviewing the PR that introduced the extension which they use. If I were more familiar with exploring the extension space of custom sphinx directives, I probably could've gotten there quicker, but I am not & I don't think our average contributor (internal or external) will be.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, that's fair! Our contributor documentation should provide that necessary context.

We should not try to document every directive exhaustively ourselves.

@sirosen
sirosen merged commit 62b5b3d into globus:main Jul 21, 2026
9 checks passed
@sirosen
sirosen deleted the doctest branch July 21, 2026 10:28
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.

2 participants