-
Notifications
You must be signed in to change notification settings - Fork 2
Add auto-generated human-readable Postman collection docs #501
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
Changes from all commits
438c120
e575f2f
c599260
2039393
65d5a43
9e90812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Generate Postman Collection Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
| - develop | ||
| paths: | ||
| - 'docker/postman/postman_collection.json' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Generate Markdown from Postman collection | ||
| run: python docker/postman/generate_collection_docs.py | ||
|
|
||
| - name: Commit generated docs | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add docker/postman/postman_collection.md | ||
| git diff --cached --quiet || git commit -m "docs: regenerate postman_collection.md" | ||
| git push |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,199 @@ | ||||||||||||||||||||||||||
| #!/usr/bin/env python3 | ||||||||||||||||||||||||||
| """Generate a human-readable Markdown document from a Postman collection JSON file.""" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| TESTRAIL_BASE_URL = "https://cae-testrail.jpl.nasa.gov/testrail/index.php?/cases/view/" | ||||||||||||||||||||||||||
| GITHUB_BASE_URL = "https://github.com/" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def extract_test_names(test_script: str) -> list[tuple[str, list[str]]]: | ||||||||||||||||||||||||||
| """Return list of (test_name, [testrail_ids]) from pm.test() calls.""" | ||||||||||||||||||||||||||
| results = [] | ||||||||||||||||||||||||||
| for match in re.finditer(r'pm\.test\(\s*["\']([^"\']+)["\']', test_script): | ||||||||||||||||||||||||||
| name = match.group(1) | ||||||||||||||||||||||||||
| ids = re.findall(r"\bC\d{5,}\b", name) | ||||||||||||||||||||||||||
| # Strip leading IDs from the display name | ||||||||||||||||||||||||||
| display = re.sub(r"^(C\d+\s+)+", "", name).strip() | ||||||||||||||||||||||||||
| results.append((display, ids)) | ||||||||||||||||||||||||||
| return results | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def extract_github_refs(name: str) -> list[str]: | ||||||||||||||||||||||||||
| """Extract GitHub issue refs like NASA-PDS/registry-api#494 from a string.""" | ||||||||||||||||||||||||||
| return re.findall(r"NASA-PDS/[\w-]+#\d+", name) | ||||||||||||||||||||||||||
|
Comment on lines
+27
to
+28
|
||||||||||||||||||||||||||
| """Extract GitHub issue refs like NASA-PDS/registry-api#494 from a string.""" | |
| return re.findall(r"NASA-PDS/[\w-]+#\d+", name) | |
| """Extract GitHub issue refs and normalize them to NASA-PDS/<repo>#<num>.""" | |
| pattern = re.compile( | |
| r"(NASA-PDS/([\w-]+)(?:#(\d+)|/#(\d+)|/issues/(\d+)))" | |
| ) | |
| refs = [] | |
| for match in pattern.finditer(name): | |
| repo = match.group(2) | |
| issue_number = match.group(3) or match.group(4) or match.group(5) | |
| refs.append(f"NASA-PDS/{repo}#{issue_number}") | |
| return refs |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_build_anchor() attempts to mimic GitHub’s duplicate-heading anchor scheme, but it starts suffixing duplicates at -2. GitHub generates #heading, then #heading-1, #heading-2, etc. If duplicate headings ever occur in the collection, the TOC links produced here will not match GitHub’s rendered anchors. Adjust the suffixing to start at 1 for the first duplicate to keep TOC links reliable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract_test_names()only detectspm.test()calls where the first argument is wrapped in single/double quotes. The current collection uses template literals (backticks) and${testrailId}interpolation (e.g.,const testrailId = "C4440539";+pm.test(`${testrailId} …`)), which results in generated docs containing literal${testrailId}strings and missing TestRail links. Consider expanding parsing to handle backtick strings and, when${testrailId}is used, extracting thetestrailIdconstant from the same script block so the correctC#######link can be emitted.