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

Support multiple :name:s with multiple signatures for .. tacn:: #17507

Closed
wants to merge 2 commits into from

Conversation

jfehrle
Copy link
Member

@jfehrle jfehrle commented Apr 18, 2023

Needed for #17503 (See this comment).

@Zimmi48 Can you review/merge this very short PR soon?

@jfehrle jfehrle added the kind: documentation Additions or improvement to documentation. label Apr 18, 2023
@jfehrle jfehrle added this to the 8.18+rc1 milestone Apr 18, 2023
@jfehrle jfehrle requested a review from a team as a code owner April 18, 2023 16:44
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Apr 18, 2023
Copy link
Member

@Zimmi48 Zimmi48 left a 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.

@@ -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):
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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"?

Copy link
Member

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.

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 }
Copy link
Member

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.

Copy link
Member Author

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.

@jfehrle
Copy link
Member Author

jfehrle commented Apr 19, 2023

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).

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.

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).

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 :name: lazy; cbv; weak lazy above.

@cpitclaudel
Copy link
Contributor

This looks OK to me, but doesn't sphinx let you add custom index entries with .. index? Maybe that's impler than adding more cases to the already-complicated :name: syntax? Not sure.

@jfehrle
Copy link
Member Author

jfehrle commented Apr 19, 2023

Updated. Hope we can wrap this up very soon.

I simplified the behavior. No need to change ~100 uses of :name: to :index:

I removed some unneeded :name:s.

I couldn't remember how to add text to doc/sphinx/README.rst. I wanted to add "If :name: is specified, the number of names must be >= the number of signatures. The name _ will not appear in indexes." Do you remember?

@cpitclaudel
Copy link
Contributor

I simplified the behavior. No need to change ~100 uses of :name: to :index:

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?)

@Zimmi48
Copy link
Member

Zimmi48 commented Apr 26, 2023

I couldn't remember how to add text to doc/sphinx/README.rst. I wanted to add "If :name: is specified, the number of names must be >= the number of signatures. The name _ will not appear in indexes." Do you remember?

You need to modify the README.template.rst file and run the build to update README.rst.

Copy link
Member

@Zimmi48 Zimmi48 left a 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.

@Zimmi48 Zimmi48 added the needs: fixing The proposed code change is broken. label Apr 26, 2023
@jfehrle
Copy link
Member Author

jfehrle commented May 2, 2023

@cpitclaudel The Coq doc has 7 indexes. I don't see how .. index:: would know which one should get the entry.

@jfehrle jfehrle removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label May 2, 2023
@Zimmi48
Copy link
Member

Zimmi48 commented May 2, 2023

Now the build results in:

/builds/coq/coq/_build/default/doc/sphinx/proof-engine/ssreflect-proof-language.rst:2215:Duplicate name first

@jfehrle
Copy link
Member Author

jfehrle commented May 2, 2023

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.

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label May 2, 2023
@jfehrle
Copy link
Member Author

jfehrle commented May 2, 2023

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.

@cpitclaudel
Copy link
Contributor

@cpitclaudel The Coq doc has 7 indexes. I don't see how .. index:: would know which one should get the entry.

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.

@cpitclaudel
Copy link
Contributor

Perhaps one of you can figure out how to do this.

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

@jfehrle
Copy link
Member Author

jfehrle commented May 3, 2023

If it's critical, I will try to make time.

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.

But maybe the .. index:: solution is enough?

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 :name:??

@cpitclaudel
Copy link
Contributor

No, you're right and I was wrong. .. index only inserts entries in the main index...

@gares gares modified the milestones: 8.18+rc1, 8.19+rc1 Jun 30, 2023
@gares
Copy link
Member

gares commented Jun 30, 2023

Not ready for 8.18, postponing to 8.19

@SkySkimmer
Copy link
Contributor

It seems this PR stalled months ago, I'm removing the milestone.

@SkySkimmer SkySkimmer removed this from the 8.19+rc1 milestone Nov 22, 2023
@SkySkimmer
Copy link
Contributor

Doesn't work and stalled, reopen if there's progress

@SkySkimmer SkySkimmer closed this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: documentation Additions or improvement to documentation. needs: fixing The proposed code change is broken. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants