Skip to content

Commit 635e124

Browse files
committed
Changes to the build scripts
1 parent c459137 commit 635e124

File tree

6 files changed

+69
-13
lines changed

6 files changed

+69
-13
lines changed

.scripts/acronyms.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"AI": "Artificial Intelligence",
3+
"API": "Application Programming Interface",
4+
"CI": "Continuous Integration",
5+
"CD": "Continuous Delivery",
6+
"CPU": "Central Processing Unit",
7+
"CSS": "Cascading Style Sheets",
8+
"DB": "Database",
9+
"DBMS": "Database Management System",
10+
"DNS": "Domain Name System",
11+
"DOM": "Document Object Model",
12+
"DRY": "Don't Repeat Yourself",
13+
"FTP": "File Transfer Protocol",
14+
"FOSS": "Free and Open Source Software",
15+
"GPU": "Graphics Processing Unit",
16+
"GUI": "Graphical User Interface",
17+
"HTML": "HyperText Markup Language",
18+
"HTTP": "HyperText Transfer Protocol",
19+
"IDE": "Integrated Development Environment",
20+
"I/O": "Input/Output",
21+
"IP": "Internet Protocol",
22+
"JSON": "JavaScript Object Notation",
23+
"MVC": "Model View Controller",
24+
"OOP": "Object Oriented Programming",
25+
"ORM": "Object Relational Mapping",
26+
"OS": "Operating System",
27+
"RAM": "Random Access Memory",
28+
"REST": "Representational State Transfer",
29+
"SOLID": "Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion",
30+
"SDK": "Software Development Kit",
31+
"SQL": "Structured Query Language",
32+
"UI": "User Interface",
33+
"URL": "Uniform Resource Locator",
34+
"UX": "User Experience",
35+
"VM": "Virtual Machine",
36+
"XML": "eXtensible Markup Language"
37+
}

.scripts/gen_markdown_chapters.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,46 @@
1414
"""
1515

1616
import argparse
17+
import json
1718
import re
1819
from pathlib import Path
1920

20-
21-
2221
def to_title(name: str) -> str:
2322
"""Return *name* in title format with spaces and preserved acronyms."""
23+
2424
# Remove numeric prefixes like ``01_``
2525
name = re.sub(r"^\d+[_-]?", "", name)
26+
27+
# Split on underscores, dashes, or spaces
2628
parts = re.split(r"[_\-\s]+", name)
29+
30+
# Import JSON file containing user-defined acronyms
31+
with open('acronyms.json') as json_data:
32+
user_acronyms = json.load(json_data)
33+
34+
# Capitalize each part, preserving all-uppercase acronyms
2735
words = []
2836
for part in parts:
37+
38+
print(part)
39+
40+
# Skip empty parts that may result from leading/trailing separators
2941
if not part:
3042
continue
31-
if re.fullmatch(r"[A-Z0-9]+", part):
32-
words.append(part)
33-
elif re.fullmatch(r"[a-z]+", part) and len(part) <= 4:
43+
44+
# Check user-defined acronyms from `docs/acronyms.txt`
45+
if part.upper() in user_acronyms:
3446
words.append(part.upper())
47+
48+
# If the part is all uppercase and contains only alphanumeric characters,
49+
# treat it as an acronym and keep it as is
50+
elif re.fullmatch(r"[A-Z0-9]+", part):
51+
words.append(part)
52+
53+
# Otherwise, capitalize the first letter and lowercase the rest
3554
else:
3655
words.append(part.capitalize())
56+
3757
return " ".join(words)
3858

3959

@@ -83,7 +103,7 @@ def main() -> None:
83103
)
84104
parser.add_argument(
85105
"--output-dir",
86-
default="../docs",
106+
default="../docs/examples",
87107
help="Directory where Markdown files will be written",
88108
)
89109
args = parser.parse_args()

.scripts/gen_markdown_pages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ def main() -> None:
5454
)
5555
parser.add_argument(
5656
"--examples-dir",
57-
default="examples",
57+
default="../examples",
5858
help="Directory containing example .py files",
5959
)
6060
parser.add_argument(
6161
"--template",
62-
default="templates/example_file.mustache",
62+
default="../templates/example_file.mustache",
6363
help="Mustache template file",
6464
)
6565
parser.add_argument(
6666
"--output-dir",
67-
default="docs",
67+
default="../docs",
6868
help="Directory where Markdown files will be written",
6969
)
7070
args = parser.parse_args()

.scripts/gen_single_markdown.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ def main() -> None:
5757
parser = argparse.ArgumentParser(description="Generate examples markdown")
5858
parser.add_argument(
5959
"--examples-dir",
60-
default="examples",
60+
default="../examples",
6161
help="Directory containing example .py files",
6262
)
6363
parser.add_argument(
6464
"--template",
65-
default="templates/examples_page.mustache",
65+
default="../templates/examples_page.mustache",
6666
help="Mustache template file",
6767
)
6868
parser.add_argument(
6969
"--output",
70-
default="examples.md",
70+
default="../docs/examples.md",
7171
help="Output markdown file",
7272
)
7373
args = parser.parse_args()

docs/.pages

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)