Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PYTHON_FILES = \
scripts/markdown_to_github_issue.py \
scripts/tests/*.py \

all: check test

check: check_python

check_python: check_ruff check_pyright

check_ruff:
uv run ruff check $(PYTHON_FILES)

check_pyright:
uv run pyright $(PYTHON_FILES)

test: test_python

test_python:
uv run pytest scripts/tests/*.py

.PHONY: all check check_python check_mypy test test_python
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ dependencies = [
"sphinx-autobuild>=2024.10.3",
"sphinx-needs>=5.1.0",
"sphinx-rtd-theme>=3.0.2",
"markdown>=3.9",
"beautifulsoup4[xml]>=4.13.5",
"lxml>=6.0.1",
"pygithub>=2.8.1",
]

[tool.uv.workspace]
Expand All @@ -30,6 +34,7 @@ lint.select = [
"TID", # Some good import practices
"C4", # Catch incorrect use of comprehensions, dict, list, etc
]

# Remove or reduce ignores to catch more issues
lint.ignore = [
"E501", # Ignore long lines, bc we use them frequently while composing .rst templates
Expand All @@ -44,6 +49,9 @@ allow-dict-calls-with-keyword-arguments = true

[dependency-groups]
dev = [
"pygithub>=2.8.1",
"pyright>=1.1.407",
"pytest>=8.4.2",
"ruff>=0.12.3",
"types-markdown>=3.9.0.20250906",
]

15 changes: 13 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### `auto-pr-helper.py`
# Scripts for automating processes around the coding guidelines

## `auto-pr-helper.py`

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.

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

#### 2. Fetching from the GitHub API directly

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.

```bash
curl https://api.github.com/repos/rustfoundation/safety-critical-rust-coding-guidelines/issues/156 | uv run ./scripts/auto-pr-helper.py
```
```

## `markdown_to_github_issue.py`

### How to use

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).
Make sure the "Issues" permission is granted as "read and write" for the token.

Pass the token to the tool via the `--auth-token` command line parameter.
Empty file added scripts/__init__.py
Empty file.
Loading