-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
The LaTeX writer support added in #11444 imposes the requirement that any desc_type_parameter_list node is immediately followed by a desc_parameterlist node.
This is not satisfied with the following:
.. py:class:: Foo[T]
Some class.The workaround is:
.. py:class:: Foo[T]()
Some class.Additionally, in the sphinx_immaterial theme, I'm adding support for type parameters to our apigen extension: jbms/sphinx-immaterial#366
See example here: https://sphinx-immaterial--366.org.readthedocs.build/en/366/python_apigen_demo.html#type-parameter-demo
In particular, the apigen extension documents class members "out of line" on a separate page:
https://sphinx-immaterial--366.org.readthedocs.build/en/366/python_apigen_generated/Map.items.html
For members of a class with type parameters, the extension inserts an additional type parameter list after the class name but before the .member suffix:
type_param_demo.Map[K, V].items() -> ItemsView[K, V]If the method itself also has type parameters, then there will be both the type parameter list for the parent class and the type parameter list for the method itself:
https://sphinx-immaterial--366.org.readthedocs.build/en/366/python_apigen_generated/Map.get.html
type_param_demo.Map[K, V].get(key: K) → V | None
type_param_demo.Map[K, V].get(key: K, default: V) → V
type_param_demo.Map[K, V].get[T](key: K, default: T) → V | TWhile this syntax is not standard Python syntax, and can only be generated via an extension to the Sphinx python domain, in my opinion this is very convenient syntax for clear documentation.
It would be nice if the LaTeX writer could be made to support this extension. Given that the C++ domain, for example, can generate incredibly complex signatures with multiple template parameter lists, template arguments at various positions, etc. all without any additional constraints imposed by the LaTeX writer, it would be nice if the LaTeX writer could somehow avoid imposing constraints on desc_type_parameter_list.
In the meantime, it seems like the easiest workaround will be to replace the desc_type_parameter_list nodes with other nodes.
How to Reproduce
N/A
Environment Information
N/A
Sphinx extensions
No response
Additional context
No response