Commit 301824d2 authored by Matt Sturgeon's avatar Matt Sturgeon Committed by Valentin Gagarin
Browse files

doc/packages/treefmt: add function reference docs

Add a `treefmt.functionsDoc` passthru, which is included on the treefmt
section of the nixpkgs manual.

This generates reference docs for functions defined in
`pkgs/by-name/tr/treefmt/lib.nix`, using `nixdoc`.
parent fe586a5d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
  nixpkgs ? { },
  markdown-code-runner,
  roboto,
  treefmt,
}:

stdenvNoCC.mkDerivation (
@@ -47,6 +48,7 @@ stdenvNoCC.mkDerivation (

    postPatch = ''
      ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json
      ln -s ${treefmt.functionsDoc.markdown} ./packages/treefmt-functions.section.md
    '';

    buildPhase = ''
+5 −1
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
[treefmt](https://github.com/numtide/treefmt) streamlines the process of applying formatters to your project, making it a breeze with just one command line.

The [`treefmt` package](https://search.nixos.org/packages?channel=unstable&show=treefmt)
provides functions for configuring treefmt using the module system.
provides functions for configuring treefmt using the module system, which are [documented below](#sec-functions-library-treefmt).

Alternatively, treefmt can be configured using [treefmt-nix](https://github.com/numtide/treefmt-nix).

```{=include=} sections auto-id-prefix=auto-generated-treefmt-functions
treefmt-functions.section.md
```
+12 −0
Original line number Diff line number Diff line
@@ -72,6 +72,15 @@
  "part-toolchains": [
    "index.html#part-toolchains"
  ],
  "pkgs.treefmt.buildConfig": [
    "index.html#pkgs.treefmt.buildConfig"
  ],
  "pkgs.treefmt.evalConfig": [
    "index.html#pkgs.treefmt.evalConfig"
  ],
  "pkgs.treefmt.withConfig": [
    "index.html#pkgs.treefmt.withConfig"
  ],
  "preface": [
    "index.html#preface"
  ],
@@ -111,6 +120,9 @@
  "sec-building-packages-with-llvm-using-clang-stdenv": [
    "index.html#sec-building-packages-with-llvm-using-clang-stdenv"
  ],
  "sec-functions-library-treefmt": [
    "index.html#sec-functions-library-treefmt"
  ],
  "sec-inkscape": [
    "index.html#sec-inkscape"
  ],
+19 −0
Original line number Diff line number Diff line
{
  nixdoc,
  runCommand,
}:
{
  markdown =
    runCommand "treefmt-functions-doc"
      {
        nativeBuildInputs = [ nixdoc ];
      }
      ''
        nixdoc --file ${./lib.nix} \
          --description "Functions Reference" \
          --prefix "pkgs" \
          --category "treefmt" \
          --anchor-prefix "" \
           > $out
      '';
}
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ buildGoModule rec {
      ;

    tests = callPackages ./tests.nix { };

    # Documentation for functions defined in `./lib.nix`
    functionsDoc = callPackages ./functions-doc.nix { };
  };

  meta = {