@@ -28,6 +28,7 @@ class ExitCode(IntFlag):
28
28
NORMAL = 0
29
29
INVALID_UPDATES = 1 << 4
30
30
MISSING_UPDATES = 1 << 5
31
+ NON_UNIQUE_DIRECTIONS = 1 << 6
31
32
32
33
33
34
THIS_SCRIPT_PATH = Path (__file__ )
@@ -95,21 +96,28 @@ def update_registry(registry_path: Path, doc_dir: Path, updates: Sequence[str]):
95
96
"""
96
97
# Parse updates
97
98
updates_ = dict (map (parse_page_update , updates ))
99
+ # Update
100
+ invalid_updates = set (updates_ )
98
101
# Load previous registry
99
102
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 {}
101
104
# Expected updates
102
105
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 )
105
114
redirections = frozenset (chain (* registry .values ()))
106
115
for file in glob .iglob ("**/*.html" , root_dir = doc_dir , recursive = True ):
107
116
# Skip redirection pages
108
117
if file in redirections :
109
118
continue
110
119
# Get previous entry and potential update
111
- old = updates_ .get (file )
112
- if old :
120
+ if old := updates_ .get (file ):
113
121
# Update old entry
114
122
invalid_updates .remove (file )
115
123
entry = registry .get (old )
@@ -137,8 +145,13 @@ def update_registry(registry_path: Path, doc_dir: Path, updates: Sequence[str]):
137
145
exit_code |= ExitCode .INVALID_UPDATES
138
146
if missing_updates :
139
147
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
142
155
if exit_code :
143
156
print ("[ERROR] Processing interrupted: please fix the errors above." )
144
157
exit (exit_code .value )
0 commit comments