Conversation
For example, given a functor like
id = {
__args = [ "x" ];
__doc =
''
The identity function. It takes a single argument *x* and returns it.
'';
__functor = _: x: x;
};
the repl can now print documentation about it:
nix-repl> :doc lib.id
Synopsis: lib.id x
The identity function. It takes a single argument x and returns it.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
Alternative idea: Without having spent too much time thinking about this the implementation could add a references to a String to the Value struct. This means we can document all and every single expression in the language, something that was always missing to generate docs from a set of functions (without resorting to some kind of hacks). I don't really like the current ergonomics around the |
|
@andir's proposal would also allow for arbitrary values to be documented which could be quite nice. |
|
@andir That was my original thought, but the problem is that Values don't have enough space to add annotations like docstrings. Functors on the other hand already are attrsets. |
You mean we can't add a pointer to the Value struct that defaults to |
|
Right, it would make every Value 8 bytes larger. |
|
I've actually gone ahead and made that change (with another pointer value in each Value instance). It is very rough around the edges but in principle it works: |
|
I marked this as stale due to inactivity. → More info |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
@edolstra can we meet to discuss options regarding this, please? |
|
Hey, @roberth, we are a team of three, working in mob programming format on core documentation issues in the Nix ecosystem. We'd love to coordinate efforts with you. |
Hi @mightyiam and the mob, @edolstra How about having both? Documentation seems important enough to warrant the relative complexity of having both the added power of __functor and the ease of use of doc comments. |


For example, given a functor like
the repl can now print documentation about it: