Marco Ricci commited on 2025-06-14 20:07:44
Zeige 1 geänderte Dateien mit 20 Einfügungen und 21 Löschungen.
Update the man page diagnostic script to current settings: use the updated path to the man pages, and use metavars without the `!s` conversion. Additionally, since the output is currently a diagnostic on standard error, and very verbose, emit a terser shorthand notation to standard output instead. (Also sort the files to be examined first.)
| ... | ... |
@@ -31,8 +31,14 @@ def _replace_known_metavars(string: str) -> str: |
| 31 | 31 |
'{service_metavar!s}',
|
| 32 | 32 |
cli_messages.Label.VAULT_METAVAR_SERVICE.value.singular, |
| 33 | 33 |
) |
| 34 |
+ .replace( |
|
| 35 |
+ '{service_metavar}',
|
|
| 36 |
+ cli_messages.Label.VAULT_METAVAR_SERVICE.value.singular, |
|
| 37 |
+ ) |
|
| 34 | 38 |
.replace('{PROG_NAME!s}', cli_messages.PROG_NAME)
|
| 39 |
+ .replace('{PROG_NAME}', cli_messages.PROG_NAME)
|
|
| 35 | 40 |
.replace('{settings_type!s}', 'global/service-specific settings')
|
| 41 |
+ .replace('{settings_type}', 'global/service-specific settings')
|
|
| 36 | 42 |
) |
| 37 | 43 |
|
| 38 | 44 |
|
| ... | ... |
@@ -193,7 +199,11 @@ manpagedoc_documented_warnings: dict[EnumName, DiagnosticText] = {}
|
| 193 | 199 |
for set_name, globs, errors, warnings in [ |
| 194 | 200 |
( |
| 195 | 201 |
'manpages', |
| 196 |
- sorted(pathlib.Path(base, 'man').glob('derivepassphrase*.1')),
|
|
| 202 |
+ sorted( |
|
| 203 |
+ pathlib.Path(base, 'share', 'man', 'man1').glob( |
|
| 204 |
+ 'derivepassphrase*.1' |
|
| 205 |
+ ) |
|
| 206 |
+ ), |
|
| 197 | 207 |
manpage_documented_errors, |
| 198 | 208 |
manpage_documented_warnings, |
| 199 | 209 |
), |
| ... | ... |
@@ -209,23 +219,17 @@ for set_name, globs, errors, warnings in [ |
| 209 | 219 |
), |
| 210 | 220 |
]: |
| 211 | 221 |
for path in globs: |
| 212 |
- print(f'Checking manpage {path}', file=sys.stderr)
|
|
| 222 |
+ print(f'CHECK DOC {str(path.relative_to(base))!r}')
|
|
| 213 | 223 |
checker = ( |
| 214 | 224 |
_check_manpage if set_name == 'manpages' else _check_manpagedoc |
| 215 | 225 |
) |
| 216 | 226 |
for diagnostic_type, (text, name) in checker(path): |
| 217 | 227 |
if diagnostic_type == 'warning': |
| 218 | 228 |
warnings[name] = text |
| 219 |
- print( |
|
| 220 |
- f'Found warning message {name!r} with {text!r} in manpage.', # noqa: E501
|
|
| 221 |
- file=sys.stderr, |
|
| 222 |
- ) |
|
| 229 |
+ print(f'DOC WARN {name} {text!r}')
|
|
| 223 | 230 |
else: |
| 224 | 231 |
errors[name] = text |
| 225 |
- print( |
|
| 226 |
- f'Found error message {name!r} with {text!r} in manpage.',
|
|
| 227 |
- file=sys.stderr, |
|
| 228 |
- ) |
|
| 232 |
+ print(f'DOC ERR {name} {text!r}')
|
|
| 229 | 233 |
assert set(errors) >= set(known_errors), ( |
| 230 | 234 |
f"Some error messages aren't documented in the {set_name}: "
|
| 231 | 235 |
+ repr(set(known_errors) - set(errors)) |
| ... | ... |
@@ -248,27 +252,22 @@ py_file_warnings: set[EnumName] = set() |
| 248 | 252 |
match_errors_warnings = re.compile( |
| 249 | 253 |
r'\b(?:cli_messages|msg|_msg)\.(Err|Warn)MsgTemplate\.([A-Z0-9_]+)' |
| 250 | 254 |
) |
| 251 |
-for path in pathlib.Path(base, 'src', 'derivepassphrase').glob('**/*.py'):
|
|
| 255 |
+for path in sorted( |
|
| 256 |
+ pathlib.Path(base, 'src', 'derivepassphrase').glob('**/*.py')
|
|
| 257 |
+): |
|
| 252 | 258 |
if path != pathlib.Path( |
| 253 | 259 |
base, 'src', 'derivepassphrase', '_internals', 'cli_messages.py' |
| 254 | 260 |
): |
| 261 |
+ print(f'CHECK SOURCE {str(path.relative_to(base))!r}')
|
|
| 255 | 262 |
filecontents = path.read_text(encoding='UTF-8') |
| 256 | 263 |
for match in match_errors_warnings.finditer(filecontents): |
| 257 | 264 |
message_type, symbol = match.group(1, 2) |
| 258 | 265 |
if message_type == 'Err': |
| 259 | 266 |
py_file_errors.add(cast('EnumName', symbol))
|
| 260 |
- print( |
|
| 261 |
- f'Found mention of error message {symbol} '
|
|
| 262 |
- f'in source file {path!r}.',
|
|
| 263 |
- file=sys.stderr, |
|
| 264 |
- ) |
|
| 267 |
+ print(f'SOURCE ERR {symbol}')
|
|
| 265 | 268 |
elif message_type == 'Warn': |
| 266 | 269 |
py_file_warnings.add(cast('EnumName', symbol))
|
| 267 |
- print( |
|
| 268 |
- f'Found mention of warning message {symbol} '
|
|
| 269 |
- f'in source file {path!r}.',
|
|
| 270 |
- file=sys.stderr, |
|
| 271 |
- ) |
|
| 270 |
+ print(f'SOURCE WARN {symbol}')
|
|
| 272 | 271 |
if py_file_errors != set(known_errors): |
| 273 | 272 |
print( |
| 274 | 273 |
"Some error messages aren't in use: " |
| 275 | 274 |