test(docs): add unit tests for MDX helpers in create_docs.py (HYBIM-725)#63
test(docs): add unit tests for MDX helpers in create_docs.py (HYBIM-725)#63etserend wants to merge 4 commits into
Conversation
fercor-cisco
left a comment
There was a problem hiding this comment.
🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.
Verdict: approve — Tests are correct and exercise the real helpers; only a stale PR description and a lint nit remain.
General Comments
- 🟡 minor (documentation): The PR description states: "Functions are inlined in the test file (not imported from the script) to avoid a
docstring_parserdependency that is not part of the project's dev dependencies." The implementation does the opposite —tests/test_create_docs_helpers.pyimports the helpers directly fromcreate_docs(line 14), and the PR addsdocstring-parserto thetestdependency group inpyproject.toml(with the correspondingpoetry.lockchange moving it into thetestgroup). Importing the real functions is the better choice (the tests will actually catch regressions in the source), but please update the description so it matches the code — as written it would mislead a reviewer about the design.
Follow-ups
Suggested follow-up work that could be tracked as Shortcut stories:
scripts/create_docs.py:522-550:_convert_rst_code_blockstreats any line whose rstripped text ends with::as the start of a code block. Prose ending in a double colon (or a trailing::from something like a namespace reference) would be misinterpreted and stripped. The new tests don't cover this ambiguity. Consider adding a test (and, if it turns out to be a real defect, a guard in the source) for a non-code line ending in::.
fercor-cisco
left a comment
There was a problem hiding this comment.
🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.
Verdict: request_changes — Test logic is correct and matches the implementation, but the new file has lint violations (E402 already flagged, plus an unnoticed import-order I001) that will fail the ruff pre-commit hook despite the "CI green" claim.
Follow-ups
Suggested follow-up work that could be tracked as Shortcut stories:
tests/test_create_docs_helpers.py:1-162: Coverage gaps in the MDX helpers not exercised here (non-blocking): (1)_escape_curly_braceswith an unclosed/odd triple-backtick fence — there.split(r"(```.*?```)")regex leaves a dangling fence in a normal (escaped) segment; (2) inline code spans with unbalanced backticks; (3)_convert_rst_code_blockswith tab-indented (rather than 4-space) RST blocks, since the collector only recognizes lines starting with exactly four spaces; (4) a::block whose content is indented more than 4 spaces (verifying only the first 4 are stripped). Adding these would harden the helpers against real-world docstrings.
| import sys | ||
| import os | ||
|
|
||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts")) | ||
|
|
||
| from create_docs import _escape_curly_braces, _convert_rst_code_blocks, _sanitize_description |
There was a problem hiding this comment.
🟡 minor (other): Two lint issues in this import block that will fail the ruff pre-commit hook (contradicting the "CI green" claim):
-
E402 (already flagged in an existing unresolved review): the
from create_docs import ...aftersys.path.insert(...)is a module-level import not at top of file.E4is selected inpyproject.tomland E402 is not in thetests/**/*.pyignore list. It is not auto-fixable, so the hook fails.tests/conftest.pyhandles the same pattern with# noqa: E402. -
I001 (import sorting):
import sysprecedesimport os, but isort (Iis selected, not ignored for tests) wants alphabetical order (osbeforesys). This is auto-fixable, but the hook will still report a modification.
| import sys | |
| import os | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts")) | |
| from create_docs import _escape_curly_braces, _convert_rst_code_blocks, _sanitize_description | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts")) | |
| from create_docs import _escape_curly_braces, _convert_rst_code_blocks, _sanitize_description # noqa: E402 |
🤖 Generated by Astra
There was a problem hiding this comment.
🟡 minor (other): This lock file was regenerated with a newer Poetry (2.2.1 → 2.4.1), which rewrote environment markers across many packages unrelated to the intended change (charset-normalizer, distro, jiter, jsonpatch, langchain-core, openai, pyyaml, requests, tenacity, urllib3, uuid_utils, zstandard, etc.). The only intended lock change for this PR is promoting docstring-parser into the test group. Consider regenerating the lock with the same Poetry version the repo standardizes on so the diff is limited to docstring-parser; the unrelated marker churn creates merge friction and makes it hard to see the real change. Please confirm these marker rewrites are benign and expected.
🤖 Generated by Astra
… (HYBIM-725) Covers _escape_curly_braces, _convert_rst_code_blocks, and _sanitize_description — the helpers added to fix prose-only example fencing and MDX brace escaping.
…er as dev dep (HYBIM-725) Add docstring-parser to test dependencies so helpers can be imported directly from scripts/create_docs.py instead of duplicated. Add 4 new test cases: adjacent fenced blocks, mixed inline/prose braces, prose-after-block, and sanitize ordering. Add class/method docstrings to match project test style.
Documents behavior when :: appears mid-line (namespace::method) and when a prose line ends with :: but has no indented block following.
ef1b11f to
8351e1d
Compare
…dded to test group poetry.lock was stale — the >=0.17.0 constraint in [test] deps conflicted with the >=0.16,<1.0 metadata from the lockfile inherited from main. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Test plan