]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
2 | ||
3 | # yt-dlp --help | make_readme.py | |
4 | # This must be run in a console of correct width | |
5 | ||
dcddc10a PH |
6 | from __future__ import unicode_literals |
7 | ||
1e91866f | 8 | import io |
4bb028f4 FV |
9 | import sys |
10 | import re | |
11 | ||
682407f2 | 12 | README_FILE = 'README.md' |
4bb028f4 FV |
13 | helptext = sys.stdin.read() |
14 | ||
49f2bf76 PH |
15 | if isinstance(helptext, bytes): |
16 | helptext = helptext.decode('utf-8') | |
17 | ||
1e91866f | 18 | with io.open(README_FILE, encoding='utf-8') as f: |
682407f2 | 19 | oldreadme = f.read() |
4bb028f4 | 20 | |
c76eb41b | 21 | header = oldreadme[:oldreadme.index('## General Options:')] |
22 | footer = oldreadme[oldreadme.index('# CONFIGURATION'):] | |
4bb028f4 | 23 | |
c76eb41b | 24 | options = helptext[helptext.index(' General Options:'):] |
d19bb9c0 | 25 | options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options) |
c76eb41b | 26 | options = options + '\n' |
4bb028f4 | 27 | |
1e91866f | 28 | with io.open(README_FILE, 'w', encoding='utf-8') as f: |
682407f2 | 29 | f.write(header) |
30 | f.write(options) | |
c76eb41b | 31 | f.write(footer) |