Skip to content

docs: move recipe examples into included source files#826

Open
l46983284-cpu wants to merge 2 commits into
hynek:mainfrom
l46983284-cpu:docs/examples-as-source-files
Open

docs: move recipe examples into included source files#826
l46983284-cpu wants to merge 2 commits into
hynek:mainfrom
l46983284-cpu:docs/examples-as-source-files

Conversation

@l46983284-cpu

Copy link
Copy Markdown

Summary

Move non-doctest recipe examples out of docs/recipes.md into docs/examples/recipes/ and include them with literalinclude, following the pattern used in hynek/svcs.

This keeps recipe source verifiable as real Python files (compile/lint) instead of only living inside markdown fences. Doctest/pycon examples stay inline.

Fixes #819

Pull Request Checklist

  • I acknowledge this project's AI policy.
  • This pull request is not from my main branch.
  • There's tests for all new and changed code.
  • New APIs are added to our typing tests in api.py.
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Documentation in .rst and .md files is written using semantic newlines.
  • Changes (and possible deprecations) are documented in the changelog.

Test plan

  • python -m py_compile docs/examples/recipes/*.py and AST parse
  • ruff check docs/examples/recipes/*.py
  • pytest -q → 884 passed, 37 skipped

Non-doctest recipe snippets now live under docs/examples/recipes/ and
are pulled into docs/recipes.md with literalinclude, matching the svcs
pattern so example code can be checked independently.

Fixes hynek#819

Signed-off-by: Alex Chen <l46983284@gmail.com>
Moving recipes into docs/examples/*.py made ty check those files.
Optional pathos import is intentional for the ThreadPool recipe and
is not part of the typed API surface under tests/typing.
Include docs/examples in the existing ty override that keeps full
rules only for tests/typing.

Signed-off-by: Alex Chen <l46983284@gmail.com>
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.

Transform examples in docs into included source files

1 participant