Skip to content

Commit 703bead

Browse files
committed
Added type annotations to func signature output by ToGoogleDocString.
1 parent 20c1855 commit 703bead

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cpp/pybind/docstring.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,24 @@ std::string FunctionDoc::ToGoogleDocString() const {
201201
for (size_t i = 0; i < overload.argument_docs_.size(); ++i) {
202202
const ArgumentDoc& argument_doc = overload.argument_docs_[i];
203203
rc << argument_doc.name_;
204+
if (argument_doc.type_ != "") {
205+
rc << ": " << argument_doc.type_;
206+
}
204207
if (argument_doc.default_ != "") {
205-
rc << "=" << argument_doc.default_;
208+
rc << " = " << argument_doc.default_;
206209
}
207210
if (i != overload.argument_docs_.size() - 1) {
208211
rc << ", ";
209212
}
210213
}
211-
rc << ")" << std::endl;
214+
rc << ")";
215+
216+
// Return type
217+
if (overload.return_doc_.type_ != "") {
218+
rc << " -> " << overload.return_doc_.type_;
219+
}
220+
221+
rc << std::endl;
212222

213223
// Summary line, strictly speaking this shall be at the very front.
214224
// However from a compiled Python module we need the function signature

0 commit comments

Comments
 (0)