Skip to content

Commit

Permalink
doc: Correctly render nested identifiers with nixdoc
Browse files Browse the repository at this point in the history
Applies nix-community/nixdoc#27 and fixes up the
location information rendering, allowing lib functions to be nested in
further scopes
  • Loading branch information
infinisil committed Dec 9, 2022
1 parent c2584ae commit f94bf99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
18 changes: 10 additions & 8 deletions doc/doc-support/lib-function-locations.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
{ pkgs ? (import ../.. { }), nixpkgs ? { }}:
let
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master");

libDefPos = set:
builtins.map
(name: {
name = name;
libDefPos = prefix: set:
builtins.concatMap
(name: [{
name = builtins.concatStringsSep "." (prefix ++ [name]);
location = builtins.unsafeGetAttrPos name set;
})
(builtins.attrNames set);
}] ++ nixpkgsLib.optionals
(builtins.length prefix == 0 && builtins.isAttrs set.${name})
(libDefPos (prefix ++ [name]) set.${name})
) (builtins.attrNames set);

libset = toplib:
builtins.map
(subsetname: {
subsetname = subsetname;
functions = libDefPos toplib.${subsetname};
functions = libDefPos [] toplib.${subsetname};
})
(builtins.filter
(name: builtins.isAttrs toplib.${name})
Expand Down
10 changes: 9 additions & 1 deletion pkgs/tools/nix/nixdoc/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin }:
{ lib, stdenv, fetchFromGitHub, fetchpatch, rustPlatform, darwin }:

rustPlatform.buildRustPackage rec {
pname = "nixdoc";
Expand All @@ -11,6 +11,14 @@ rustPlatform.buildRustPackage rec {
sha256 = "14d4dq06jdqazxvv7fq5872zy0capxyb0fdkp8qg06gxl1iw201s";
};

patches = [
# Support nested identifiers https://github.com/nix-community/nixdoc/pull/27
(fetchpatch {
url = "https://github.com/nix-community/nixdoc/pull/27/commits/ea542735bf675fe2ccd37edaffb9138d1a8c1b7e.patch";
sha256 = "1fmz44jv2r9qsnjxvkkjfb0safy69l4x4vx1g5gisrp8nwdn94rj";
})
];

buildInputs = lib.optionals stdenv.isDarwin [ darwin.Security ];

cargoSha256 = "1nv6g8rmjjbwqmjkrpqncypqvx5c7xp2zlx5h6rw2j9d1wlys0v5";
Expand Down

0 comments on commit f94bf99

Please sign in to comment.