Skip to content

Commit 7c45e3f

Browse files
committed
Implement MISRA importer and issue exporter
1 parent 737a09e commit 7c45e3f

File tree

11 files changed

+1237
-174
lines changed

11 files changed

+1237
-174
lines changed

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PYTHON_FILES = \
2+
scripts/markdown_to_github_issue.py \
3+
scripts/tests/*.py \
4+
5+
all: check test
6+
7+
check: check_python
8+
9+
check_python: check_ruff check_pyright
10+
11+
check_ruff:
12+
uv run ruff check $(PYTHON_FILES)
13+
14+
check_pyright:
15+
uv run pyright $(PYTHON_FILES)
16+
17+
test: test_python
18+
19+
test_python:
20+
uv run pytest scripts/tests/*.py
21+
22+
.PHONY: all check check_python check_mypy test test_python

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ dependencies = [
1212
"sphinx-autobuild>=2024.10.3",
1313
"sphinx-needs>=5.1.0",
1414
"sphinx-rtd-theme>=3.0.2",
15+
"markdown>=3.9",
16+
"beautifulsoup4[xml]>=4.13.5",
17+
"lxml>=6.0.1",
18+
"pygithub>=2.8.1",
1519
]
1620

1721
[tool.uv.workspace]
@@ -30,6 +34,7 @@ lint.select = [
3034
"TID", # Some good import practices
3135
"C4", # Catch incorrect use of comprehensions, dict, list, etc
3236
]
37+
3338
# Remove or reduce ignores to catch more issues
3439
lint.ignore = [
3540
"E501", # Ignore long lines, bc we use them frequently while composing .rst templates
@@ -44,6 +49,9 @@ allow-dict-calls-with-keyword-arguments = true
4449

4550
[dependency-groups]
4651
dev = [
52+
"pygithub>=2.8.1",
53+
"pyright>=1.1.407",
54+
"pytest>=8.4.2",
4755
"ruff>=0.12.3",
56+
"types-markdown>=3.9.0.20250906",
4857
]
49-

scripts/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
### `auto-pr-helper.py`
1+
# Scripts for automating processes around the coding guidelines
2+
3+
## `auto-pr-helper.py`
24

35
This script is a utility for automating the generation of guidelines. It takes a GitHub issue's JSON data from standard input, parses its body (which is expected to follow a specific issue template), and converts it into a formatted reStructuredText (`.rst`) guideline.
46

@@ -17,9 +19,18 @@ cat path/to/your_issue.json | uv run scripts/auto-pr-helper.py
1719
```
1820

1921
#### 2. Fetching from the GitHub API directly
22+
2023
You can fetch the data for a live issue directly from the GitHub API using curl and pipe it to the script. This is useful for getting the most up-to-date content.
2124

2225
```bash
2326
curl https://api.github.com/repos/rustfoundation/safety-critical-rust-coding-guidelines/issues/156 | uv run ./scripts/auto-pr-helper.py
2427
```
25-
```
28+
29+
## `markdown_to_github_issue.py`
30+
31+
### How to use
32+
33+
You need to create a personal access token for the target repository as [described here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).
34+
Make sure the "Issues" permission is granted as "read and write" for the token.
35+
36+
Pass the token to the tool via the `--auth-token` command line parameter.

scripts/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)