Skip to content

Value doc#625

Draft
inclyc wants to merge 4 commits into
mainfrom
value-doc
Draft

Value doc#625
inclyc wants to merge 4 commits into
mainfrom
value-doc

Conversation

@inclyc

@inclyc inclyc commented Nov 23, 2024

Copy link
Copy Markdown
Member

This PR introduces nix-repl's :doc command to nixd.

Since NixOS/nix#11072, we can utilize the API exposed by nix::EvalState::getDoc. (i.e. to provide hover/completions(todo) from nixpkgs's doc comments).

Current status:

  • support hovering
  • support completion-list resolve
The :doc command in nix-repl Hovering on that value

Also CC @roberth (author of nix implementation), @hsjobeki (author of doc-comments RFC). How can we co-operate to make these stuff more fancy? (It looks very ugly so far, 😆 )

I see there are some information for "definition" here, generally this information is separated from "hover-ed documentation" in LSP, can we have a new API to get a structured output?

@hsjobeki

hsjobeki commented Nov 23, 2024

Copy link
Copy Markdown

I am also in favor or just returning the content without Rendering it. Maybe as a function on the C-abi.
But it should Return a struct with content, Position, and probably more metadata.
Rendering is best done using the markdown Extensions from the documentation readme in nixpkgs.

Comment thread libnixt/include/nixt/Value.h Outdated

/// TODO: use https://github.com/NixOS/nix/pull/11914 on nix version bump
/// \brief Get nix's `builtins` constant
inline nix::Value &getBuiltins(const nix::EvalState &State) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove, not used in this PR

constexpr inline std::string_view AttrPathComplete = "attrset/attrpathComplete";
constexpr inline std::string_view OptionInfo = "attrset/optionInfo";
constexpr inline std::string_view OptionComplete = "attrset/optionComplete";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty

Comment thread nixd/lib/Eval/AttrSetProvider.cpp Outdated

std::optional<ValueDescription> describeValue(nix::EvalState &State,
nix::Value &V) {
const auto Doc = State.getDoc(V);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix::EvalState::getDoc() is invoked here

}

static std::string mkValueMarkdown(const ValueDescription &ValueDesc) {
return ValueDesc.Doc;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, the documentation is replied directly without any formatting/tokenization.

@inclyc

inclyc commented Dec 12, 2024

Copy link
Copy Markdown
Member Author

kindly ping @roberth, can we have a structured helper function exposed from nix-expr?

@roberth

roberth commented Feb 18, 2025

Copy link
Copy Markdown

Hey @inclyc, sorry for the delay. Happy to help if I can, but it's not quite clear to me what needs to be done in nix-expr.
Currently the inside of the comment is not parsed, except with a markdown parser, of which I'm not even sure that it's the right parser, considering the mismatch with some extended syntax that's used in Nixpkgs.
If, on the other hand, you're looking for some improvements in the interface around the already implemented functionality, we might have some low hanging fruit to pick there.

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/why-nix-will-win-and-whats-stopping-it-a-3-year-production-story/70621/42

@inclyc inclyc force-pushed the main branch 2 times, most recently from ed5029e to 6707401 Compare January 2, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants