[Proposal] Small POC for doctest and recipes to prevent docs drift from code - #888
Draft
jernejfrank wants to merge 1 commit into
Draft
[Proposal] Small POC for doctest and recipes to prevent docs drift from code#888jernejfrank wants to merge 1 commit into
jernejfrank wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main motivation is to propose a mechanism to keep docs aligned with code. In particular, code examples in docs and docstrings that are stale because the code progressed but the docs we forgotten to be updated.
I experimented with this for our private repos and it proved handy. Our docs are a bit different since they do not have a cookbook/recipe layout, but I think it translates well over to here where we have large chunks of code in the docs.
2 additions:
Under this split I would treat docstring code snippets directly relevant to that one class/function and it showcases directly its usage via simple examples tested via doctest.
Docs involving multiple classes/functions and documenting a workflow / full implementation get written as python script into a *.py file with asserts at the end so it becomes an executable test. These files get collected and executed as a test in pytest (marked docs) and can run separately on the CI.
One con is that the code and doc text live seperately (see proposed changes) which means you need two files open.