[BUG]: Use of pybind11::args or pybind11::kw_only results in a Sphinx warning due to the use of *
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
3cc7e4258c15a6a19ba5e0b62a220b1a6196d4eb
Problem description
The function initialize_generic in pybind11.h adds the signature of overloads as part of the docs string if show_function_signatures is true. This signature is not marked as code and hence any use of * in that signature are not correctly interpreted by sphinx, causing an "Inline emphasis start-string without end-string" warning.
A minimal fix is changing this line to
signatures += std::regex_replace(std::string(it->signature), std::regex("\\*"), "\\*"); // making sure * are escaped
Alternatively, the name + signature could also be surrounded by a code block or inline code markers.
The nicest IMO would be for the signatures to be presented in the same style that member functions of a class are, though I don't know how that would need to be done.
Reproducible example code
void createBinding(pybind11::module &m) {
m.def("foo", [&](pybind11::args args) {
// ...;
});
}
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in include/pybind11/pybind11.h around line 582, where initialize_generic adds overload signatures when show_function_signatures is enabled. Reproduce the warning with the provided pybind11::args example and inspect how the generated signature is passed to Sphinx. Done means signatures containing * are rendered without an "Inline emphasis start-string without end-string" warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100