pybind/pybind11

[BUG]: Use of pybind11::args or pybind11::kw_only results in a Sphinx warning due to the use of *

Open

#4.537 geöffnet am 27. Feb. 2023

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (2.005 Forks)batch import
enhancementhelp wantedsignatures

Repository-Metriken

Stars
 (14.677 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 2h) (10 gemergte PRs in 30 T)

Beschreibung

Required prerequisites

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