summary refs log tree commit diff
path: root/doc/coding-conventions.xml
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2018-11-27 22:14:41 +0100
committerGitHub <noreply@github.com>2018-11-27 22:14:41 +0100
commit064bd03b8c2faa534f3979051f5ecb267af9bc72 (patch)
treedef25da298eb70727d0e029926bd55f2b4f8b434 /doc/coding-conventions.xml
parent63c7ed978828b9561bcc22185d32f4d67c57c117 (diff)
downloadnixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar.gz
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar.bz2
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar.lz
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar.xz
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.tar.zst
nixpkgs-064bd03b8c2faa534f3979051f5ecb267af9bc72.zip
doc: tweak the coding conventions (#51113)
Encouraging to put container elements on their own lines to minimize
diffs, merge conflicts and making re-ordering easier.

Nix doesn't suffer the restrictions of other languages where commas are
used to separate list items.
Diffstat (limited to 'doc/coding-conventions.xml')
-rw-r--r--doc/coding-conventions.xml29
1 files changed, 17 insertions, 12 deletions
diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml
index 2d2018c72d2..a8a4557b461 100644
--- a/doc/coding-conventions.xml
+++ b/doc/coding-conventions.xml
@@ -56,25 +56,30 @@ foo { arg = ...; }
      or list elements should be aligned:
 <programlisting>
 # A long list.
-list =
-  [ elem1
-    elem2
-    elem3
-  ];
+list = [
+  elem1
+  elem2
+  elem3
+];
 
 # A long attribute set.
-attrs =
-  { attr1 = short_expr;
-    attr2 =
-      if true then big_expr else big_expr;
-  };
-
-# Alternatively:
 attrs = {
   attr1 = short_expr;
   attr2 =
     if true then big_expr else big_expr;
 };
+
+# Combined
+listOfAttrs = [
+  {
+    attr1 = 3;
+    attr2 = "fff";
+  }
+  {
+    attr1 = 5;
+    attr2 = "ggg";
+  }
+];
 </programlisting>
     </para>
    </listitem>