Skip to content
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

Emit Nix doc comments for functions #14

Open
PgBiel opened this issue Aug 4, 2024 · 0 comments
Open

Emit Nix doc comments for functions #14

PgBiel opened this issue Aug 4, 2024 · 0 comments
Labels
enhancement New feature or request nix target Related to the nix target's codegen

Comments

@PgBiel
Copy link
Member

PgBiel commented Aug 4, 2024

Since Nix 2.2412, one may write :doc some-function on the Nix REPL (invoked by nix repl) to obtain a function's documentation, specified through a docstring in the format specified by Nix RFC 1453, as follows:

let
   /** Function doc */
   func = x: y: x + y;
in ...

Additionally, in Gleam, we may specify documentation comments on functions through the /// syntax, as follows:

/// Function doc
pub fn func(x: Int, y: Int) -> Int {
  x + y
}

When generating the Nix code for this function, it could be nice to translate the Gleam docstring into a Nix docstring so it can be accessed through :doc.

One concern: We'd need to escape */ in the docstring somehow. One way could be to add a whitespace between * and /, but this could be a problem depending on the contents of the docstring.

Footnotes

  1. https://discourse.nixos.org/t/nix-2-24-released/49986

  2. https://www.github.com/NixOS/nix/pull/11072

  3. https://www.github.com/NixOS/rfcs/pull/145

@PgBiel PgBiel added the enhancement New feature or request label Aug 4, 2024
@PgBiel PgBiel added the nix target Related to the nix target's codegen label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nix target Related to the nix target's codegen
Projects
None yet
Development

No branches or pull requests

1 participant