manual: reworked submodule section for better readability

The section was strange to read, as the initial example already used
`listOf' which is mentioned in the very first paragraph. Then you read
in a subsection about `listOf' and the exact same example is given
once again.

authored by Thomas Bach and committed by Domen Kožar 4d101993 f37a1e15

+30 -29
+30 -29
nixos/doc/manual/development/option-types.xml
··· 157 158 <section xml:id='section-option-types-submodule'><title>Submodule</title> 159 160 - <para>Submodule is a very powerful type that defines a set of sub-options that 161 - are handled like a separate module. 162 - It is especially interesting when used with composed types like 163 - <literal>attrsOf</literal> or <literal>listOf</literal>.</para> 164 165 - <para>The submodule type take a parameter <replaceable>o</replaceable>, that 166 - should be a set, or a function returning a set with an 167 - <literal>options</literal> key defining the sub-options. 168 - The option set can be defined directly (<xref linkend='ex-submodule-direct' 169 - />) or as reference (<xref linkend='ex-submodule-reference' />).</para> 170 171 - <para>Submodule option definitions are type-checked accordingly to the options 172 - declarations. It is possible to declare submodule options inside a submodule 173 - sub-options for even higher modularity.</para> 174 175 <example xml:id='ex-submodule-direct'><title>Directly defined submodule</title> 176 <screen> 177 options.mod = mkOption { 178 description = "submodule example"; 179 - type = with types; listOf (submodule { 180 options = { 181 foo = mkOption { 182 type = int; ··· 185 type = str; 186 }; 187 }; 188 - }); 189 };</screen></example> 190 191 - <example xml:id='ex-submodule-reference'><title>Submodule defined as a 192 reference</title> 193 <screen> 194 let ··· 205 in 206 options.mod = mkOption { 207 description = "submodule example"; 208 - type = with types; listOf (submodule modOptions); 209 };</screen></example> 210 211 - <section><title>Composed with <literal>listOf</literal></title> 212 - 213 - <para>When composed with <literal>listOf</literal>, submodule allows multiple 214 - definitions of the submodule option set.</para> 215 216 <example xml:id='ex-submodule-listof-declaration'><title>Declaration of a list 217 - of submodules</title> 218 <screen> 219 options.mod = mkOption { 220 description = "submodule example"; ··· 238 { foo = 2; bar = "two"; } 239 ];</screen></example> 240 241 - </section> 242 - 243 - 244 - <section><title>Composed with <literal>attrsOf</literal></title> 245 - 246 - <para>When composed with <literal>attrsOf</literal>, submodule allows multiple 247 - named definitions of the submodule option set.</para> 248 249 <example xml:id='ex-submodule-attrsof-declaration'><title>Declaration of 250 attribute sets of submodules</title> ··· 269 config.mod.one = { foo = 1; bar = "one"; }; 270 config.mod.two = { foo = 2; bar = "two"; };</screen></example> 271 272 - </section> 273 </section> 274 275 <section><title>Extending types</title>
··· 157 158 <section xml:id='section-option-types-submodule'><title>Submodule</title> 159 160 + <para><literal>submodule</literal> is a very powerful type that defines a set 161 + of sub-options that are handled like a separate module.</para> 162 163 + <para>It takes a parameter <replaceable>o</replaceable>, that should be a set, 164 + or a function returning a set with an <literal>options</literal> key 165 + defining the sub-options. 166 + Submodule option definitions are type-checked accordingly to the 167 + <literal>options</literal> declarations. 168 + Of course, you can nest submodule option definitons for even higher 169 + modularity.</para> 170 171 + <para>The option set can be defined directly 172 + (<xref linkend='ex-submodule-direct' />) or as reference 173 + (<xref linkend='ex-submodule-reference' />).</para> 174 175 <example xml:id='ex-submodule-direct'><title>Directly defined submodule</title> 176 <screen> 177 options.mod = mkOption { 178 description = "submodule example"; 179 + type = with types; submodule { 180 options = { 181 foo = mkOption { 182 type = int; ··· 185 type = str; 186 }; 187 }; 188 + }; 189 };</screen></example> 190 191 + <example xml:id='ex-submodule-reference'><title>Submodule defined as a 192 reference</title> 193 <screen> 194 let ··· 205 in 206 options.mod = mkOption { 207 description = "submodule example"; 208 + type = with types; submodule modOptions; 209 };</screen></example> 210 211 + <para>The <literal>submodule</literal> type is especially interesting when 212 + used with composed types like <literal>attrsOf</literal> or 213 + <literal>listOf</literal>. 214 + When composed with <literal>listOf</literal> 215 + (<xref linkend='ex-submodule-listof-declaration' />), 216 + <literal>submodule</literal> allows multiple definitions of the submodule 217 + option set (<xref linkend='ex-submodule-listof-definition' />).</para> 218 + 219 220 <example xml:id='ex-submodule-listof-declaration'><title>Declaration of a list 221 + nof submodules</title> 222 <screen> 223 options.mod = mkOption { 224 description = "submodule example"; ··· 242 { foo = 2; bar = "two"; } 243 ];</screen></example> 244 245 + <para>When composed with <literal>attrsOf</literal> 246 + (<xref linkend='ex-submodule-attrsof-declaration' />), 247 + <literal>submodule</literal> allows multiple named definitions of the 248 + submodule option set (<xref linkend='ex-submodule-attrsof-definition' />). 249 + </para> 250 251 <example xml:id='ex-submodule-attrsof-declaration'><title>Declaration of 252 attribute sets of submodules</title> ··· 271 config.mod.one = { foo = 1; bar = "one"; }; 272 config.mod.two = { foo = 2; bar = "two"; };</screen></example> 273 274 </section> 275 276 <section><title>Extending types</title>