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