Skip to content

Commit 45a037f

Browse files
committed
[make] Allow for multiple categories in Makefile
1 parent caa1e17 commit 45a037f

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

tools/make/common.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2023, Niklas Hauser
22
# SPDX-License-Identifier: MPL-2.0
33

4-
### @Utils Utilities \1000
4+
### @Utils Utilities \1010
55

66
log/%:
77
@mkdir -p $@
@@ -34,7 +34,7 @@ venv:
3434
$(MAKE) pip-install-frozen
3535

3636
.PHONY: clean-venv
37-
# Remove the virtual environment
37+
## Remove the virtual environment
3838
clean-venv:
3939
@rm -rf .venv
4040

@@ -55,13 +55,13 @@ build-homepage:
5555
serve-api-docs:
5656
@pdoc --mermaid modm_data
5757

58-
58+
### @Tests Testing \1009
5959
# ================================== Testing ==================================
6060
ext/test/regression/:
6161
@git clone --depth=1 [email protected]:modm-ext/modm-data-test-docs.git $@
6262

6363
.PHONY: run-regression-tests
64-
## Convert some PDF pages and check against their known HTML.
64+
## @Tests Convert some PDF pages and check against their known HTML.
6565
run-regression-tests: ext/test/regression/
6666
@test/convert_html.sh
6767
@git diff --exit-code -- test/data/html

tools/scripts/makefile_help.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ def parse_makefiles(makefiles: list[str]):
1414
for path in makefiles:
1515
content = Path(path).read_text()
1616
fcategory = "General"
17-
if (cdoc := re.search(r"### *@([\w-]+) *(.*?) *\\(\d+)\n", content)):
18-
fcategory = cdoc.group(1)
19-
cdocs[fcategory] = (cdoc.group(2), int(cdoc.group(3) or 0))
20-
21-
rawdocs = re.findall(r"((?:##.+\n)+)(.+):", content, flags=re.MULTILINE)
22-
for doc, rule in rawdocs:
23-
doc = doc.replace("##", "")
24-
if (category := re.search(r"@([\w-]+)", doc)):
25-
doc = doc.replace(category.group(0), "")
26-
category = category.group(1)
27-
else:
28-
category = fcategory
29-
docs[category][rule] = [l.strip() for l in doc.splitlines()]
17+
for groupcontent in re.split(r"### *@", content):
18+
if (cdoc := re.search(r"^([\w-]+) *(.*?) *\\(\d+)\n", groupcontent)):
19+
fcategory = cdoc.group(1)
20+
cdocs[fcategory] = (cdoc.group(2), int(cdoc.group(3) or 0))
21+
22+
rawdocs = re.findall(r"((?:##.+\n)+)(.+):", groupcontent, flags=re.MULTILINE)
23+
for doc, rule in rawdocs:
24+
doc = doc.replace("##", "")
25+
if (category := re.search(r"@([\w-]+)", doc)):
26+
doc = doc.replace(category.group(0), "")
27+
category = category.group(1)
28+
else:
29+
category = fcategory
30+
docs[category][rule] = [l.strip() for l in doc.splitlines()]
3031

3132
return dict(docs), cdocs
3233

0 commit comments

Comments
 (0)