@@ -450,6 +450,7 @@ class cpp_function : public function {
450450
451451 std::string signatures;
452452 int index = 0 ;
453+ bool first_user_def = true ;
453454 /* Create a nice pydoc rec including all signatures and
454455 docstrings of the functions in the overload chain */
455456 if (chain && options::show_function_signatures ()) {
@@ -458,12 +459,16 @@ class cpp_function : public function {
458459 signatures += it->signature ;
459460 signatures += " \n " ;
460461 }
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 ;
462466 }
463467 // 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 ();
465470 for (auto it = chain_start; it != nullptr ; it = it->next ) {
466- if (options::show_function_signatures () ) {
471+ if (show_signature_headings ) {
467472 if (index > 0 ) signatures += " \n " ;
468473 if (chain)
469474 signatures += std::to_string (++index) + " . " ;
@@ -472,15 +477,14 @@ class cpp_function : public function {
472477 signatures += " \n " ;
473478 }
474479 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 " ;
482486 signatures += it->doc ;
483- if (options::show_function_signatures () ) signatures += " \n " ;
487+ if (show_signature_headings ) signatures += " \n " ;
484488 }
485489 }
486490
0 commit comments