-
Notifications
You must be signed in to change notification settings - Fork 899
Docs scripting fixing #9729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
oharboe
wants to merge
17
commits into
The-OpenROAD-Project:master
from
Pinata-Consulting:docs-scripting-fixing
Closed
Docs scripting fixing #9729
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6c1ed57
docs: apply black formatting to md_roff_compat.py
oharboe 1109a51
docs: replace cryptic assert with descriptive ValueError in md_roff_c…
oharboe 831b342
docs: replace bare exit() with ValueError in man3_translate
oharboe cc916d1
docs: replace assert with ValueError in extract_headers
oharboe 117f1ea
docs: open files with explicit utf-8 encoding in md_roff_compat
oharboe 23f83e9
docs: fix silent str.find('#') == -1 in extract_arguments
oharboe 5187aec
docs: guard against empty candidate list in extract_arguments
oharboe ad58f5e
docs: avoid O(n^2) string concatenation in extract_global_examples
oharboe dfd0703
docs: add pytest unit tests for extract_utils and md_roff_compat
oharboe 75d6bbf
docs: wire pytest into Makefile and requirements
oharboe ce6905e
docs: document test suite purpose and CI integration in TESTING.md
oharboe 8cbb148
docs: run unit tests before preprocess in Makefile
oharboe beedbf8
docs: update TESTING.md to reflect preprocess -> test dependency
oharboe f5c2f74
docs: ignore pytest .coverage files
oharboe 01be158
docs: remove redundant dict comprehension in error message
oharboe 09d266c
docs: guard extract_arguments against empty level-3 header list
oharboe 894b8bc
docs: reformat md_roff_compat.py with black 26.x
oharboe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,5 @@ cat | |
|
|
||
| # for doc tests | ||
| src/test/results | ||
| .coverage | ||
| src/test/.coverage | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [pytest] | ||
| testpaths = src/test | ||
| python_files = test_*.py | ||
| addopts = --cov=src/scripts --cov-report=term-missing |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Documentation Script Tests | ||
|
|
||
| Unit tests for the Python scripts that convert module `README.md` files | ||
| into man-page markdown (`md_roff_compat.py`, `extract_utils.py`). | ||
|
|
||
| ## What is tested | ||
|
|
||
| | Test file | Covers | | ||
| | --------- | ------ | | ||
| | `test_extract_utils.py` | `extract_headers`, `extract_tcl_command`, `extract_tcl_code`, `extract_description`, `extract_arguments`, `extract_tables`, `parse_switch`, `check_function_signatures` | | ||
| | `test_md_roff_compat.py` | `man2_translate` (valid input, count mismatch, error message content), `man3_translate` (valid input, `with-total` guard, per-line write calls) | | ||
|
|
||
| `man2_translate` and `man3_translate` use `unittest.mock` to replace | ||
| `ManPage.write_roff_file` where needed, so no files outside `tmp_path` | ||
| are written. The full suite runs in under 0.1 s. | ||
|
|
||
| ## Running locally | ||
|
|
||
| ```bash | ||
| # from the docs/ directory | ||
| pip install pytest pytest-cov # once; already in requirements.txt | ||
| make test | ||
| ``` | ||
|
|
||
| Or directly: | ||
|
|
||
| ```bash | ||
| cd docs/src/test | ||
| python3 -m pytest test_extract_utils.py test_md_roff_compat.py -v \ | ||
| --cov=../scripts --cov-report=term-missing | ||
| ``` | ||
|
|
||
| ## CI integration | ||
|
|
||
| The `preprocess` target (called by Jenkins as `make preprocess -C docs`) | ||
| runs the integration-level check: it links all module READMEs and runs | ||
| `md_roff_compat.py` over every one of them, raising `ValueError` on any | ||
| structural mismatch. | ||
|
|
||
| The unit tests run automatically before the integration check because | ||
| `preprocess` depends on `test` in the Makefile: | ||
|
|
||
| ```makefile | ||
| preprocess: test | ||
| ./src/scripts/link_readmes.sh && python3 src/scripts/md_roff_compat.py | ||
| ``` | ||
|
|
||
| Any CI step calling `make preprocess -C docs` will run the unit tests | ||
| first. A broken parser fails fast before attempting to generate man-pages. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ## SPDX-License-Identifier: BSD-3-Clause | ||
| ## Copyright (c) 2024-2026, The OpenROAD Authors | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
| # Make the symlinked scripts importable when pytest is invoked from any directory. | ||
| sys.path.insert(0, os.path.dirname(__file__)) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.