@@ -329,9 +329,43 @@ For example:
329
329
|
330
330
| Add two floating points numbers together.
331
331
332
- Calling ``options.disable_function_signatures() ``, as shown previously,
332
+ Calling ``options.disable_function_signatures() `` as shown previously,
333
333
will cause docstrings to be generated without the prepended function signatures
334
334
and without the section headings.
335
+ To disable only the sections headings, use ``options.disable_section_headings() ``:
336
+
337
+ .. code-block :: cpp
338
+
339
+ PYBIND11_MODULE(example, m) {
340
+ py::options options;
341
+ options.disable_section_headings();
342
+
343
+ m.def("add", [](int a, int b)->int { return a + b; },
344
+ "A function which adds two numbers.\n"); // Note the additional newline here.
345
+ m.def("add", [](float a, float b)->float { return a + b; },
346
+ "Internally, a simple addition is performed.");
347
+ m.def("add", [](py::none a, py::none b)->py::none { return py::none(); },
348
+ "Both numbers can be None, and None will be returned.");
349
+ }
350
+
351
+ The above example would produce the following docstring:
352
+
353
+ .. code-block :: pycon
354
+
355
+ >>> help(example.add)
356
+
357
+ add(...)
358
+ | add(arg0: int, arg1: int) -> int \
359
+ | add(arg0: float, arg1: float) -> float \
360
+ | add(arg0: None, arg1: None) -> None
361
+
362
+ | A function which adds two numbers.
363
+ |
364
+ | Internally, a simple addition is performed.
365
+ | Both numbers can be None, and None will be returned.
366
+
367
+ Not every overload must supply a docstring.
368
+ You may find it easier for a single overload to supply the entire docstring.
335
369
336
370
.. [#f4 ] http://www.sphinx-doc.org
337
371
.. [#f5 ] http://github.com/pybind/python_example
0 commit comments