@@ -450,6 +450,7 @@ class cpp_function : public function {
450
450
451
451
std::string signatures;
452
452
int index = 0 ;
453
+ bool first_user_def = true ;
453
454
/* Create a nice pydoc rec including all signatures and
454
455
docstrings of the functions in the overload chain */
455
456
if (chain && options::show_function_signatures ()) {
@@ -458,12 +459,16 @@ class cpp_function : public function {
458
459
signatures += it->signature ;
459
460
signatures += " \n " ;
460
461
}
461
- signatures += " \n Overloaded function.\n\n " ;
462
+ if (options::show_section_headings ())
463
+ signatures += " \n Overloaded function.\n\n " ;
464
+ else
465
+ first_user_def = false ;
462
466
}
463
467
// Then specific overload signatures
464
- bool first_user_def = true ;
468
+ const bool show_signature_headings = options::show_function_signatures ()
469
+ && options::show_section_headings ();
465
470
for (auto it = chain_start; it != nullptr ; it = it->next ) {
466
- if (options::show_function_signatures () ) {
471
+ if (show_signature_headings ) {
467
472
if (index > 0 ) signatures += " \n " ;
468
473
if (chain)
469
474
signatures += std::to_string (++index ) + " . " ;
@@ -472,15 +477,14 @@ class cpp_function : public function {
472
477
signatures += " \n " ;
473
478
}
474
479
if (it->doc && strlen (it->doc ) > 0 && options::show_user_defined_docstrings ()) {
475
- // If we're appending another docstring, and aren't printing function signatures, we
476
- // need to append a newline first:
477
- if (!options::show_function_signatures ()) {
478
- if (first_user_def) first_user_def = false ;
479
- else signatures += " \n " ;
480
- }
481
- if (options::show_function_signatures ()) signatures += " \n " ;
480
+ // If we're appending another docstring, and aren't printing signature headings,
481
+ // we need to append a newline first:
482
+ if (!show_signature_headings && first_user_def)
483
+ first_user_def = false ;
484
+ else
485
+ signatures += " \n " ;
482
486
signatures += it->doc ;
483
- if (options::show_function_signatures () ) signatures += " \n " ;
487
+ if (show_signature_headings ) signatures += " \n " ;
484
488
}
485
489
}
486
490
0 commit comments