@@ -104,6 +104,13 @@ void handle_variable(Cppyy::TCppScope_t var, std::ostringstream &file, int inden
104104void handle_variable (Cppyy::TCppScope_t var, std::ostringstream &file, int indent = 0 ) {
105105 std::string indentation_str = indentation (indent);
106106
107+ std::string doc = Cppyy::GetDoc (var);
108+ if (!doc.empty ()) {
109+ file << indentation_str
110+ << " # "
111+ << replace_all (doc, " \n " , " \n # " )
112+ << " \n " ;
113+ }
107114 file << indentation_str
108115 << Cppyy::GetFinalName (var)
109116 << " : "
@@ -114,6 +121,14 @@ void handle_variable(Cppyy::TCppScope_t var, std::ostringstream &file, int inden
114121void handle_typedef (Cppyy::TCppScope_t var, std::ostringstream &file, int indent) {
115122 std::string indentation_str = indentation (indent);
116123
124+ std::string doc = Cppyy::GetDoc (var);
125+ if (!doc.empty ()) {
126+ file << indentation_str
127+ << " # "
128+ << replace_all (doc, " \n " , " \n # " )
129+ << " \n " ;
130+ }
131+
117132 file << indentation_str
118133 << Cppyy::GetMethodName (var)
119134 << " = "
@@ -147,8 +162,7 @@ void handle_function(Cppyy::TCppScope_t fn, std::ostringstream &file, int indent
147162 bool prepend_comma = false ;
148163 if (Cppyy::IsMethod (fn) && !Cppyy::IsStaticMethod (fn)) {
149164 // add the implicit self argument
150- file << " self: "
151- << pythonize_type_name (class_name);
165+ file << " self: Self" ;
152166 prepend_comma = true ;
153167 }
154168 for (size_t i = 0 , nArgs = Cppyy::GetMethodNumArgs (fn); i < nArgs; i++) {
@@ -168,7 +182,16 @@ void handle_function(Cppyy::TCppScope_t fn, std::ostringstream &file, int indent
168182 }
169183 file << " ) -> "
170184 << pythonize_type_name (Cppyy::GetMethodReturnTypeAsString (fn))
171- << " : ...\n " ;
185+ << " :\n " ;
186+ std::string doc = Cppyy::GetDoc (fn);
187+ if (!doc.empty ()) {
188+ file << indentation_str
189+ << " \"\"\" "
190+ << replace_all (doc, " \"\"\" " , " \\\"\\\"\\\" " ) // replace """ -> \"\"\"
191+ << " \"\"\"\n " ;
192+ }
193+ file << indentation_str
194+ << " ...\n " ;
172195}
173196
174197void handle_templates (Cppyy::TCppScope_t tmpl, std::ostringstream &file, int indent) {
@@ -231,9 +254,18 @@ void handle_templates(Cppyy::TCppScope_t tmpl, std::ostringstream &file, int ind
231254 }
232255 file << " ) -> "
233256 << pythonize_type_name (Cppyy::GetMethodReturnTypeAsString (tmpl))
234- << " : ...\n " ;
257+ << " :\n " ;
258+ std::string doc = Cppyy::GetDoc (tmpl);
259+ if (!doc.empty ()) {
260+ file << indentation_str
261+ << " \"\"\" "
262+ << replace_all (doc, " \"\"\" " , " \\\"\\\"\\\" " ) // replace """ -> \"\"\"
263+ << " \"\"\"\n " ;
264+ }
265+ file << indentation_str
266+ << " ...\n " ;
235267 } else {
236- // is templated class
268+ // is templated class ???
237269 }
238270}
239271
@@ -257,6 +289,13 @@ void handle_class(Cppyy::TCppScope_t cls, std::ostringstream &file, int indent)
257289 file << " ]" ;
258290 }
259291 file << " :\n " ;
292+ std::string doc = Cppyy::GetDoc (cls);
293+ if (!doc.empty ()) {
294+ file << indentation_str
295+ << " \"\"\" "
296+ << replace_all (doc, " \"\"\" " , " \\\"\\\"\\\" " ) // replace """ -> \"\"\"
297+ << " \"\"\"\n\n " ;
298+ }
260299
261300 std::vector<Cppyy::TCppScope_t> members;
262301 Cppyy::GetDatamembers (cls, members);
@@ -284,9 +323,17 @@ void handle_class(Cppyy::TCppScope_t cls, std::ostringstream &file, int indent)
284323}
285324
286325void handle_namespace (Cppyy::TCppScope_t ns, std::ostringstream &file, int indent) {
326+ std::string indentation_str = indentation (indent);
287327 std::vector<Cppyy::TCppScope_t> members;
288328 Cppyy::GetMemberInNamespace (ns, members);
289329 file << " class " << Cppyy::GetMethodName (ns) << " :\n " ;
330+ std::string doc = Cppyy::GetDoc (ns);
331+ if (!doc.empty ()) {
332+ file << indentation_str
333+ << " \"\"\" "
334+ << replace_all (doc, " \"\"\" " , " \\\"\\\"\\\" " ) // replace """ -> \"\"\"
335+ << " \"\"\"\n\n " ;
336+ }
290337 for (Cppyy::TCppScope_t s: members)
291338 handle_scope (s, file, indent + 1 );
292339}
0 commit comments