lol

nixos/make-options-doc: render option types through md

no changes to rendered output, but options.xml loses a few spaces.

pennae de22a26b 6b677d91

+18 -2
+18 -2
nixos/lib/make-options-doc/optionsToDocbook.py
··· 263 263 convertCode(name, option, 'example') 264 264 convertCode(name, option, 'default') 265 265 266 + if typ := option.get('type'): 267 + ro = " *(read only)*" if option.get('readOnly', False) else "" 268 + option['type'] = md.render(f'*Type:* {md_escape(typ)}{ro}') 269 + 266 270 if 'relatedPackages' in option: 267 271 option['relatedPackages'] = md.render(option['relatedPackages']) 268 272 except Exception as e: ··· 280 284 ord(':'): ord('_'), 281 285 ord('"'): ord('_'), 282 286 } 287 + 288 + md_escape_table = { 289 + ord('*'): '\\*', 290 + ord('<'): '\\<', 291 + ord('['): '\\[', 292 + ord('`'): '\\`', 293 + ord('.'): '\\.', 294 + ord('#'): '\\#', 295 + ord('&'): '\\&', 296 + ord('\\'): '\\\\', 297 + } 298 + def md_escape(s: str) -> str: 299 + return s.translate(md_escape_table) 283 300 284 301 def need_env(n): 285 302 if n not in os.environ: ··· 358 375 print(f"""<listitem>""") 359 376 print(opt['description']) 360 377 if typ := opt.get('type'): 361 - ro = " <emphasis>(read only)</emphasis>" if opt.get('readOnly', False) else "" 362 - print(f"""<para><emphasis>Type:</emphasis> {escape(typ)}{ro}</para>""") 378 + print(typ) 363 379 if default := opt.get('default'): 364 380 print(default) 365 381 if example := opt.get('example'):