From dcab5eb11b8b018bb296475c24e5716a2ac415ca Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 22 May 2020 17:12:51 +0200 Subject: [PATCH] src2asciidoc: Make sure usage lines are generated with fixed width Due to a change in Python 3.8, the output depended on the calling terminal's width. Set a fixed with of 200 (rather than 80) so that we always have the expanded version for the generated documentation. See #5393 and https://github.com/python/cpython/commit/74102c9a5f2327c4fc47feefa072854a53551d1f#diff-837b312b1f3508216ace6adb46492836 --- doc/help/commands.asciidoc | 17 +++++------------ scripts/dev/src2asciidoc.py | 5 +++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 565b87ac8..3266c7153 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -285,8 +285,7 @@ Set all settings back to their default. [[config-cycle]] === config-cycle -Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] - 'option' ['values' ['values' ...]]+ +Syntax: +:config-cycle [*--pattern* 'pattern'] [*--temp*] [*--print*] 'option' ['values' ['values' ...]]+ Cycle an option between multiple values. @@ -597,8 +596,7 @@ Show help about a command or setting. [[hint]] === hint -Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] - ['group'] ['target'] ['args' ['args' ...]]+ +Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] [*--first*] ['group'] ['target'] ['args' ['args' ...]]+ Start hinting. @@ -855,8 +853,7 @@ Do nothing. [[open]] === open -Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] - ['url']+ +Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] ['url']+ Open a URL in the current/[count]th tab. @@ -1186,9 +1183,7 @@ Load a session. [[session-save]] === session-save -Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] - [*--with-private*] - ['name']+ +Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] [*--with-private*] ['name']+ Save a session. @@ -1252,9 +1247,7 @@ Set a mark at the current scroll position in the current tab. [[spawn]] === spawn -Syntax: +:spawn [*--userscript*] [*--verbose*] [*--output*] [*--output-messages*] - [*--detach*] - 'cmdline'+ +Syntax: +:spawn [*--userscript*] [*--verbose*] [*--output*] [*--output-messages*] [*--detach*] 'cmdline'+ Spawn an external command. diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index b82ede3e1..1d3ad8bf4 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -59,6 +59,11 @@ class UsageFormatter(argparse.HelpFormatter): argparse.HelpFormatter while copying 99% of the code :-/ """ + def __init__(self, prog, indent_increment=2, max_help_position=24, + width=200): + """Override __init__ to set a fixed width as default.""" + super().__init__(prog, indent_increment, max_help_position, width) + def _format_usage(self, usage, actions, groups, _prefix): """Override _format_usage to not add the 'usage:' prefix.""" return super()._format_usage(usage, actions, groups, '')