Skip to content

Commit 891ca9f

Browse files
committed
Better handling of title/example in options
1 parent bbd230a commit 891ca9f

25 files changed

Lines changed: 334 additions & 879 deletions

OPTIONS.md

Lines changed: 143 additions & 747 deletions
Large diffs are not rendered by default.

flake.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
'';
3434

3535
optionsDoc = pkgsMaster.nixosOptionsDoc {
36-
options = ((pkgsMaster.callPackage ./nix/evaluate-config.nix {
36+
# Fold each option's "title" into its description so it survives into the docs.
37+
options = (import ./nix/fold-option-titles.nix { lib = pkgsMaster.lib; }) (((pkgsMaster.callPackage ./nix/evaluate-config.nix {
3738
inherit pkgsStable pkgsMaster;
3839
extraSpecialArgs = {
3940
pkgs = {};
4041
};
41-
}) {}).options;
42+
}) {}).options);
4243
transformOptions = opt: opt // {
4344
# Remove declarations to hide "Declared by" lines
4445
declarations = [];

modules/environment/module.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ with lib;
55
{
66
options = {
77
environment.variables = mkOption {
8+
title = "Environment variables";
89
type = types.attrsOf types.str;
910
default = {};
1011
description = "Environment variables to set.";
1112
};
1213

1314
environment.extraNix = mkOption {
15+
title = "Extra Nix";
1416
type = types.codeMirrorLines "nix";
1517
default = "";
18+
example = ''
19+
with pkgs;
20+
symlinkJoin {
21+
name = "extra-packages";
22+
paths = [ hello cowsay ];
23+
}
24+
'';
1625
description = "Arbitrary Nix expression that evaluates to a derivation, which will be joined into the environment. The expression has \"pkgs\" in scope, an imported Nixpkgs package set.";
1726
};
1827
};

modules/exporters/nbconvert/module.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ with lib;
77
exporters.nbconvert = {
88
enable = mkOption {
99
type = types.bool;
10-
example = "Enable nbconvert exporters";
10+
title = "Enable nbconvert exporters";
1111
description = "Enable the nbconvert exporters.";
1212
default = false;
1313
visible = false;
@@ -36,7 +36,7 @@ with lib;
3636
"scheme-full"
3737
];
3838
default = "scheme-full";
39-
example = "TeX Live scheme";
39+
title = "TeX Live scheme";
4040
description = "The TeX Live scheme to use, as an attribute of pkgs.texlive.combined.*";
4141
};
4242
};

modules/exporters/pandoc/module.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ with lib;
77
exporters.pandoc = {
88
enable = mkOption {
99
type = types.bool;
10-
example = "Enable pandoc exporters";
10+
title = "Enable pandoc exporters";
1111
description = "Enable the pandoc exporters.";
1212
default = false;
1313
visible = false;
@@ -36,7 +36,7 @@ with lib;
3636
"scheme-full"
3737
];
3838
default = "scheme-full";
39-
example = "TeX Live scheme";
39+
title = "TeX Live scheme";
4040
description = "The TeX Live scheme to use, as an attribute of pkgs.texlive.combined.*";
4141
};
4242
};

modules/exporters/typst/default.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ let
1616

1717
common = callPackage ../../kernels/common.nix {};
1818

19+
# Also writes a dependency file at "<output>.deps" (typst's native JSON
20+
# {"inputs": [...]}, paths relative to cwd) so the runner can watch imported
21+
# files and re-render when any of them changes. See exporterInfoDeps below.
1922
script = common.writeShellScriptBinWithAttrs {} "typst-export" ''
2023
echo_and_run() { echo "$*" ; "$@" ; }
2124
echo_and_run export PATH="''${PATH:+''${PATH}:}"
22-
echo_and_run ${typst}/bin/typst compile "$1" "$2"
25+
echo_and_run ${typst}/bin/typst compile --deps "$2.deps" "$1" "$2"
2326
'';
2427

2528
typstToUse = typst.withPackages (ps: (map (x: ps.${x}) packages));
@@ -43,6 +46,7 @@ let
4346
args = [(script + "/bin/typst-export")];
4447
input_extensions = ["typ"];
4548
pandoc = "${pandoc}/bin/pandoc";
49+
deps = "typst_json";
4650
};
4751

4852
in

modules/exporters/typst/module.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let
1010
type = types.str;
1111
};
1212
outputs = mkOption {
13-
example = "Package outputs to include";
13+
title = "Package outputs to include";
1414
type = types.listOf types.str;
1515
};
1616
};
@@ -23,34 +23,34 @@ in
2323
exporters.typst = {
2424
enable = mkOption {
2525
type = types.bool;
26-
example = "Enable Typst exporter";
26+
title = "Enable Typst exporter";
2727
description = "Enable the Typst exporters.";
2828
default = false;
2929
visible = false;
3030
};
3131

3232
packages = mkOption {
33-
example = "List of packages";
33+
title = "List of packages";
3434
type = types.listOf (types.either types.str subPackage);
3535
default = [];
3636
visible = false;
3737
};
3838

3939
interface.attrs = mkOption {
40-
example = boilerplate.attrsTitle;
40+
title = boilerplate.attrsTitle;
4141
description = boilerplate.attrsDescription;
4242
type = types.listOf types.str;
4343
default = ["typst"];
4444
};
4545
interface.extensions = mkOption {
46-
example = boilerplate.extensionsTitle;
46+
title = boilerplate.extensionsTitle;
4747
description = boilerplate.extensionsDescription;
4848
type = types.listOf types.str;
4949
default = ["typ"];
5050
};
5151

5252
lsp.tinymist.enable = mkOption {
53-
example = "Enable tinymist language server";
53+
title = "Enable tinymist language server";
5454
type = types.bool;
5555
default = true;
5656
};

modules/kernels/bash/module.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ in
1111
options = {
1212
kernels.bash = {
1313
enable = mkOption {
14-
example = "Enable Bash kernel";
14+
title = "Enable Bash kernel";
1515
type = types.bool;
1616
default = false;
1717
visible = false;
1818
};
1919

2020
interface.attrs = mkOption {
21-
example = boilerplate.attrsTitle;
21+
title = boilerplate.attrsTitle;
2222
description = boilerplate.attrsDescription;
2323
type = types.listOf types.str;
2424
default = ["bash"];
2525
};
2626
interface.extensions = mkOption {
27-
example = boilerplate.extensionsTitle;
27+
title = boilerplate.extensionsTitle;
2828
description = boilerplate.extensionsDescription;
2929
type = types.listOf types.str;
3030
default = ["sh" "bash"];
3131
};
3232

3333
lsp.bash-language-server.enable = mkOption {
34-
example = "Enable Bash language server";
34+
title = "Enable Bash language server";
3535
type = types.bool;
3636
default = true;
3737
};

modules/kernels/clojure/module.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ with lib;
66
options = {
77
kernels.clojure = {
88
enable = mkOption {
9-
example = "Enable Clojure kernel";
9+
title = "Enable Clojure kernel";
1010
type = types.bool;
1111
default = false;
1212
visible = false;
1313
};
1414

1515
interface.attrs = mkOption {
16-
example = boilerplate.attrsTitle;
16+
title = boilerplate.attrsTitle;
1717
description = boilerplate.attrsDescription;
1818
type = types.listOf types.str;
1919
default = ["clojure"];
2020
};
2121
interface.extensions = mkOption {
22-
example = boilerplate.extensionsTitle;
22+
title = boilerplate.extensionsTitle;
2323
description = boilerplate.extensionsDescription;
2424
type = types.listOf types.str;
2525
default = ["clj"];
2626
};
2727

2828
lsp.clojure-lsp.enable = mkOption {
29-
example = "Enable clojure-lsp language server";
29+
title = "Enable clojure-lsp language server";
3030
type = types.bool;
3131
default = true;
3232
};

modules/kernels/coq/module.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ in
1111
options = {
1212
kernels.coq = {
1313
enable = mkOption {
14-
example = "Enable Coq kernel";
14+
title = "Enable Coq kernel";
1515
type = types.bool;
1616
default = false;
1717
visible = false;
1818
};
1919

2020
packages = mkOption {
21-
example = "List of Coq packages to use";
21+
title = "List of Coq packages to use";
2222
type = types.listOf types.str;
2323
default = [];
2424
visible = false;
2525
};
2626

2727
coqPackages = mkOption {
28-
example = "Coq packages set";
28+
title = "Coq packages set";
2929
type = types.enum (
3030
["coqPackages"]
3131
++ (builtins.filter (name: builtins.substring 0 (builtins.stringLength "coqPackages_") name == "coqPackages_")
@@ -35,13 +35,13 @@ in
3535
};
3636

3737
interface.attrs = mkOption {
38-
example = boilerplate.attrsTitle;
38+
title = boilerplate.attrsTitle;
3939
description = boilerplate.attrsDescription;
4040
type = types.listOf types.str;
4141
default = ["coq"];
4242
};
4343
interface.extensions = mkOption {
44-
example = boilerplate.extensionsTitle;
44+
title = boilerplate.extensionsTitle;
4545
description = boilerplate.extensionsDescription;
4646
type = types.listOf types.str;
4747
default = ["v"];

0 commit comments

Comments
 (0)