Make CLI documentation searchable: Enable search for --options #14041
optimusprimeg
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
|
@optimusprimeg happy to accept a PR. Makes sense to treat double hyphen at least as special. The single hyphen case is trickier, though. A |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Command-line options with double hyphens (like
--run,--build-dir,--async) are currently not searchable in Sphinx documentation. This affects any project documenting CLI tools.Example: Searching for
--runin documentation returns results for 'run', even when the option is documented with '--run', because:-are treated as exclusion operators--runbecomes["--", "run"]instead of staying as["--run"]Our Solution
We successfully fixed this for the KDE Builder documentation with a custom Sphinx extension that patches
searchtools.jsin three ways:\-to the word character regex--optionsfrom being treated as exclusions (only single-should be)The fix is automatic—it runs after every build via the
build-finishedhook.Benefits to Sphinx Ecosystem
This would help any project documenting command-line tools:
Implementation
We have a working implementation as a Sphinx extension (~100 lines). The extension:
Video demonstration available
Questions
preserve_hyphens_in_search = True)?Related
Happy to provide more details, share the extension code, or create a PR if there's interest!
Note: This is based on real-world usage in KDE Builder documentation where searching for options like
--build-dir,--async, and--branch-groupnow works perfectly.Beta Was this translation helpful? Give feedback.
All reactions