Add links to combinator implementations in docs
This commit is contained in:
parent
35347831a2
commit
f0fd252dd0
1 changed files with 16 additions and 2 deletions
|
|
@ -3,10 +3,24 @@
|
||||||
# want to depend on nixpkgs
|
# want to depend on nixpkgs
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
|
|
||||||
outputs = { nixpkgs, ... }: let
|
outputs = { self, nixpkgs, ... }: let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
|
||||||
|
formatCombinatorDoc = name: combinatorObj: let
|
||||||
|
attrPos = builtins.unsafeGetAttrPos "impl" combinatorObj;
|
||||||
|
file = lib.removePrefix (toString ./..) attrPos.file;
|
||||||
|
in ''
|
||||||
|
## ${name}
|
||||||
|
**${name} :: ${combinatorObj.sig}**
|
||||||
|
|
||||||
|
${if self ? rev then "[Source](https://git.sr.ht/~alexdavid/jail.nix/tree/${self.rev}${file}#L${toString attrPos.line})" else ""}
|
||||||
|
|
||||||
|
${combinatorObj.doc}
|
||||||
|
|
||||||
|
---
|
||||||
|
'';
|
||||||
|
|
||||||
combinatorDocs = lib.pipe
|
combinatorDocs = lib.pipe
|
||||||
{
|
{
|
||||||
pkgs = throw "Docs must not depend on pkgs";
|
pkgs = throw "Docs must not depend on pkgs";
|
||||||
|
|
@ -16,7 +30,7 @@
|
||||||
[
|
[
|
||||||
(import ../combinators.nix)
|
(import ../combinators.nix)
|
||||||
(lib.filterAttrs (_: v: !(v ? deprecated && v.deprecated)))
|
(lib.filterAttrs (_: v: !(v ? deprecated && v.deprecated)))
|
||||||
(lib.mapAttrsToList (k: v: "## ${k}\n**${k} :: ${v.sig}**\n\n${v.doc}"))
|
(lib.mapAttrsToList formatCombinatorDoc)
|
||||||
(lib.concatStringsSep "\n\n")
|
(lib.concatStringsSep "\n\n")
|
||||||
(docs: "# Combinators\n\n${docs}")
|
(docs: "# Combinators\n\n${docs}")
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue