|
19 | 19 | CONTENT_DIR = "content" |
20 | 20 | SITE_DIR = "site" |
21 | 21 |
|
22 | | -CATEGORY_DISPLAY = { |
23 | | - "language": "Language", |
24 | | - "collections": "Collections", |
25 | | - "strings": "Strings", |
26 | | - "streams": "Streams", |
27 | | - "concurrency": "Concurrency", |
28 | | - "io": "I/O", |
29 | | - "errors": "Errors", |
30 | | - "datetime": "Date/Time", |
31 | | - "security": "Security", |
32 | | - "tooling": "Tooling", |
33 | | - "enterprise": "Enterprise", |
34 | | -} |
| 22 | +CATEGORIES_FILE = "html-generators/categories.properties" |
| 23 | + |
| 24 | + |
| 25 | +def load_category_display(): |
| 26 | + """Load category display names from the properties file.""" |
| 27 | + categories = {} |
| 28 | + with open(CATEGORIES_FILE) as f: |
| 29 | + for line in f: |
| 30 | + line = line.strip() |
| 31 | + if not line or line.startswith('#'): |
| 32 | + continue |
| 33 | + key, sep, value = line.partition('=') |
| 34 | + key, value = key.strip(), value.strip() |
| 35 | + if sep and key: |
| 36 | + categories[key] = value |
| 37 | + return categories |
| 38 | + |
| 39 | + |
| 40 | +CATEGORY_DISPLAY = load_category_display() |
35 | 41 |
|
36 | 42 |
|
37 | 43 | def escape(text): |
@@ -65,12 +71,8 @@ def load_template(): |
65 | 71 | def load_all_snippets(): |
66 | 72 | """Load all JSON snippet files, keyed by category/slug.""" |
67 | 73 | snippets = {} |
68 | | - categories = [ |
69 | | - "language", "collections", "strings", "streams", "concurrency", |
70 | | - "io", "errors", "datetime", "security", "tooling", "enterprise", |
71 | | - ] |
72 | 74 | json_files = [] |
73 | | - for cat in categories: |
| 75 | + for cat in CATEGORY_DISPLAY: |
74 | 76 | json_files.extend(sorted(glob.glob(f"{CONTENT_DIR}/{cat}/*.json"))) |
75 | 77 | for path in json_files: |
76 | 78 | with open(path) as f: |
|
0 commit comments