[glibmm] gmmproc: Tidy up the generation of enum docs



commit 2a21d3c3d15e55bd541ce8c4b69f04a022da2340
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon Dec 1 18:36:23 2014 +0100

    gmmproc: Tidy up the generation of enum docs
    
    * tools/m4/gerror.m4: Add "/** " at the start of the documentation,
    like enum.m4 does.
    * tools/pm/DocsParser.pm: lookup_enum_documentation(): Don't add "/** "
    which is deleted by the caller. Add "\n * " with the right indentation.
    * tools/pm/Output.pm: output_wrap_enum(), output_wrap_enum_docs_only(),
    output_wrap_gerror(): Don't delete "/** ". Don't change indentation.

 tools/m4/gerror.m4     |    2 +-
 tools/pm/DocsParser.pm |   10 +++++-----
 tools/pm/Output.pm     |   25 ++++---------------------
 3 files changed, 10 insertions(+), 27 deletions(-)
---
diff --git a/tools/m4/gerror.m4 b/tools/m4/gerror.m4
index a8b8437..e48aef6 100644
--- a/tools/m4/gerror.m4
+++ b/tools/m4/gerror.m4
@@ -15,7 +15,7 @@ _POP()
 class __CPPNAME__ : public Glib::Error
 {
 public:
-  $6
+  /** $6
    */
   enum Code
   {
diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm
index 23af3a6..1997945 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/DocsParser.pm
@@ -233,9 +233,9 @@ sub parse_on_cdata($$)
   }
 }
 
-sub lookup_enum_documentation($$$)
+sub lookup_enum_documentation($$$$)
 {
-  my ($c_enum_name, $cpp_enum_name, $ref_flags) = @_;
+  my ($c_enum_name, $cpp_enum_name, $indent, $ref_flags) = @_;
   
   my @subst_in  = [];
   my @subst_out = [];
@@ -305,9 +305,9 @@ sub lookup_enum_documentation($$$)
   
   remove_example_code($c_enum_name, \$docs);
 
-  # Convert to Doxygen-style comment.
-  $docs =~ s/\n/\n \* /g;
-  $docs =  "\/\*\* " . $docs;
+  # Add indentation and an asterisk on all lines except the first.
+  # $docs does not contain leading "/**" and trailing "*/".
+  $docs =~ s/\n/\n${indent}\* /g;
 
   return $docs;
 }
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 3eff097..de13f5e 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -676,14 +676,7 @@ sub output_wrap_enum($$$$$$$)
 
   # Get the enum documentation from the parsed docs.
   my $enum_docs =
-    DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", \ flags);
-
-  # Remove initial Doxygen comment block start ('/**') from the enum docs
-  # to merge the passed in Doxygen comment block.
-  $enum_docs =~ s/\/\*\*\s+//g;
-  
-  # Make sure indentation of passed in comment is correct.
-  $comment =~ s/\n\s*\*/\n */g;
+    DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", " ", \ flags);
 
   # Merge the passed in comment to the existing enum documentation.
   $comment = $comment . "\n * " . $enum_docs;
@@ -707,7 +700,7 @@ sub output_wrap_enum_docs_only($$$$$$$)
  
   # Get the existing enum description from the parsed docs.
   my $enum_docs =
-    DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", \ flags);
+    DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", " ", \ flags);
 
   if($enum_docs eq "")
   {
@@ -718,15 +711,8 @@ sub output_wrap_enum_docs_only($$$$$$$)
   # Include the enum docs in the module's enum docs group.
   $enum_docs .= "\n * \ ingroup ${module_canonical}Enums\n";
 
-  # Remove initial Doxygen comment block start ('/**') from the enum docs
-  # to merge the passed in Doxygen comment block.
-  $enum_docs =~ s/\/\*\*\s+//g;
-  
   # Merge the passed in comment to the existing enum documentation.
-  $comment = "\/\*\* " . $comment . "\n * " . $enum_docs . "\n */\n";
-
-  # Make sure indentation of passed in comment is correct.
-  $comment =~ s/\n\s*\*/\n */g;
+  $comment = "/** " . $comment . "\n * " . $enum_docs . "\n */\n";
 
   $self->append($comment);
 }
@@ -762,10 +748,7 @@ sub output_wrap_gerror($$$$$$$)
 
   # Get the enum documentation from the parsed docs.
   my $enum_docs =
-    DocsParser::lookup_enum_documentation("$c_enum", "Code", \ flags);
-
-  # Make sure indentation of enum documentation is correct.
-  $enum_docs =~ s/\n\s*\*/\n   \*/g;
+    DocsParser::lookup_enum_documentation("$c_enum", "Code", "   ", \ flags);
 
   # Prevent Doxygen from auto-linking to a class called Error.
   $enum_docs =~ s/([^%])(Error code)/$1%$2/g;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]