diff options
Diffstat (limited to 'release')
-rwxr-xr-x | release/update-manpages | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/release/update-manpages b/release/update-manpages index d619cf0b..739cedb1 100755 --- a/release/update-manpages +++ b/release/update-manpages | |||
@@ -83,11 +83,6 @@ def main(argv): | |||
83 | with multiprocessing.Pool() as pool: | 83 | with multiprocessing.Pool() as pool: |
84 | pool.map(partial(worker, cwd=tempdir, check=True), cmdlist) | 84 | pool.map(partial(worker, cwd=tempdir, check=True), cmdlist) |
85 | 85 | ||
86 | regex = ( | ||
87 | (r'(It was generated by help2man) [0-9.]+', '\g<1>.'), | ||
88 | (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'), | ||
89 | (r'^\.PP\nDescription', '.SH DETAILS'), | ||
90 | ) | ||
91 | for tmp_path in MANDIR.glob('*.1.tmp'): | 86 | for tmp_path in MANDIR.glob('*.1.tmp'): |
92 | path = tmp_path.parent / tmp_path.stem | 87 | path = tmp_path.parent / tmp_path.stem |
93 | old_data = path.read_text() if path.exists() else '' | 88 | old_data = path.read_text() if path.exists() else '' |
@@ -95,8 +90,7 @@ def main(argv): | |||
95 | data = tmp_path.read_text() | 90 | data = tmp_path.read_text() |
96 | tmp_path.unlink() | 91 | tmp_path.unlink() |
97 | 92 | ||
98 | for pattern, replacement in regex: | 93 | data = replace_regex(data) |
99 | data = re.sub(pattern, replacement, data, flags=re.M) | ||
100 | 94 | ||
101 | # If the only thing that changed was the date, don't refresh. This avoids | 95 | # If the only thing that changed was the date, don't refresh. This avoids |
102 | # a lot of noise when only one file actually updates. | 96 | # a lot of noise when only one file actually updates. |
@@ -106,5 +100,25 @@ def main(argv): | |||
106 | path.write_text(data) | 100 | path.write_text(data) |
107 | 101 | ||
108 | 102 | ||
103 | def replace_regex(data): | ||
104 | """Replace semantically null regexes in the data. | ||
105 | |||
106 | Args: | ||
107 | data: manpage text. | ||
108 | |||
109 | Returns: | ||
110 | Updated manpage text. | ||
111 | """ | ||
112 | regex = ( | ||
113 | (r'(It was generated by help2man) [0-9.]+', '\g<1>.'), | ||
114 | (r'^\033\[[0-9;]*m([^\033]*)\033\[m', '\g<1>'), | ||
115 | (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'), | ||
116 | (r'^\.PP\nDescription', '.SH DETAILS'), | ||
117 | ) | ||
118 | for pattern, replacement in regex: | ||
119 | data = re.sub(pattern, replacement, data, flags=re.M) | ||
120 | return data | ||
121 | |||
122 | |||
109 | if __name__ == '__main__': | 123 | if __name__ == '__main__': |
110 | sys.exit(main(sys.argv[1:])) | 124 | sys.exit(main(sys.argv[1:])) |