Conversation
Contributor
Reviewer's GuideReplaces jupyter-sphinx-based execution of usage docs with Sybil-driven doctests integrated into pytest, including custom doctest handling and a fake user package to keep audobject’s serialization and versioning behavior consistent in documentation examples. Sequence diagram for Sybil-based doctest execution via pytestsequenceDiagram
participant Pytest as pytest
participant Conftest as docs_conftest
participant SybilObj as Sybil_instance
participant SybilCol as Sybil_pytest_collect_file
participant Doctest as doctest_DocTestRunner
participant Linecache as linecache
participant MyPkg as mypkg_module
participant Audobject as audobject
Pytest->>Conftest: import conftest
Conftest->>Conftest: patch doctest.DocTestRunner.run = _run_with_linecache
Conftest->>Conftest: create _MyPkgModule and register in sys.modules
Conftest->>Conftest: patch audobject.core.utils.get_version = _patched_get_version
Conftest->>SybilObj: create Sybil(parsers, patterns, fixtures, setup=imports)
Conftest->>SybilCol: SybilObj.pytest()
Pytest->>SybilCol: pytest_collect_file(usage.rst)
SybilCol->>SybilObj: parse usage.rst with DocTestParser, PythonCodeBlockParser, SkipParser
SybilObj->>SybilCol: return pytest items for each example
loop for each example
Pytest->>SybilCol: execute example item
SybilCol->>Conftest: call imports(namespace)
Conftest->>MyPkg: _mypkg.bind_namespace(namespace)
Conftest->>SybilCol: namespace seeded with __name__=mypkg, __version__=1.0.0, audobject
SybilCol->>Doctest: run example via DocTestRunner.run
Doctest->>Doctest: _run_with_linecache(test)
Doctest->>Linecache: store example.source under <doctest name[index]>
Doctest-->>SybilCol: return doctest result
SybilCol->>Audobject: execute example code using audobject
Audobject->>MyPkg: access classes via attribute lookup
Audobject->>Audobject: audobject.core.utils.get_version(mypkg)
Audobject->>Conftest: _patched_get_version(module_name)
Conftest->>MyPkg: read __version__ from bound namespace
Conftest-->>Audobject: return version
end
Updated class diagram for doctest integration helpers and fake mypkg moduleclassDiagram
class _MyPkgModule {
- dict _namespace
+ _MyPkgModule(name)
+ bind_namespace(namespace) void
+ __getattr__(name) Any
}
class audobject_core_utils {
+ get_version(module_name) str
}
class patched_get_version {
+ _patched_get_version(module_name) str
}
class doctest_DocTestRunner {
+ run(test, *args, **kwargs) Any
}
class patched_doctest_runner {
+ _run_with_linecache(self, test, *args, **kwargs) Any
}
class Sybil {
+ Sybil(parsers, patterns, fixtures, setup)
+ pytest() callable
}
class imports_function {
+ imports(namespace) void
}
class run_in_tmpdir_fixture {
+ run_in_tmpdir(tmpdir_factory) generator
}
audobject_core_utils <|.. patched_get_version : patched
doctest_DocTestRunner <|.. patched_doctest_runner : patched
_MyPkgModule <-- imports_function : bind_namespace(namespace)
patched_get_version --> _MyPkgModule : reads _namespace and __version__
imports_function --> _MyPkgModule : sets __name__, __version__ via namespace
Sybil --> imports_function : setup=imports
Sybil --> run_in_tmpdir_fixture : uses fixture by name
class pytest_integration {
+ pytest_collect_file
}
pytest_integration --> Sybil : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Member
Author
|
@sourcery-ai review |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
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.
Replace
jupyter-sphinxwithsybilto test the usage documentation.