From 4a5e8f69d29141e15bdb574d28c93beba124d1b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 4 May 2019 21:27:12 +0200 Subject: [PATCH] documentation/python: properly escape default values. --- documentation/python.py | 2 +- .../pybind_signatures/pybind_signatures.MyClass.html | 2 +- .../test_python/pybind_signatures/pybind_signatures.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/python.py b/documentation/python.py index 6b749314..032089d4 100755 --- a/documentation/python.py +++ b/documentation/python.py @@ -462,7 +462,7 @@ def extract_function_doc(state: State, parent, path: List[str], function) -> Lis # Don't include redundant type for the self argument if name == 'self': param.type = None else: param.type = type - param.default = default + param.default = html.escape(default or '') if type or default: out.has_complex_params = True # *args / **kwargs can still appear in the parsed signatures if diff --git a/documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html b/documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html index 4c104a0e..bbc62020 100644 --- a/documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html +++ b/documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html @@ -63,7 +63,7 @@
def instance_function_kwargs(self, hey: int, - what: str = 'eh?') -> Tuple[float, int] + what: str = '<eh?>') -> Tuple[float, int]
Instance method with position or keyword args
diff --git a/documentation/test_python/pybind_signatures/pybind_signatures.cpp b/documentation/test_python/pybind_signatures/pybind_signatures.cpp index ea145b27..40d055fb 100644 --- a/documentation/test_python/pybind_signatures/pybind_signatures.cpp +++ b/documentation/test_python/pybind_signatures/pybind_signatures.cpp @@ -52,7 +52,7 @@ PYBIND11_MODULE(pybind_signatures, m) { .def_static("static_function", &MyClass::staticFunction, "Static method with positional-only args") .def(py::init(), "Constructor") .def("instance_function", &MyClass::instanceFunction, "Instance method with positional-only args") - .def("instance_function_kwargs", &MyClass::instanceFunction, "Instance method with position or keyword args", py::arg("hey"), py::arg("what") = "eh?") + .def("instance_function_kwargs", &MyClass::instanceFunction, "Instance method with position or keyword args", py::arg("hey"), py::arg("what") = "") .def("another", &MyClass::another, "Instance method with no args, 'self' is thus position-only") .def_property("foo", &MyClass::foo, &MyClass::setFoo, "A read/write property"); } -- 2.30.2