mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Avoid duplicating all signatures. Also get rid of "generic" signature.
This commit is contained in:
parent
62c7a35aba
commit
335878892f
@ -389,9 +389,7 @@ The above example would produce the following docstring:
|
|||||||
>>> help(example.add)
|
>>> help(example.add)
|
||||||
|
|
||||||
add(...)
|
add(...)
|
||||||
| add(arg0: int, arg1: int) -> int
|
| Overloaded function:
|
||||||
| add(arg0: float, arg1: float) -> float
|
|
||||||
| Overloaded function.
|
|
||||||
|
|
|
|
||||||
| 1. add(arg0: int, arg1: int) -> int
|
| 1. add(arg0: int, arg1: int) -> int
|
||||||
|
|
|
|
||||||
@ -403,7 +401,6 @@ The above example would produce the following docstring:
|
|||||||
|
|
||||||
Calling ``options.disable_function_signatures()`` as shown previously
|
Calling ``options.disable_function_signatures()`` as shown previously
|
||||||
will cause the docstrings of overloaded functions to be generated without the section headings.
|
will cause the docstrings of overloaded functions to be generated without the section headings.
|
||||||
The prepended overload signatures will remain:
|
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
@ -425,9 +422,6 @@ The above example would produce the following docstring:
|
|||||||
|
|
||||||
>>> help(example.add)
|
>>> help(example.add)
|
||||||
add(...)
|
add(...)
|
||||||
| add(arg0: int, arg1: int) -> int
|
|
||||||
| add(arg0: float, arg1: float) -> float
|
|
||||||
| add(arg0: None, arg1: None) -> None
|
|
||||||
| A function which adds two numbers.
|
| A function which adds two numbers.
|
||||||
|
|
|
|
||||||
| Internally, a simple addition is performed.
|
| Internally, a simple addition is performed.
|
||||||
|
@ -612,15 +612,8 @@ protected:
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
/* Create a nice pydoc rec including all signatures and
|
/* Create a nice pydoc rec including all signatures and
|
||||||
docstrings of the functions in the overload chain */
|
docstrings of the functions in the overload chain */
|
||||||
if (chain) {
|
if (chain && options::show_function_signatures()) {
|
||||||
for (auto *it = chain_start; it != nullptr; it = it->next) {
|
signatures += "Overloaded function:\n\n";
|
||||||
signatures += rec->name;
|
|
||||||
signatures += it->signature;
|
|
||||||
signatures += "\n";
|
|
||||||
}
|
|
||||||
if (options::show_function_signatures()) {
|
|
||||||
signatures += "Overloaded function.\n\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Then specific overload signatures
|
// Then specific overload signatures
|
||||||
bool first_user_def = true;
|
bool first_user_def = true;
|
||||||
|
@ -10,41 +10,23 @@ def test_docstring_options():
|
|||||||
assert m.test_function2.__doc__ == "A custom docstring"
|
assert m.test_function2.__doc__ == "A custom docstring"
|
||||||
|
|
||||||
# docstring specified on just the first overload definition:
|
# docstring specified on just the first overload definition:
|
||||||
assert m.test_overloaded1.__doc__ == (
|
assert m.test_overloaded1.__doc__ == "Overload docstring"
|
||||||
"test_overloaded1(i: int) -> None\n"
|
|
||||||
"test_overloaded1(d: float) -> None\n"
|
|
||||||
"Overload docstring"
|
|
||||||
)
|
|
||||||
|
|
||||||
# docstring on both overloads:
|
# docstring on both overloads:
|
||||||
assert m.test_overloaded2.__doc__ == (
|
assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2"
|
||||||
"test_overloaded2(i: int) -> None\n"
|
|
||||||
"test_overloaded2(d: float) -> None\n"
|
|
||||||
"overload docstring 1\n"
|
|
||||||
"overload docstring 2"
|
|
||||||
)
|
|
||||||
|
|
||||||
# docstring on only second overload:
|
# docstring on only second overload:
|
||||||
assert m.test_overloaded3.__doc__ == (
|
assert m.test_overloaded3.__doc__ == "Overload docstr"
|
||||||
"test_overloaded3(i: int) -> None\n"
|
|
||||||
"test_overloaded3(d: float) -> None\n"
|
|
||||||
"Overload docstr"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check overload configuration behaviour matches the documentation
|
# Check overload configuration behaviour matches the documentation
|
||||||
assert m.test_overloaded4.__doc__ == (
|
assert m.test_overloaded4.__doc__ == (
|
||||||
"test_overloaded4(arg0: int, arg1: int) -> int\n"
|
|
||||||
"test_overloaded4(arg0: float, arg1: float) -> float\n"
|
|
||||||
"test_overloaded4(arg0: None, arg1: None) -> None\n"
|
|
||||||
"A function which adds two numbers.\n\n"
|
"A function which adds two numbers.\n\n"
|
||||||
"Internally, a simple addition is performed.\n"
|
"Internally, a simple addition is performed.\n"
|
||||||
"Both numbers can be None, and None will be returned."
|
"Both numbers can be None, and None will be returned."
|
||||||
)
|
)
|
||||||
|
|
||||||
assert m.test_overloaded5.__doc__ == (
|
assert m.test_overloaded5.__doc__ == (
|
||||||
"test_overloaded5(arg0: int, arg1: int) -> int\n"
|
"Overloaded function:\n"
|
||||||
"test_overloaded5(arg0: float, arg1: float) -> float\n"
|
|
||||||
"Overloaded function.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"1. test_overloaded5(arg0: int, arg1: int) -> int\n"
|
"1. test_overloaded5(arg0: int, arg1: int) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -88,11 +88,7 @@ def test_init_factory_signature(msg):
|
|||||||
assert (
|
assert (
|
||||||
msg(m.TestFactory1.__init__.__doc__)
|
msg(m.TestFactory1.__init__.__doc__)
|
||||||
== """
|
== """
|
||||||
__init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int) -> None
|
Overloaded function:
|
||||||
__init__(self: m.factory_constructors.TestFactory1, arg0: str) -> None
|
|
||||||
__init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.pointer_tag) -> None
|
|
||||||
__init__(self: m.factory_constructors.TestFactory1, arg0: object, arg1: int, arg2: object) -> None
|
|
||||||
Overloaded function.
|
|
||||||
|
|
||||||
1. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int) -> None
|
1. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.unique_ptr_tag, arg1: int) -> None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user