Skip to content

generate nixpkgs neovim doc from the code  #137

@teto

Description

@teto

I would like to upgrade the neovim wrapper documentation and I prefer to document it within the code, ie.: pkgs/applications/editors/neovim/wrapper.nix.
I've patched doc/doc-support/lib-function-docs.nix to get a better understanding of what was going on since the doc is scarce.

I ended up handcrafting the following neovim_locations.json:

{
  "neovim-unwrapped": "[pkgs/applications/editors/neovim/wrapper.nix:57](https://github.com/NixOS/nixpkgs/blob/master/lib/asserts.nix#L135) in `<nixpkgs>`"
}

and I copy/pasted some valid doc from somewhere else ( I convertedh the triple backticks into two to avoid messing up the preview):

/**
  Specialized `assertMsg` for checking if every one of `vals` is one of the elements
  of the list `xs`. Useful for checking lists of supported attributes.

  # Inputs

  `name`

  : The name of the variable the user entered `val` into, for inclusion in the error message

  `vals`

  : The list of values of what the user provided, to be compared against the values in `xs`

  `xs`

  : The list of valid values

  # Type

  ``
  assertEachOneOf :: String -> List ComparableVal -> List ComparableVal -> Bool
  ``

  # Examples
  :::{.example}
  ## `lib.asserts.assertEachOneOf` usage example

  ``nix
  let sslLibraries = [ "libressl" "bearssl" ];
  in assertEachOneOf "sslLibraries" sslLibraries [ "openssl" "bearssl" ]
  stderr> error: each element in sslLibraries must be one of [
  stderr>   "openssl"
  stderr>   "bearssl"
  stderr> ], but is: [
  stderr>   "libressl"
  stderr>   "bearssl"
  stderr> ]
  ``

  :::
*/
neovim-unwrapped: ##### THIS IS LINE 57

then I ran

nixdoc -c "toto" -d "lib.matt: this is description" -l neovim_locations.json -f "pkgs/applications/editors/neovim/wrapper.nix"

which outputs the disappointing

# lib.matt: this is description {#sec-functions-library-toto}

I am not sure how to proceed from there and even once that is fixed, I dont know how easy it would be to use this in nixpkgs ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions