aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/src/contributing
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-02-28 16:28:54 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-02-28 16:35:47 +0100
commitd0d0b9a748051e1957c5ba332b9eb74112c15570 (patch)
tree3529639bbb9d78d95f4e932b60d4a93e93ea6447 /doc/manual/src/contributing
parent17f70b10bfb109dff9963adeb317ee0a5ff8563e (diff)
doc/cli-guideline: Improve examples
Turns out that the settings themselves have a bad data model anyway, so we cut that. They do still occur in the first example, but not in focus.
Diffstat (limited to 'doc/manual/src/contributing')
-rw-r--r--doc/manual/src/contributing/cli-guideline.md74
1 files changed, 29 insertions, 45 deletions
diff --git a/doc/manual/src/contributing/cli-guideline.md b/doc/manual/src/contributing/cli-guideline.md
index 3e56d9037..e53d2d178 100644
--- a/doc/manual/src/contributing/cli-guideline.md
+++ b/doc/manual/src/contributing/cli-guideline.md
@@ -425,65 +425,49 @@ This leads to the following guidelines:
### Examples
-```javascript
-// bad: all keys must be assumed to be store implementations
+
+This is bad, because all keys must be assumed to be store implementations:
+
+```json
{
"local": { ... },
"remote": { ... },
"http": { ... }
}
-// good: extensible and a little bit self-documenting.
+```
+
+This is good, because the it is extensible at the root, and is somewhat self-documenting:
+
+```json
{
"storeTypes": { "local": { ... }, ... },
- // While the dictionary of store types seemed like a complete response,
- // this little bit of info tells the consumer how to proceed if a store type
- // is missing. It's not always easy to predict how something will be used, so
- // let's keep it open.
"pluginSupport": true
}
```
-```javascript
-// bad: a store type can only hold configuration items
-{
- "storeTypes": {
- "Local Daemon Store": {
- "max-connections": {
- "defaultValue": 1
- "value": 1
- },
- "trusted": {
- "defaultValue": false,
- "value": true
- },
- ...
- }
- }
-}
-// good: a store type can be extended with other metadata, such as its URI scheme
-{
- "storeTypes": {
- "Local Daemon Store": {
- "uriScheme": "daemon",
- "settings": {
- "max-connections": {
- "defaultValue": 1
- "value": 1
- },
- ...
- },
- ...
- },
- ...
-}
-```
+While the dictionary of store types seems like a very complete response at first, a use case may arise that warrants returning additional information.
+For example, the presence of plugin support may be crucial information for a client to proceed when their desired store type is missing.
-```javascript
-// bad: not extensible
+
+
+The following representation is bad because it is not extensible:
+
+```json
{ "outputs": [ "out" "bin" ] }
-// bad: order matters but is lost, as many JSON parsers don't preserve item order.
+```
+
+However, simply converting everything to records is not enough, because the order of outputs must be preserved:
+
+```json
{ "outputs": { "bin": {}, "out": {} } }
-// good:
+```
+
+The first item is the default output. Deriving this information from the outputs ordering is not great, but this is how Nix currently happens to work.
+While it is possible for a JSON parser to preserve the order of fields, we can not rely on this capability to be present in all JSON libraries.
+
+This representation is extensible and preserves the ordering:
+
+```json
{ "outputs": [ { "outputName": "out" }, { "outputName": "bin" } ] }
```