]> jfr.im git - yt-dlp.git/blame - devscripts/make_readme.py
Split man and README (Fixes #2892)
[yt-dlp.git] / devscripts / make_readme.py
CommitLineData
1e91866f 1import io
4bb028f4
FV
2import sys
3import re
4
682407f2 5README_FILE = 'README.md'
4bb028f4
FV
6helptext = sys.stdin.read()
7
49f2bf76
PH
8if isinstance(helptext, bytes):
9 helptext = helptext.decode('utf-8')
10
1e91866f 11with io.open(README_FILE, encoding='utf-8') as f:
682407f2 12 oldreadme = f.read()
4bb028f4
FV
13
14header = oldreadme[:oldreadme.index('# OPTIONS')]
15footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
16
49f2bf76 17options = helptext[helptext.index(' General Options:') + 19:]
d19bb9c0 18options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
4bb028f4
FV
19options = '# OPTIONS\n' + options + '\n'
20
1e91866f 21with io.open(README_FILE, 'w', encoding='utf-8') as f:
682407f2 22 f.write(header)
23 f.write(options)
24 f.write(footer)