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
Support multiple :name:s with multiple signatures for .. tacn:: #17507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that accepting more names than signature lines and silently pointing extra names to the first signature line, but not doing so for the middle names, is a footgun (even more so without any documentation of this behavior). It seems that your suggestion from #17503 (comment) illustrates this, since this should have been :names: lazy cbv weak lazy
(and located on the line below).
Since the use case appears valid, a semantic that would look saner to me would simply be to point all the names to the first signature in case there are more names than signatures. This even leads to a simpler implementation:
if len(names) < len(sigs):
ERR = ("Expected at least {} semicolon-separated names, got {}. " +
"Please provide at least one name per signature line.")
raise self.error(ERR.format(len(names), len(sigs)))
elif len(names) > len(sigs):
self._sig_names = { sigs[0]: names }
else:
self._sig_names = { sig: [name] for (sig, name) in zip(sigs, names) }
Though there might also be valid use cases for providing fewer names than signature lines (in case three signatures start with the same two possible names, but end up with different parsing rules), in which case the code would simply be:
if len(names) != len(sigs):
self._sig_names = { sigs[0]: names }
else:
self._sig_names = { sig: [name] for (sig, name) in zip(sigs, names) }
Unless @cpitclaudel has a better idea.
doc/tools/coqrst/coqdomain.py
Outdated
@@ -274,14 +274,16 @@ def _prepare_names(self): | |||
self._sig_names = {} | |||
else: | |||
names = [n.strip() for n in names.split(";")] | |||
if len(names) != len(sigs): | |||
if len(names) < len(sigs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch was precisely meant for the case where len(names) > len(sigs) = 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? What did you mean instead of len(names) > len(sigs) = 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes you think I meant something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax. What do you mean by (simplifying) "A > B = 1"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed answer. I mean A > B /\ B = 1
.
doc/tools/coqrst/coqdomain.py
Outdated
ERR = ("Expected {} semicolon-separated names, got {}. " + | ||
"Please provide one name per signature line.") | ||
ERR = ("Expected at least {} semicolon-separated names, got {}. " + | ||
"Please provide at least one name per signature line.") | ||
raise self.error(ERR.format(len(names), len(sigs))) | ||
self._sig_names = { sigs[0]: names } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your current code, this line becomes unreachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's reachable, but the message needs to be reworded.
Colorful, but this seems a minor problem. We're never going to be able to check for every possible doc error. You even suggest pointing all the names to the first signature. I'm OK with changing it so all signatures point to the first entry.
Not so much, one has to test such changes. Hard to make review comments flawless when you're not actually making the changes. FWIW, I won't mention that you should have said |
This looks OK to me, but doesn't sphinx let you add custom index entries with |
a3b8296
to
c317b58
Compare
Updated. Hope we can wrap this up very soon. I simplified the behavior. No need to change ~100 uses of I removed some unneeded I couldn't remember how to add text to |
I wasn't proposing that, just to handle this additional new case with index instead of making :name: more powerful. (Or did I miss something?) |
You need to modify the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the current version, but maybe we should have kept the ability of linking to each signature when the number of provided names matches exactly with the number of signatures?
I'm also not completely clear on what the alternative proposed by Clément would entail.
BTW, there is a build error that I'm not sure that I understand.
@cpitclaudel The Coq doc has 7 indexes. I don't see how |
c317b58
to
a583075
Compare
Now the build results in:
|
That's the same message it was getting before, you just had to look at the full log to see it. I only rebased, no code change, but I think I figured out the cause. |
I still can't get this to work after several hours of trying :-(. Perhaps one of you can figure out how to do this. It does seem like a useful enhancement if it can be made to work. |
See https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-index, you give it the name of the index and what index entry to use. |
I would love to help, but I won't have time to write code for this any time soon. If it's critical, I will try to make time. But maybe the .. index:: solution is enough? Let me know |
Thanks. The immediate need for this for #17503 has gone away--they'll probably use different syntax that won't need an extra index entry.
I looked at the referenced Sphinx doc twice and closely but I don't see how you specify the name of the index. Is it something like |
No, you're right and I was wrong. |
Not ready for 8.18, postponing to 8.19 |
It seems this PR stalled months ago, I'm removing the milestone. |
Doesn't work and stalled, reopen if there's progress |
Needed for #17503 (See this comment).
@Zimmi48 Can you review/merge this very short PR soon?