manual / manpages: Adjust option filter filtering, move from C++ to Nix

Behavior change:

Before we only showed uption if the command-specific options were
non-empty. But that is somewhat odd since we also show common options.
Now, we do everything based on the union of both sorts of options (with
hidden-categories filtered, as before).

Implementation change:

The JSON dumping once again includes all options; the filtering of
hidden categories is done in the Nix instead. This is better separation
of "content" vs "presentation", and prepare the way for the HTML manual
vs manpages / `--help` doing different things.
This commit is contained in:
John Ericson 2023-09-22 23:55:06 -04:00
parent 9c640c1229
commit 1d9fd3a6f8
2 changed files with 7 additions and 3 deletions

View file

@ -75,10 +75,14 @@ let
(details ? doc)
(replaceStrings ["@stores@"] [storeDocs] details.doc);
maybeOptions = optionalString (details.flags != {}) ''
maybeOptions = let
allVisibleOptions = filterAttrs
(_: o: ! o.hiddenCategory)
(details.flags // toplevel.flags);
in optionalString (allVisibleOptions != {}) ''
# Options
${showOptions (details.flags // toplevel.flags)}
${showOptions allVisibleOptions}
> **Note**
>

View file

@ -236,7 +236,7 @@ nlohmann::json Args::toJSON()
for (auto & [name, flag] : longFlags) {
auto j = nlohmann::json::object();
if (hiddenCategories.count(flag->category)) continue;
j["hiddenCategory"] = hiddenCategories.count(flag->category) > 0;
if (flag->aliases.count(name)) continue;
if (flag->shortName)
j["shortName"] = std::string(1, flag->shortName);