Skip to content

Commit df0e138

Browse files
leoheitmannruizGrub4K
authored andcommitted
[docs] Various manpage fixes
Authored by: leoheitmannruiz
1 parent 2e94602 commit df0e138

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ When using `--update`/`-U`, a release binary will only update to its current cha
158158
You may also use `--update-to <repository>` (`<owner>/<repository>`) to update to a channel on a completely different repository. Be careful with what repository you are updating to though, there is no verification done for binaries from different repositories.
159159

160160
Example usage:
161+
161162
* `yt-dlp --update-to master` switch to the `master` channel and update to its latest release
162163
* `yt-dlp --update-to stable@2023.07.06` upgrade/downgrade to release to `stable` channel tag `2023.07.06`
163164
* `yt-dlp --update-to 2023.10.07` upgrade/downgrade to tag `2023.10.07` if it exists on the current channel
@@ -1892,6 +1893,7 @@ Plugins can be installed using various methods and locations.
18921893

18931894

18941895
`.zip`, `.egg` and `.whl` archives containing a `yt_dlp_plugins` namespace folder in their root are also supported as plugin packages.
1896+
18951897
* e.g. `${XDG_CONFIG_HOME}/yt-dlp/plugins/mypluginpkg.zip` where `mypluginpkg.zip` contains `yt_dlp_plugins/<type>/myplugin.py`
18961898

18971899
Run yt-dlp with `--verbose` to check if the plugin has been loaded.

devscripts/prepare_manpage.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ def filter_excluded_sections(readme):
4343
'', readme)
4444

4545

46+
def _convert_code_blocks(readme):
47+
current_code_block = None
48+
49+
for line in readme.splitlines(True):
50+
if current_code_block:
51+
if line == current_code_block:
52+
current_code_block = None
53+
yield '\n'
54+
else:
55+
yield f' {line}'
56+
elif line.startswith('```'):
57+
current_code_block = line.count('`') * '`' + '\n'
58+
yield '\n'
59+
else:
60+
yield line
61+
62+
63+
def convert_code_blocks(readme):
64+
return ''.join(_convert_code_blocks(readme))
65+
66+
4667
def move_sections(readme):
4768
MOVE_TAG_TEMPLATE = '<!-- MANPAGE: MOVE "%s" SECTION HERE -->'
4869
sections = re.findall(r'(?m)^%s$' % (
@@ -65,8 +86,10 @@ def move_sections(readme):
6586

6687
def filter_options(readme):
6788
section = re.search(r'(?sm)^# USAGE AND OPTIONS\n.+?(?=^# )', readme).group(0)
89+
section_new = section.replace('*', R'\*')
90+
6891
options = '# OPTIONS\n'
69-
for line in section.split('\n')[1:]:
92+
for line in section_new.split('\n')[1:]:
7093
mobj = re.fullmatch(r'''(?x)
7194
\s{4}(?P<opt>-(?:,\s|[^\s])+)
7295
(?:\s(?P<meta>(?:[^\s]|\s(?!\s))+))?
@@ -86,7 +109,7 @@ def filter_options(readme):
86109
return readme.replace(section, options, 1)
87110

88111

89-
TRANSFORM = compose_functions(filter_excluded_sections, move_sections, filter_options)
112+
TRANSFORM = compose_functions(filter_excluded_sections, convert_code_blocks, move_sections, filter_options)
90113

91114

92115
def main():

0 commit comments

Comments
 (0)