diff options
author | Robert Hensing | 2024-08-11 01:23:32 +0200 |
---|---|---|
committer | GitHub | 2024-08-11 01:23:32 +0200 |
commit | c5979b4e01886243f3af22de6dac46ea28f2bc2f (patch) | |
tree | c93bc26ec533c0ba16800019ca23284ef186d230 /doc | |
parent | 4b2abd87acddfafcdde5ba305054d6678d6d6577 (diff) | |
parent | 667f3a73f7ed070b570c03d63275acc301e7de54 (diff) |
Merge pull request #329400 from NixOS/doc-function-inputs
doc/README: Add function Inputs guidelines
Diffstat (limited to 'doc')
-rw-r--r-- | doc/README.md | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/doc/README.md b/doc/README.md index 6f452f1ba744..d7a853d0ec35 100644 --- a/doc/README.md +++ b/doc/README.md @@ -251,25 +251,42 @@ You, as the writer of documentation, are still in charge of its content. For example: ```markdown - # pkgs.coolFunction + # pkgs.coolFunction {#pkgs.coolFunction} - Description of what `coolFunction` does. + `pkgs.coolFunction` *`name`* *`config`* - ## Inputs + Description of what `callPackage` does. - `coolFunction` expects a single argument which should be an attribute set, with the following possible attributes: - `name` (String) + ## Inputs {#pkgs-coolFunction-inputs} + + If something's special about `coolFunction`'s general argument handling, you can say so here. + Otherwise, just describe the single argument or start the arguments' definition list without introduction. + + *`name`* (String) : The name of the resulting image. - `tag` (String; _optional_) + *`config`* (Attribute set) + + : Introduce the parameter. Maybe you have a test to make sure `{ }` is a sensible default; then you can say: these attributes are optional; `{ }` is a valid argument. - : Tag of the generated image. + `outputHash` (String; _optional_) - _Default:_ the output path's hash. + : A brief explanation including when and when not to pass this attribute. + + : _Default:_ the output path's hash. ``` + Checklist: + - Start with a synopsis, to show the order of positional arguments. + - Metavariables are in emphasized code spans: ``` *`arg1`* ```. Metavariables are placeholders where users may write arbitrary expressions. This includes positional arguments. + - Attribute names are regular code spans: ``` `attr1` ```. These identifiers can _not_ be picked freely by users, so they are _not_ metavariables. + - _optional_ attributes have a _`Default:`_ if it's easily described as a value. + - _optional_ attributes have a _`Default behavior:`_ if it's not easily described using a value. + - Nix types aren't in code spans, because they are not code + - Nix types are capitalized, to distinguish them from the camelCase [Module System](#module-system) types, which _are_ code and behave like functions. + #### Examples To define a referenceable figure use the following fencing: |