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