aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorThéophane Hufschmitt <regnat@users.noreply.github.com>2021-12-14 09:14:25 +0100
committerGitHub <noreply@github.com>2021-12-14 09:14:25 +0100
commit6234e1c8115b876bcb01337952def1e1f23ffc69 (patch)
tree1d2528813d3c45f279cc0801c4645ad8708879fc /src/libutil
parent3fc8042f77d488d3ebc9b3aefb3c54cec38fa432 (diff)
parent21520297dad8a198004e4551808a4818a8de7ddd (diff)
Merge pull request #5702 from baloo/baloo/hide-non-reproducible-settings
reproducibility: hide non-reproducible settings from manual
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/abstract-setting-to-json.hh1
-rw-r--r--src/libutil/config.hh10
-rw-r--r--src/libutil/tests/config.cc2
3 files changed, 9 insertions, 4 deletions
diff --git a/src/libutil/abstract-setting-to-json.hh b/src/libutil/abstract-setting-to-json.hh
index b3fbc84f7..2d82b54e7 100644
--- a/src/libutil/abstract-setting-to-json.hh
+++ b/src/libutil/abstract-setting-to-json.hh
@@ -10,6 +10,7 @@ std::map<std::string, nlohmann::json> BaseSetting<T>::toJSONObject()
auto obj = AbstractSetting::toJSONObject();
obj.emplace("value", value);
obj.emplace("defaultValue", defaultValue);
+ obj.emplace("documentDefault", documentDefault);
return obj;
}
}
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index 736810bf3..79ec0f9cf 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -232,16 +232,19 @@ protected:
T value;
const T defaultValue;
+ const bool documentDefault;
public:
BaseSetting(const T & def,
+ const bool documentDefault,
const std::string & name,
const std::string & description,
const std::set<std::string> & aliases = {})
: AbstractSetting(name, description, aliases)
, value(def)
, defaultValue(def)
+ , documentDefault(documentDefault)
{ }
operator const T &() const { return value; }
@@ -288,8 +291,9 @@ public:
const T & def,
const std::string & name,
const std::string & description,
- const std::set<std::string> & aliases = {})
- : BaseSetting<T>(def, name, description, aliases)
+ const std::set<std::string> & aliases = {},
+ const bool documentDefault = true)
+ : BaseSetting<T>(def, documentDefault, name, description, aliases)
{
options->addSetting(this);
}
@@ -311,7 +315,7 @@ public:
const std::string & name,
const std::string & description,
const std::set<std::string> & aliases = {})
- : BaseSetting<Path>(def, name, description, aliases)
+ : BaseSetting<Path>(def, true, name, description, aliases)
, allowEmpty(allowEmpty)
{
options->addSetting(this);
diff --git a/src/libutil/tests/config.cc b/src/libutil/tests/config.cc
index 0ebdaf3db..8be6730dd 100644
--- a/src/libutil/tests/config.cc
+++ b/src/libutil/tests/config.cc
@@ -161,7 +161,7 @@ namespace nix {
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
setting.assign("value");
- ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"defaultValue":"","description":"description\n","value":"value"}})#");
+ ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"defaultValue":"","description":"description\n","documentDefault":true,"value":"value"}})#");
}
TEST(Config, setSettingAlias) {