]>
jfr.im git - yt-dlp.git/blob - devscripts/make_readme.py
3 # yt-dlp --help | make_readme.py
4 # This must be run in a console of correct width
8 README_FILE
= 'README.md'
10 OPTIONS_START
= 'General Options:'
11 OPTIONS_END
= 'CONFIGURATION'
12 EPILOG_START
= 'See full documentation'
15 helptext
= sys
.stdin
.read()
16 if isinstance(helptext
, bytes):
17 helptext
= helptext
.decode('utf-8')
19 start
, end
= helptext
.index(f
'\n {OPTIONS_START}'), helptext
.index(f
'\n{EPILOG_START}')
20 options
= re
.sub(r
'(?m)^ (\w.+)$', r
'## \1', helptext
[start
+ 1: end
+ 1])
22 with open(README_FILE
, encoding
='utf-8') as f
:
25 header
= readme
[:readme
.index(f
'## {OPTIONS_START}')]
26 footer
= readme
[readme
.index(f
'# {OPTIONS_END}'):]
28 with open(README_FILE
, 'w', encoding
='utf-8') as f
:
29 for part
in (header
, options
, footer
):