summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrelease/update-manpages22
1 files changed, 17 insertions, 5 deletions
diff --git a/release/update-manpages b/release/update-manpages
index 6ef3ec11..ddbce0cc 100755
--- a/release/update-manpages
+++ b/release/update-manpages
@@ -59,11 +59,11 @@ def main(argv):
59 version = RepoSourceVersion() 59 version = RepoSourceVersion()
60 cmdlist = [['help2man', '-N', '-n', f'repo {cmd} - manual page for repo {cmd}', 60 cmdlist = [['help2man', '-N', '-n', f'repo {cmd} - manual page for repo {cmd}',
61 '-S', f'repo {cmd}', '-m', 'Repo Manual', f'--version-string={version}', 61 '-S', f'repo {cmd}', '-m', 'Repo Manual', f'--version-string={version}',
62 '-o', MANDIR.joinpath(f'repo-{cmd}.1'), TOPDIR.joinpath('repo'), 62 '-o', MANDIR.joinpath(f'repo-{cmd}.1.tmp'), TOPDIR.joinpath('repo'),
63 '-h', f'help {cmd}'] for cmd in subcmds.all_commands] 63 '-h', f'help {cmd}'] for cmd in subcmds.all_commands]
64 cmdlist.append(['help2man', '-N', '-n', 'repository management tool built on top of git', 64 cmdlist.append(['help2man', '-N', '-n', 'repository management tool built on top of git',
65 '-S', 'repo', '-m', 'Repo Manual', f'--version-string={version}', 65 '-S', 'repo', '-m', 'Repo Manual', f'--version-string={version}',
66 '-o', MANDIR.joinpath('repo.1'), TOPDIR.joinpath('repo'), 66 '-o', MANDIR.joinpath('repo.1.tmp'), TOPDIR.joinpath('repo'),
67 '-h', '--help-all']) 67 '-h', '--help-all'])
68 68
69 with tempfile.TemporaryDirectory() as tempdir: 69 with tempfile.TemporaryDirectory() as tempdir:
@@ -80,11 +80,23 @@ def main(argv):
80 (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'), 80 (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'),
81 (r'^\.PP\nDescription', '.SH DETAILS'), 81 (r'^\.PP\nDescription', '.SH DETAILS'),
82 ) 82 )
83 for path in MANDIR.glob('*.1'): 83 for tmp_path in MANDIR.glob('*.1.tmp'):
84 data = path.read_text() 84 path = tmp_path.parent / tmp_path.stem
85 old_data = path.read_text() if path.exists() else ''
86
87 data = tmp_path.read_text()
88 tmp_path.unlink()
89
85 for pattern, replacement in regex: 90 for pattern, replacement in regex:
86 data = re.sub(pattern, replacement, data, flags=re.M) 91 data = re.sub(pattern, replacement, data, flags=re.M)
87 path.write_text(data) 92
93 # If the only thing that changed was the date, don't refresh. This avoids
94 # a lot of noise when only one file actually updates.
95 old_data = re.sub(r'^(\.TH REPO "1" ")([^"]+)', r'\1', old_data, flags=re.M)
96 new_data = re.sub(r'^(\.TH REPO "1" ")([^"]+)', r'\1', data, flags=re.M)
97 if old_data != new_data:
98 path.write_text(data)
99
88 100
89if __name__ == '__main__': 101if __name__ == '__main__':
90 sys.exit(main(sys.argv[1:])) 102 sys.exit(main(sys.argv[1:]))