@@ -117,60 +117,64 @@ let
117117 # TODO: display values like TOML instead.
118118 toMarkdown = optionsDocs :
119119 let
120+ optionsDocsPartitioned = partition ( opt : head opt . loc != "_module" ) optionsDocs ;
121+
120122 # TODO: handle opt.relatedPackages. What is it for?
121123 optToMd = opt :
124+ let heading = lib . showOption opt . loc ; in
122125 ''
123- ## `${ opt . name } `
126+ ### `${ heading } `
124127
125128 ''
126129 + ( lib . optionalString opt . internal "\n **internal**\n " )
127- + opt . description + " \n "
128- + ( lib . optionalString ( opt ? default && opt . default != null ) ''
130+ + opt . description
131+ + ''
129132
133+ **Type**:
134+
135+ ```console
136+ ${ opt . type }
137+ ```
138+ ''
139+ + ( lib . optionalString ( opt ? default && opt . default != null ) ''
140+
130141 **Default value**:
142+
131143 ```nix
132- ${
133- # When defaultText is set on the module, we only get back a
134- # string here and defaultText has disappeared. Re-hydrate that
135- # knowledge by looking at the type.
136- if builtins . isString opt . default && ! ( lib . hasPrefix "string" opt . type ) then
137- # If it's a defaultText, assume it's already formatted as nix
138- # code.
139- opt . default
140- else
141- builtins . toJSON opt . default
142- }
144+ ${ removeSuffix "\n " opt . default . text }
143145 ```
144-
145146 '' )
146- + ''
147-
148- **Type**: ${ opt . type }
149- ''
150147 + ( lib . optionalString ( opt ? example ) ''
151148
152149 **Example value**:
150+
153151 ```nix
154- ${ builtins . toJSON opt . example }
152+ ${ removeSuffix " \n " opt . example . text }
155153 ```
156-
157154 '' )
158155 + ''
159156
160- Declared in:
157+ **Declared in**:
158+
161159 ''
162160 + (
163161 lib . concatStringsSep
164162 "\n "
165163 ( map
166- ( decl : "* [${ decl . path } ](${ decl . url } )" )
164+ ( decl : "- [${ decl . path } ](${ decl . url } )" )
167165 opt . declarations
168166 )
169167 )
170168 + "\n "
171169 ;
170+ doc = [
171+ "## Options\n "
172+ ( concatStringsSep "\n " ( map optToMd optionsDocsPartitioned . right ) )
173+ "## Extra options\n "
174+ ( concatStringsSep "\n " ( map optToMd optionsDocsPartitioned . wrong ) )
175+ ] ;
172176 in
173- concatStringsSep "\n " ( map optToMd optionsDocs ) ;
177+ concatStringsSep "\n " doc ;
174178in
175179{
176180 options . modules-docs = {
0 commit comments