Skip to content

Feat/doc example testing - #250

Open
Leokaufi wants to merge 8 commits into
developmentfrom
feat/doc-example-testing
Open

Feat/doc example testing#250
Leokaufi wants to merge 8 commits into
developmentfrom
feat/doc-example-testing

Conversation

@Leokaufi

@Leokaufi Leokaufi commented Jul 30, 2026

Copy link
Copy Markdown

Description

Adds automated testing for the Python code snippets in the detector documentation.
The example usage - blocks in the docs are now extracted and executed as tests, so they
stay in sync with the actual API and don't silently break when the code changes.

Also adds runnable, tested doc examples for all detectors.

How Has This Been Tested?

The documentation snippets are run as automated tests via the new test in
tests/test_docs/test_doc_examples.py. All tests pass locally.

Checklist

  • This Pull-Request goes to the development branch.
  • I have successfully run prek locally.
  • I have added tests to cover my changes.
  • I have linked the issue-id to the task-description.
  • I have performed a self-review of my own code.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Leokaufi
Leokaufi requested a review from ipmach July 30, 2026 13:32
Comment thread mkdocs.yml

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.

ERROR   -  Config value 'markdown_extensions': Failed to load extension 'pymdownx.snippets'.
           ModuleNotFoundError: No module named 'pymdownx'

Aborted with a configuration error!

Extension does not work locally, need to be document it to run with uv run mkdocs serve command.

Comment thread pyproject.toml

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.

Why do we need matplotlib dependency?

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.

This is not part of this PR.

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.

This is not part of this PR.

@ipmach ipmach left a comment

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.

The approach looks interesting :) . I added some formatting comments please take a look into them.

Could you also look into ways to tests that the examples work? It will interesting to have some type of automation.

For example create a unittest file with a class call TestExamples. To check if the example works, maybe you can simple add an import to check that it will not crash or use the subprocess.run method with check=True (https://docs.python.org/3/library/subprocess.html)

@Leokaufi
Leokaufi force-pushed the feat/doc-example-testing branch from 3db6ff0 to 28a1d6d Compare July 31, 2026 05:36
@Leokaufi

Copy link
Copy Markdown
Author

Thanks for the review! Addressed all your points:

  • Unrelated files removed. The new_sequence_detector files and the matplotlib dependency had slipped in from another branch — cleaned up via rebase, so the PR now contains only the doc-testing changes.
  • pymdownx error fixed. Added pymdown-extensions as a dev dependency in pyproject.toml, so uv run mkdocs build / serve now works out of the box.
  • Automated testing already in place. See tests/test_docs/test_doc_examples.py — it collects every .py under docs/examples/ via pytest parametrize and runs each with runpy.run_path, so a broken example fails its test. But if you want me to switch to your subprocess.run(check=True) suggestion; happy to do so!

@Leokaufi

Leokaufi commented Aug 4, 2026

Copy link
Copy Markdown
Author

Update: added the runnable, tested examples for all parsers as well (same pattern as the detectors).

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