-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support documentation on functors #5527
base: master
Are you sure you want to change the base?
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: https://discourse.nixos.org/t/tweag-nix-dev-update-21/16032/1 |
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: https://discourse.nixos.org/t/how-to-generate-documentation-from-arbitrary-nix-code/22292/7 |
@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: