]> jfr.im git - yt-dlp.git/blame - devscripts/make_readme.py
[docs] Improve manpage format (#2003)
[yt-dlp.git] / devscripts / make_readme.py
CommitLineData
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
6from __future__ import unicode_literals
7
1e91866f 8import io
4bb028f4
FV
9import sys
10import re
11
682407f2 12README_FILE = 'README.md'
4bb028f4
FV
13helptext = sys.stdin.read()
14
49f2bf76
PH
15if isinstance(helptext, bytes):
16 helptext = helptext.decode('utf-8')
17
1e91866f 18with io.open(README_FILE, encoding='utf-8') as f:
682407f2 19 oldreadme = f.read()
4bb028f4 20
c76eb41b 21header = oldreadme[:oldreadme.index('## General Options:')]
22footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
4bb028f4 23
c76eb41b 24options = helptext[helptext.index(' General Options:'):]
d19bb9c0 25options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
c76eb41b 26options = options + '\n'
4bb028f4 27
1e91866f 28with io.open(README_FILE, 'w', encoding='utf-8') as f:
682407f2 29 f.write(header)
30 f.write(options)
c76eb41b 31 f.write(footer)