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

docstring for commands only shown with import Lean #3842

Closed
nomeata opened this issue Apr 8, 2024 · 2 comments · Fixed by #3918
Closed

docstring for commands only shown with import Lean #3842

nomeata opened this issue Apr 8, 2024 · 2 comments · Fixed by #3918
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@nomeata
Copy link
Contributor

nomeata commented Apr 8, 2024

Consider

inductive Foo where

There is no hover on inductive. That’s unfortuante, because someone wrote a nice docstring for that syntax, as seen here.

It does show up with

import Lean
inductive Foo where

Maybe something has to be made built-in of sorts?

Versions

4.7.0

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@nomeata nomeata added the bug Something isn't working label Apr 8, 2024
@nomeata
Copy link
Contributor Author

nomeata commented Apr 8, 2024

It seems that somehow the docstring needs to be added to builtinDocStrings. Maybe via some attribute? But Lean.Parser.Command.inductive isn’t really a builtin_term_parser nor a builtin_command_parser, isn’t it?

@digama0
Copy link
Collaborator

digama0 commented Apr 8, 2024

The simplest fix there is to use an attribute IMO. But you could also try to derive the set of builtin parsers by traversing the definition of every builtin_term_parser and builtin_command_parser. Or maybe you can use the infoFn baked into the parser? Unsure if that data is usable in this context.

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Aug 30, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 13, 2024
This solves the issue where certain subexpressions are lacking syntax
hovers because the hover text is not "builtin" - it only shows up if the
`Parser` constant is imported in the environment. For top level syntaxes
this is not a problem because `builtin_term_parser` will automatically
add this doc information, but nested syntaxes don't get the same
treatment.

We could walk the expression and add builtin docs recursively, but this
is somewhat expensive and unnecessary given that it's a fixed list of
declarations in lean core. Moreover, there are reasons to want to
control which syntax nodes actually get hovers, and while a better
system for that is forthcoming, for now it can be achieved by
strategically not applying the `@[builtin_doc]` attribute.

Fixes #3842
tobiasgrosser pushed a commit to opencompl/lean4 that referenced this issue Sep 16, 2024
This solves the issue where certain subexpressions are lacking syntax
hovers because the hover text is not "builtin" - it only shows up if the
`Parser` constant is imported in the environment. For top level syntaxes
this is not a problem because `builtin_term_parser` will automatically
add this doc information, but nested syntaxes don't get the same
treatment.

We could walk the expression and add builtin docs recursively, but this
is somewhat expensive and unnecessary given that it's a fixed list of
declarations in lean core. Moreover, there are reasons to want to
control which syntax nodes actually get hovers, and while a better
system for that is forthcoming, for now it can be achieved by
strategically not applying the `@[builtin_doc]` attribute.

Fixes leanprover#3842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants