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

Store all code examples in documentation as .py files that are evaluated and templated into the docs #85

Closed
jamescurtin opened this issue Feb 8, 2021 · 0 comments · Fixed by #115
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@jamescurtin
Copy link
Contributor

We might consider storing all code examples used in the documentation as individual .py files. When the docs are built, each example is evaluated and the code (along with whatever is printed to stdout) is templated into the docs.

Projects like Pydantic use this approach and it allows them to:

  1. Have confidence that all examples in the documentation work properly (examples that won't run would fail the CI pipeline)
  2. Give readers of the documentation more information (they see the output of the code snippet without needing to copy & execute it themself)
  3. Minimize maintenance, as the output would be automatically generated.

Here's one example from Pydantic:

@jamescurtin jamescurtin added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 8, 2021
@plannigan plannigan added this to the 1.0.0 milestone Feb 16, 2021
@fhightower fhightower self-assigned this Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants