-
Notifications
You must be signed in to change notification settings - Fork 444
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
feat: @[builtin_doc] attribute (part 2) #3918
Conversation
Part 2 can be moved into a separate PR, no? |
Part 1 is fine to merge as is |
This will fix #3842, right? |
As I indicated in the PR, I'm not sure how the protocol for this works. Do I open two PRs, one with the first and one with all 3 commits? And then rebase the second one after the first is merged and the stage0 bot runs? How do I signal the bot to run? |
If the first step works on it's own (i.e. passes the test suite), you can put it on a PR of it's own and merge. If this changes the stdflags.h file, as such PRs often do, the bot will automatically update stage0 on master. If not you can trigger the workflow manually using the button at https://github.com/leanprover/lean4/actions/workflows/update-stage0.yml. If the first step on its own is not suitable for master, then doing it as you do here, and asking an admin to rebase merge, is the way to go. |
First part of #3918.
Mathlib CI status (docs):
|
Remember to update the PR description so that it also works as the commit message |
It does, did you want me to put |
Ah, maybe by browser still showed the old message asking about the procedure, but a reload helped. All good. |
Hmm, looks like this doesn't bootstrap as is. |
@digama0, what is the status of this PR? Would be good to fix the issue, but I also see some |
this PR was meant to be merged immediately after part 1, but I guess it wasn't and now presumably it has rotted |
The FIXMEs are fine to merge as is. The issue is that while it would be nice to have docs for these bits of syntax, they appear far too often and suppress more useful hovers, so they probably need another attribute to undo the effect of |
Thanks for the explanation!
Is this specific to builtin_doc? Or would you need a mechanism to suppress the hovers also if the syntax wasn’t builtin? I.e. a “This syntax has documentation, but never show it in hovers” Indeed, for example the doc string for Do we have a fundamental issue here that a docstring on a parser is used for two very different audiences, authors of parsers and users of the resulting syntax? I guess this is what you are saying in the PR description. You say “while a better system for that is forthcoming” - is there an PR or RFC for that? It might be useful to link to that from the FIXME, so that when I or someone else stumble over the FIXME comment in a year we it’s clearer why it’s there and when it can be fixed. |
Uff, now that understand the issue better I find many hovers of dubious quality when doing
when hovering over the But this already affects everyone doing The proper fix would require going through all docstrings of parsers and either rephrase them to make sense to users, or (somehow?) prevent them from leaking into hovers. That sounds like a fair bit of work, though. |
Yes, you see the issue now. There is a difference between documentation useful for people reading the parser or hovering references in a As for whether I'm working on such an attribute: I may have been thinking about it at the time, but this PR took way too long to merge and now I've forgotten any plans I had (and also in the meantime the governmental structure of lean has changed to the point that I don't really like making PRs like this anymore). It doesn't seem like a particularly hard task though, the spec and implementation seem clear enough. |
Hmm, but that only helps users on a bare lean file, but for example not mathlib users, does it?
Agreed! Sorry for the slow handling of this PR, I think it fell between the cracks when I sent it to the merge queue, but it came back due to a failed CI check (bootstrapping issues?). Actually, I wonder if we still have that problem, let me add the |
Mathlib doesn't have many syntax definitions which are internal in the same way as core lean definitions. For those that do exist, they currently are causing problems and that issue is not addressed by this PR (which is about adding docstrings for syntax that can clearly benefit from it and which currently only shows the docstring with The bootstrapping issue was probably caused by an |
Hmm, but inductive Foo has no hover over import Mathlib
inductive Foo has (already before this PR). In that sense this change doesn’t affect the typical mathlib user, but only the user working on files without a (transitive) import of Lean. And it’s good if they all get the same experience, even if we ought to improve that at some point. |
Yes, that is correct. The fact that |
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
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 becausebuiltin_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