Skip to content

Commit 5815bc9

Browse files
committed
Fix pre-commit checks
1 parent affd884 commit 5815bc9

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

.github/workflows/pre-commit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Pre-commit
44
on:
55
pull_request:
66
push:
7-
branches: [main]
7+
branches: [master]
88

99
permissions:
1010
contents: read # to fetch code (actions/checkout)

docs/api_cpp/utils.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ Calculates the number of seconds that will pass during specified number of tics.
6565
| Python | `doom_fixed_to_double(doomFixed: int | float) -> float` |
6666

6767
Converts fixed point numeral to a floating point value.
68-
Doom's engine internaly use fixed point numbers.
69-
If you read them directly from `USERX` variables,
68+
Doom's engine internally use fixed point numbers.
69+
If you read them directly from `USERX` variables,
7070
you may want to convert them to floating point numbers.
7171

7272
See also:

scripts/create_python_docs_from_cpp_docs.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55

66
FILES_TO_PARSE = [
7-
{"input_filepath": "docs/api_cpp/doomGame.md", "output_filepath": "docs/api_python/doomGame.md", "submodule": "DoomGame.",
8-
"append_to_header": """
7+
{
8+
"input_filepath": "docs/api_cpp/doomGame.md",
9+
"output_filepath": "docs/api_python/doomGame.md",
10+
"submodule": "DoomGame.",
11+
"append_to_header": """
912
```{eval-rst}
1013
.. autoclass:: vizdoom.DoomGame
1114
```
12-
"""},
13-
{"input_filepath": "docs/api_cpp/utils.md", "output_filepath": "docs/api_python/utils.md", "submodule": ""},
15+
""",
16+
},
17+
{
18+
"input_filepath": "docs/api_cpp/utils.md",
19+
"output_filepath": "docs/api_python/utils.md",
20+
"submodule": "",
21+
},
1422
]
1523
SECTION_REGEX = r"^##+ *([a-zA-Z ]+) *$"
1624
FUNCTION_REGEX = r"^###+ *`([a-zA-Z]+)` *$"
@@ -43,13 +51,15 @@
4351

4452
elif not started:
4553
start_lines += line
46-
54+
4755
else:
4856
match = re.match(FUNCTION_REGEX, line)
4957
if match:
5058
function_name = match.group(1)
5159
function_name = function_name.replace("ViZDoom", "Vizdoom")
52-
function_name = re.sub(r'(?<!^)(?=[A-Z])', '_', function_name).lower() # Convert CamelCase to snake_case
53-
output_file.write(f".. autofunction:: vizdoom.{fp['submodule']}{function_name}\n")
54-
55-
60+
function_name = re.sub(
61+
r"(?<!^)(?=[A-Z])", "_", function_name
62+
).lower() # Convert CamelCase to snake_case
63+
output_file.write(
64+
f".. autofunction:: vizdoom.{fp['submodule']}{function_name}\n"
65+
)

scripts/create_python_docstrings_from_cpp_docs.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RAW_STRING_ESCAPE_SEQ = "DOCSTRING"
1212
FUNCTION_HEADER_REGEX = r"^##+ *`([a-zA-Z]+)` *$"
1313
TO_REPLACE = [
14-
r"\[([`a-zA-Z]+)\]\(.*\)", # Links
14+
r"\[([`a-zA-Z]+)\]\(.*\)", # Links
1515
]
1616
LINES_TO_IGNORE_REGEXES = [
1717
r"---", # Lines
@@ -24,7 +24,7 @@
2424
r"^Deprecated since .*$", # Deprecated since annotations
2525
r"^Removed in .*$", # Removed in annotations
2626
r"^Config key: .*$", # Config annotations
27-
r"^Python aliases .*$", # Python aliasses
27+
r"^Python aliases .*$", # Python aliases
2828
r"^#+.*", # Other headings
2929
]
3030

@@ -80,7 +80,9 @@
8080
next_docstring += line
8181

8282
if started:
83-
output_file.write(f'{next_docstring.strip()}){RAW_STRING_ESCAPE_SEQ}";\n\n')
83+
output_file.write(
84+
f'{next_docstring.strip()}){RAW_STRING_ESCAPE_SEQ}";\n\n'
85+
)
8486

8587
if "namespace" in file:
8688
output_file.write(f"}} // namespace {file['namespace']}\n\n")

0 commit comments

Comments
 (0)