[Doc] Fix %% rendering in CLI reference for --safetensors-load-strategy#46335
[Doc] Fix %% rendering in CLI reference for --safetensors-load-strategy#46335lizzzcai wants to merge 2 commits into
Conversation
|
Documentation preview: https://vllm--46335.org.readthedocs.build/en/46335/ |
The docstring is read by arg_utils.py which already escapes % to %% for argparse, so the source must contain a literal %. The stray %% was rendering as 90%%% in the generated docs. Co-authored-by: Claude Signed-off-by: Lize Cai <lize.cai@sap.com>
MarkdownFormatter.add_arguments reads action.help directly, bypassing _expand_help which would normally unescape %% -> %. arg_utils.py escapes all % to %% for argparse, so without this fix any percent sign in a docstring-derived help string renders as %% in the docs. Co-authored-by: Claude Signed-off-by: Lize Cai <lize.cai@sap.com>
dd77924 to
0b855b0
Compare
|
|
||
| if action.help: | ||
| help_dd = ":" + textwrap.indent(action.help, " ")[1:] | ||
| help_text = action.help.replace("%%", "%") |
There was a problem hiding this comment.
Why this is needed? Shall we fix the source instead of editing text directly here?
There was a problem hiding this comment.
Hi @yewentao256 Thanks for the review.
The root cause is that arg_utils.py:319 unconditionally escapes % → %% for all docstring-derived help text:
help = help.replace("%", "%%")This is needed for terminal --help because argparse's _expand_help does help % params, which collapses %% → % as a side effect:
"90%% of RAM" % {"default": None} # → "90% of RAM" But MarkdownFormatter.add_arguments bypasses _expand_help and reads action.help directly, so %% is never unescaped. This affects multiple args today — --safetensors-load-strategy, --gpu-memory-utilization, and --cp-kv-cache-interleave-size.
Two options:
Option 1 — Fix in generate_argparse.py (current approach): unescape %% → % in MarkdownFormatter. Systemic — covers all current and future docstrings with %.
Option 2 — Fix in arg_utils.py: skip escaping when running under mkdocs, since _expand_help is never called in that path:
IS_MKDOCS = (
sys.argv[0].endswith("mkdocs")
or sys.argv[0].endswith("mkdocs/__main__.py")
)
if not IS_MKDOCS:
help = help.replace("%", "%%")Happy to switch to Option 2 if preferred.
Summary
While exploring the
--safetensors-load-strategyfeature, I noticed the CLI reference docs showed90%%%%instead of90%.Root cause
arg_utils.pyescapes%→%%in docstring-derived help text for argparse.MarkdownFormatter.add_argumentsingenerate_argparse.pyreadsaction.helpdirectly, bypassing_expand_helpwhich would normally unescape%%→%. Additionally, theload.pydocstring had90%%instead of90%, causing a double-escape to90%%%%in the rendered output.Changes
vllm/config/load.py:90%%→90%in docstringdocs/mkdocs/hooks/generate_argparse.py: unescape%%→%inMarkdownFormatter.add_argumentsbefore writing markdownAs a side effect, this also fixes
--bin-byin the benchmark CLI reference which was showingrequest_throughput%%1instead of the correctrequest_throughput%1.Verification
Served docs locally with
API_AUTONAV_EXCLUDE=vllm mkdocs serveand confirmed:Notes
safetensors,generate_argparse,%%)