]> jfr.im git - yt-dlp.git/blame_incremental - devscripts/make_readme.py
Merge remote-tracking branch 'petrkutalek/dvtv'
[yt-dlp.git] / devscripts / make_readme.py
... / ...
CommitLineData
1from __future__ import unicode_literals
2
3import io
4import sys
5import re
6
7README_FILE = 'README.md'
8helptext = sys.stdin.read()
9
10if isinstance(helptext, bytes):
11 helptext = helptext.decode('utf-8')
12
13with io.open(README_FILE, encoding='utf-8') as f:
14 oldreadme = f.read()
15
16header = oldreadme[:oldreadme.index('# OPTIONS')]
17footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
18
19options = helptext[helptext.index(' General Options:') + 19:]
20options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
21options = '# OPTIONS\n' + options + '\n'
22
23with io.open(README_FILE, 'w', encoding='utf-8') as f:
24 f.write(header)
25 f.write(options)
26 f.write(footer)