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

LaTeX: Fix #12735 about siglines with typing but no parameter list #12737

Merged
merged 13 commits into from
Aug 24, 2024

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Aug 5, 2024

Fix #12735

Related #11444, #12561

@jfbu jfbu added this to the 8.x milestone Aug 5, 2024
@jfbu jfbu requested a review from picnixz August 5, 2024 15:32
Copy link
Contributor Author

@jfbu jfbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the added CR's are cosmetic they will put one argument per line for the various \pysig... support macros, which helps when examining LaTeX file, or when setting up tests. Cause of the bug was that in the case of presence of typing of class name but no parameters the LaTeX macro was fed with only 3 arguments but it is designed to fetch 4. Note that for LaTeX commands declared via \newcommand with N parameters you can separate the {...} by spaces (but not by blank lines), inclusive of EOL space, it is ignored by TeX.

@picnixz
Copy link
Member

picnixz commented Aug 6, 2024

I'll need a laptop for that PR just to confirm that the comments are also correct. The logic should be correct though. I think I first wanted a three arg macro parameter but then I observed that I could just have an empty parameter instead and then I forget to update one case. Thanks JF! I also forgot about the CR for cosmetic purposes. By the way do you think we should have some CRI which also indents the arguments like

\macro
  {}
  {}
  {}
  {}

Instead of

\macro
{}
{}
{}
{}

@jfbu
Copy link
Contributor Author

jfbu commented Aug 6, 2024

@picnixz +1 for indenting by two spaces as you display, it is helpful for those who like me like to browse the latex files...

@picnixz
Copy link
Member

picnixz commented Aug 6, 2024

Let's do it in a separate PR when I return.

@jfbu
Copy link
Contributor Author

jfbu commented Aug 6, 2024

Let's do it in a separate PR when I return.

ok.

@AA-Turner Can we merge this now? (test of tests/test_builders/test_build_latex.py::test_one_parameter_per_line will still be failing on DocUtils HEAD, but passes on current DocUtils).

@AA-Turner
Copy link
Member

Should this have a CHANGES entry?

@jfbu
Copy link
Contributor Author

jfbu commented Aug 6, 2024

This is a bugfix but there was no bug report... I asked for merge because if we do a 8.0.x bugfix release it appeared to belong to it. I am +0 on adding a CHANGES but documentation is always good, so I can do it if you prefer.

Copy link
Member

@picnixz picnixz 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 it's a fix of a fix but it's kind of a separate issue. So a CHANGELOG should be added (or you can just move my changelog entry (since we didn't really solve the issue) and credit yourself as well).

sphinx/writers/latex.py Outdated Show resolved Hide resolved
sphinx/writers/latex.py Show resolved Hide resolved
sphinx/writers/latex.py Outdated Show resolved Hide resolved
@picnixz
Copy link
Member

picnixz commented Aug 23, 2024

Huh, I forgot about this one. Tomorrow afternoon, I'll have a last look and we can merge it I think. Sorry for that JF.

@picnixz picnixz self-requested a review August 23, 2024 17:13
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, three is one single case where I'm wondering whether we should actually handle it or not.

.. py:function:: generic_foo[R] -> R

This renders as

image

both in HTML and in LaTeX. I don't expect people to forget about the () if they have a return type. But should we actually do something for that instead? (I also think it's a separate issue though). Otherwise I'm good.

@jfbu
Copy link
Contributor Author

jfbu commented Aug 24, 2024

Ok, three is one single case where I'm wondering whether we should actually handle it or not.

.. py:function:: generic_foo[R] -> R

Yes good find this looks a bit anomalous:

  • latex code will have no associated \index command, and function does not show in the PDF index indeed
  • but the latex code itself, using \pysigline with one argument, at least does not work only per accident, it does fetch one legit argument and renders it,
  • everything is bold including brackets in output, contrasting with output for correct input.

It seems, afaict, that this not correct source anyhow. It does not cause a build crash, it produces in PDF a reasonable output, main deficiency is lacking an index entry (which is actually a help perhaps to locate such problems).

I would say it is a separate issue!

I need to go for some outdoor activity before upcoming bad weather, so I will not do anything yet until a few more hours to give you a chance to respond... +1 for merge-as-is on my side.

@picnixz
Copy link
Member

picnixz commented Aug 24, 2024

I would say it is a separate issue!

I'll file one after this. Otherwise, I'm good to go. You can merge whenever you want!

@jfbu
Copy link
Contributor Author

jfbu commented Aug 24, 2024

Here we go, thanks @picnixz!

@jfbu jfbu merged commit 447cd1a into sphinx-doc:master Aug 24, 2024
22 checks passed
@jfbu jfbu deleted the latex_typinggenerics branch August 24, 2024 19:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2024
@AA-Turner AA-Turner modified the milestones: 8.x, 8.1.0 Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LaTeX: the py:class directive renders badly in PDF when used for generics with typing
3 participants