Add tests for code examples in docs #18
br3ndonland
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
The fastenv docs contain code examples to help people get started with the package.
Code examples can be helpful, but they can also get out-of-date and stop working. For this reason, it can be helpful to test the code examples.
The code examples are usually moved to separate files to make testing easier.
pymdownx.snippets
is already enabled, which allows us to embed external files in the docs.fastenv/mkdocs.yml
Line 10 in 903a7de
Suggestions
Pages in the docs could be updated like this:
Make a new Python package directory for the docs.
fastenv_docs
. FastAPI usesdocs_src
, but I would preferfastenv_docs
because it is more specific.docs/
directory, or at the top-level of the repo. It might make sense to put the directory intodocs/
.Move code examples from Markdown code blocks into Python files in the
fastenv_docs
package.Update the Markdown code blocks to import the code examples from
fastenv_docs
as described in Material for MkDocs docs: Setup - Extensions - Python Markdown extensions - Snippets.Add tests for the code examples.
Tests could go into a new directory
tests/fastenv_docs
.If needed, the same secrets from the other tests can be used in GitHub Actions.
fastenv/.github/workflows/ci.yml
Lines 92 to 101 in 903a7de
Update test configurations in
pyproject.toml
to test the new files.fastenv/pyproject.toml
Lines 98 to 100 in 903a7de
fastenv/pyproject.toml
Lines 111 to 114 in 903a7de
Update configurations for code quality tooling to check the new files.
fastenv/pyproject.toml
Lines 102 to 109 in 903a7de
To make it manageable, a PR could address one page of the docs at a time.
Future work could also add doctests (tests for REPL examples that start with
>>>
).Related
xdoctest
(can run doctests, but maybe not on Markdown files yet)Beta Was this translation helpful? Give feedback.
All reactions