1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00

Assemble experimental feature docs outside of Nix itself

Instead of constructing a markdown list in C++ (which involved all sorts
of nasty string literals), export some JSON and assemble it with the
manual build system.

Besides following the precedent set with other dumped data, this is a
better separate of content and presentation; if we decide for example we
want to display this information in a different way, or in a different
section of the manual, it will become much easier to do so.
This commit is contained in:
John Ericson 2023-04-04 22:57:11 -04:00
parent 3f98353f19
commit 53d0836347
8 changed files with 55 additions and 37 deletions

View file

@ -140,32 +140,12 @@ std::string_view showExperimentalFeature(const ExperimentalFeature tag)
return xpFeatureDetails[(size_t)tag].name;
}
std::string getExperimentalFeaturesList() {
std::string experimentalFeaturesList = R"(
Experimental features that can be enabled.
Example:
```
experimental-features = nix-command flakes
Experimental features available:
)";
for (auto & xpFeature : xpFeatureDetails) {
experimentalFeaturesList += std::string {}
/* length of this first string must be 12, matching the indent of
the descriptions in the xpFeatureDetails literal. FIXME compute
markdown in a less hacky way. */
+ " - "
+ "`" + xpFeature.name + "`"
+ "\n"
+ xpFeature.description
+ "\n\n";
}
return experimentalFeaturesList;
nlohmann::json documentExperimentalFeatures() {
StringMap res;
for (auto & xpFeature : xpFeatureDetails)
res[std::string { xpFeature.name }] =
trim(stripIndentation(xpFeature.description));
return (nlohmann::json) res;
}
std::set<ExperimentalFeature> parseFeatures(const std::set<std::string> & rawFeatures)