the repl's :doc
should print documentation for built-in constants #356
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#356
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is your feature request related to a problem? Please describe.
Many of the constants defined using
addConstant
insrc/libexpr/eval.cc
actually do have a documentation string, but they are only used for generating the manual. It'd be nice if they could also be printed via the repl's:doc
command (especially since the current output for things like:doc __nixPath
in the repl iserror: value '__nixPath' does not have documentation
, which is misleading, since it is actually documented in the manual)Describe the solution you'd like
Implementing this seems a bit annoying, as currently the only place these documentation strings are stored is in the evaluators
constantInfos
, in which they are sorted by name of the constant. So afaict there's no easy way to check if a given value represents an instance of a built-in constant, thus there's also no way to get the appropriate documentation.Maybe it would be possible to annotate values with documentation?
Describe alternatives you've considered
As a simpler alternative, the
:doc
command could just look constants up by name if it finds nothing else. Of course, this would then still fail to display documentation if the constant was bound to another name, and is also susceptible to printing wrong documentation if a built-in constant was shadowed.(i have a rough patch implementing this that I'd need to clean up first, but am not at all sure if this is something anyone'd want)
We would really like to be able to do this, but indeed, implementing it is a little tricky.
I feel like it'd be ok to "cheat" a bit and report about expressions first, and evaluated values second. That's warranted if you consider that evaluation is a lossy process (the right kind of loss, but lossy still).
Concretely, you could pattern match on expressions such as bare references and
builtins.<x>
and then show documentation for x.qyriad referenced this issue2024-06-01 04:04:17 +00:00