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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generated documentation for library functions #49275
Conversation
Oh, and before I forget it - shoutout to @jD91mZM2 for writing |
Updated with |
Very nice :) Is it feasible to generate the docs during the build instead of checking them into the repo? |
@joachifm Eventually we'd like to do that, but as Graham mentioned the The required features are going to stabilise not too far in the future, at which point we could add it to the automatic manual generation. An alternative approach is removing the use of unstable features from that lib and its dependencies, which @Mic92 has started doing. Either way, for now just checking in the generated files already gets us quite far! |
I believe Rust 2018 edition is, if all goes well, coming in 1.31 (the very next update of rust) which should get rid of the nightly dependency. EDIT: Did it anyway, a backported version is now available on the stable branch :) |
@jD91mZM2 Awesome, thank you! Would you consider publishing the stable-compatible It seems like Edit: Nevermind, managed to patch |
I'll publish them as soon as I get a PR to arenatree merged, to avoid publishing twice. Will let you know when (in a day or two) |
Adds nixdoc, a tool to generate documentation for Nix functions in the standard library. See NixOS#49275 for some background information.
As you can see above there's now a PR for adding |
@Mic92 I used |
Added docs for There are some slightly unclear things in both of those, so it'd be appreciated if someone could do a second pass - but we can do that in a followup PR. |
Adds nixdoc, a tool to generate documentation for Nix functions in the standard library. See NixOS#49275 for some background information.
@tazjin is this ready to merge? |
It's ready technically, I'll just make more PRs when I cover the other files. Two notes:
|
What do you think about this strategy for merging:
Ideally the "update generated docs" step would be a make target in the Makefile, not called by default. Before merging the generated docs, I'd like to do a rendered display for people to look at. |
Oh, I forgot to mention this - I publish rendered docs here at the moment.
Works for me. I'd make a new PR for the For the 18.09 PR I suppose the steps are something like:
Correct? Or is that branch no longer in use?
Lets do this as the next step, we can discuss a little bit what the best workflow is but for now I just want to get Some Docs 鈩笍 in. |
Changes to Nix-files have been removed from this PR, they are now in #49383. |
Working on making it an appendix. One maybe long-term project is to fix the code examples with absolute function names, so
becomes
this might be part of a larger effort to improve the examples, though, like adding titles and splitting shared examples in to two? Also, what is the status of splitting the input with the output, for testable doc comments? |
You mean by actually updating the doc comments to look like that, or via some spooky rewriting?
It depends on me writing a proper parser for the doc comments. Currently it's a somewhat advanced string-splitter that works well with the existing format, but it should be a bit more flexible. I'll probably start looking into it this evening. |
Note: once merged, I think this will obsolete #23505 |
Adds documentation generated with [nixdoc][] for the functions in `trivial.nix`. There are a couple of minor issues: * Some markup syntax used in comments is not recognised and rendered literally. This isn't so much a bug, as a design decision. * Functions *returning* functions have incorrect function parameter annotations because there is no way to distinguish between the arguments of the functions when currying. [nixdoc]: https://github.com/tazjin/nixdoc
Add nixdoc-generated documentation for the functions in lib.strings. The new file should not be modified manually.
Add nixdoc-generated documentation for the functions in lib.lists. The new file should not be modified manually.
e0a6ba9
to
98ba629
Compare
I've rebased this and regenerated all the docs above (there were a handful of new functions). @grahamc When do you think we can get this merged? |
This looks awesome! One suggestion I have is to put the commands to regenerate these files somewhere in the repo. Maybe also somehow make sure that they get run before a channel update. |
It should be possible to build a setup that does this as part of the manual build, but for now I mostly just want to get some version of them in as a starter ;-) |
I'd be fine with just a simple |
An alternative approach is in this commit. Instead of checking in the generated files it updates the manual build process to generate them, which is not too difficult. Currently due to the way this works the list of files that needs to be documented is specified twice (once for generation of the doc XML, and once in another XML file to include the generated files). I think this is a very small price to pay for now though. Thoughts? |
I think I prefer the other pr. |
@Mic92 Agree, and @infinisil does, too. I'm closing this PR in favour of the other one. |
This adds generated documentation using nixdoc for some of the library functions in
<nixpkgs>.lib
. It is part of my NixCon 2018 hackathon project.A rendered view is available for your viewing pleasure. 馃憖
This PR previously included the changes to documentation comments, but those have been moved to #49383, see this comment for why.
The documentation files can be generated by installing
nixdoc
(available inmaster
) and running:Some notes & caveats: