chiark / gitweb /
documentation/python: properly escape default values.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 4 May 2019 19:27:12 +0000 (21:27 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 4 May 2019 19:27:12 +0000 (21:27 +0200)
documentation/python.py
documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html
documentation/test_python/pybind_signatures/pybind_signatures.cpp

index 6b749314957cf809df707df1d27d5fdd2ef9ea7f..032089d488fb6ae476a0356d2d7ddddee9efcb33 100755 (executable)
@@ -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
index 4c104a0e82d390fbb280a58503f208da743e8f88..bbc620206e9233e239d5a937e8787a80aed056ab 100644 (file)
@@ -63,7 +63,7 @@
             <dt>
               <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">instance_function_kwargs</a>(</span><span class="m-doc-wrap">self,
               hey: int,
-              what: str = 'eh?') -&gt; Tuple[float, int]</span>
+              what: str = &#x27;&lt;eh?&gt;&#x27;) -&gt; Tuple[float, int]</span>
             </dt>
             <dd>Instance method with position or keyword args</dd>
           </dl>
index ea145b272f4713ea3a15f306c9899101728e364e..40d055fbcdf8d7ff700f92cbd69cd7450d465c25 100644 (file)
@@ -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") = "<eh?>")
         .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");
 }