Skip to content

Commit b756143

Browse files
committed
doc: Fix cool URIs
1 parent aa2928f commit b756143

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

doc/cool-uris.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# Do not edit manually.
33
annotated.html: []
44
classes.html: []
5+
debugging.html: []
56
deprecated.html: []
67
dir_63ce773eee1f9b680e6e312b48cc99ca.html: []
78
dir_891596f32582d3133e8915e72908625f.html: []
89
dir_d44c64559bbebec7f509842c48db8b23.html: []
910
dir_e68e8157741866f444e17edd764ebbae.html: []
11+
# TODO: wait for Doxygen upgrade
12+
# doxygen_crawl.html: []
1013
error-index.html: []
1114
files.html: []
1215
functions.html: []
@@ -33,8 +36,10 @@ group__x11.html: []
3336
index.html: []
3437
keymap-text-format-v1.html:
3538
- md_doc_keymap_format_text_v1.html
36-
md_doc_quick_guide.html: []
37-
modules.html: []
39+
md_doc_2quick-guide.html:
40+
- md_doc_quick_guide.html
41+
# TODO: wait for Doxygen upgrade
42+
# meson_options.html: []
3843
pages.html: []
3944
rule-file-format.html:
4045
- md_doc_rules_format.html
@@ -54,6 +59,8 @@ structxkb__keymap.html: []
5459
structxkb__rule__names.html: []
5560
structxkb__state.html: []
5661
todo.html: []
62+
topics.html:
63+
- modules.html
5764
user-configuration.html:
5865
- md_doc_user_configuration.html
5966
xkb-intro.html: []

scripts/ensure-stable-doc-urls.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ExitCode(IntFlag):
2828
NORMAL = 0
2929
INVALID_UPDATES = 1 << 4
3030
MISSING_UPDATES = 1 << 5
31+
NON_UNIQUE_DIRECTIONS = 1 << 6
3132

3233

3334
THIS_SCRIPT_PATH = Path(__file__)
@@ -95,21 +96,28 @@ def update_registry(registry_path: Path, doc_dir: Path, updates: Sequence[str]):
9596
"""
9697
# Parse updates
9798
updates_ = dict(map(parse_page_update, updates))
99+
# Update
100+
invalid_updates = set(updates_)
98101
# Load previous registry
99102
with registry_path.open("rt", encoding="utf-8") as fd:
100-
registry = yaml.safe_load(fd) or {}
103+
registry: dict[str, list[str]] = yaml.safe_load(fd) or {}
101104
# Expected updates
102105
missing_updates = set(file for file in registry if not (doc_dir / file).is_file())
103-
# Update
104-
invalid_updates = set(updates_)
106+
# Ensure each page is unique
107+
for d, rs in registry.items():
108+
if clashes := frozenset(rs).intersection(registry):
109+
print(
110+
f"[ERROR] The following redirections of “{d}”",
111+
f"clash with canonical directions: {clashes}",
112+
)
113+
exit(ExitCode.NON_UNIQUE_DIRECTIONS)
105114
redirections = frozenset(chain(*registry.values()))
106115
for file in glob.iglob("**/*.html", root_dir=doc_dir, recursive=True):
107116
# Skip redirection pages
108117
if file in redirections:
109118
continue
110119
# Get previous entry and potential update
111-
old = updates_.get(file)
112-
if old:
120+
if old := updates_.get(file):
113121
# Update old entry
114122
invalid_updates.remove(file)
115123
entry = registry.get(old)
@@ -137,8 +145,13 @@ def update_registry(registry_path: Path, doc_dir: Path, updates: Sequence[str]):
137145
exit_code |= ExitCode.INVALID_UPDATES
138146
if missing_updates:
139147
for old in missing_updates:
140-
print(f"[ERROR] “{old}” not found and has no update.")
141-
exit_code |= ExitCode.MISSING_UPDATES
148+
# Handle older Doxygen version
149+
if old in redirections:
150+
missing_updates.remove(old)
151+
else:
152+
print(f"[ERROR] “{old}” not found and has no update.")
153+
if missing_updates:
154+
exit_code |= ExitCode.MISSING_UPDATES
142155
if exit_code:
143156
print("[ERROR] Processing interrupted: please fix the errors above.")
144157
exit(exit_code.value)

0 commit comments

Comments
 (0)