-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
doc/doc-support: Generalize library docs code #305847
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94a5ded
doc-support/lib-function-docs.nix -> doc-support/generate-function-do…
roberth 8c08279
doc/doc-support: Add library parameter to function doc functions
roberth 5391e81
doc/doc-support/generate-function-docs.nix: Add src parameter
roberth 3114522
doc/doc-support/generate-function-docs.nix: Add name parameter
roberth a9c3c9e
doc/doc-support: Add prefix parameter to function doc functions
roberth d549393
doc/default.nix: Inline import ./doc-support/lib-docs.nix
roberth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
doc/doc-support/lib-function-docs.nix → doc/doc-support/generate-function-docs.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
# Generates the documentation for library functions via nixdoc. | ||
|
||
{ pkgs, nixpkgs, libsets }: | ||
{ pkgs, nixpkgs, libsets, library, src, name, prefix }: | ||
|
||
with pkgs; | ||
|
||
let | ||
locationsJSON = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets; }; | ||
locationsJSON = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets library prefix; }; | ||
in | ||
stdenv.mkDerivation { | ||
name = "nixpkgs-lib-docs"; | ||
src = ../../lib; | ||
inherit src name; | ||
|
||
buildInputs = [ nixdoc ]; | ||
env = { | ||
# lower case $prefix is written by setup.sh for ./configure when empty | ||
PREFIX = prefix; | ||
PREFIXDOT = if prefix == "" then "" else "${prefix}."; | ||
}; | ||
installPhase = '' | ||
function docgen { | ||
name=$1 | ||
baseName=$2 | ||
description=$3 | ||
# TODO: wrap lib.$name in <literal>, make nixdoc not escape it | ||
# TODO: wrap ${prefix}$name in <literal>, make nixdoc not escape it | ||
if [[ -e "../lib/$baseName.nix" ]]; then | ||
nixdoc -c "$name" -d "lib.$name: $description" -l ${locationsJSON} -f "$baseName.nix" > "$out/$name.md" | ||
nixdoc -c "$name" -d "$PREFIXDOT$name: $description" -l ${locationsJSON} -f "$baseName.nix" --prefix "$PREFIX" > "$out/$name.md" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would require nixdoc to support that feature as you already mentioned. I could take care of that in the next couple of days. |
||
else | ||
nixdoc -c "$name" -d "lib.$name: $description" -l ${locationsJSON} -f "$baseName/default.nix" > "$out/$name.md" | ||
nixdoc -c "$name" -d "$PREFIXDOT$name: $description" -l ${locationsJSON} -f "$baseName/default.nix" --prefix "$PREFIX" > "$out/$name.md" | ||
fi | ||
echo "$out/$name.md" >> "$out/index.md" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A am about to change this default in nixdoc. Can you change it to "lib." already here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So more like a string prefix than a path prefix? That's also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that what you requested in nix-community/nixdoc#119? Or did I understand it wong?
This now depends on which one gets merged earlier. Ideally, we would merge this PR first nix-community/nixdoc#122 to support empty prefixes with the default prefix="lib.".
The problem is, that if we change the prefix delimiter in the wrong way. The manual will not build because the heading IDs on the manual change.
If we merge this one first, we are in a deadlock. Where we must implement a backwards compatible migration in nixdoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both solutions are valid, and I don't have a preference.
Requiring the
.
to be specified on the command line is more of a breaking change, but the implementation is slightly simpler.