-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: Add test for package readme syntax errors (#492)
Add a test to ensure readmes render properly Also adds README.rst for testutil package to pass new test. Co-authored-by: Christian Neumüller <[email protected]>
- Loading branch information
Showing
6 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,4 @@ sphinx-rtd-theme~=0.4 | |
sphinx-autodoc-typehints~=1.10.2 | ||
pytest!=5.2.3 | ||
pytest-cov>=2.8 | ||
readme-renderer~=24.0 |
This file contains 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 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,9 @@ | ||
OpenTelemetry Test Utilities | ||
============================ | ||
|
||
Test utilities for OpenTelemetry unit tests | ||
|
||
|
||
References | ||
---------- | ||
* `OpenTelemetry Project <https://opentelemetry.io/>`_ |
This file contains 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,51 @@ | ||
"""Test script to check given paths for valid README.rst files.""" | ||
import argparse | ||
import sys | ||
from pathlib import Path | ||
|
||
import readme_renderer.rst | ||
|
||
|
||
def is_valid_rst(path): | ||
"""Checks if RST can be rendered on PyPI.""" | ||
with open(path) as readme_file: | ||
markup = readme_file.read() | ||
return readme_renderer.rst.render(markup) is not None | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser( | ||
description="Checks README.rst file in path for syntax errors." | ||
) | ||
parser.add_argument( | ||
"paths", nargs="+", help="paths containing a README.rst to test" | ||
) | ||
parser.add_argument("-v", "--verbose", action="store_true") | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
error = False | ||
|
||
for path in map(Path, args.paths): | ||
readme = path / "README.rst" | ||
try: | ||
if not is_valid_rst(readme): | ||
error = True | ||
print("FAILED: RST syntax errors in", readme) | ||
continue | ||
except FileNotFoundError: | ||
error = True | ||
print("FAILED: README.rst not found in", path) | ||
continue | ||
if args.verbose: | ||
print("PASSED:", readme) | ||
|
||
if error: | ||
sys.exit(1) | ||
print("All clear.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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 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