[gtk-doc] mkdb: also pretty print/filter enum declarations
- From: Stefan Kost <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] mkdb: also pretty print/filter enum declarations
- Date: Thu, 8 Sep 2011 17:14:37 +0000 (UTC)
commit 61a247a870ae07f5ae02537450bbc483b4a439cd
Author: Stefan Sauer <ensonic users sf net>
Date: Thu Sep 8 19:13:38 2011 +0200
mkdb: also pretty print/filter enum declarations
Strip private enums from the declaration in the docs. Fixes #617121.
gtkdoc-common.pl.in | 2 ++
gtkdoc-mkdb.in | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/gtkdoc-common.pl.in b/gtkdoc-common.pl.in
index af43e07..5175473 100644
--- a/gtkdoc-common.pl.in
+++ b/gtkdoc-common.pl.in
@@ -288,6 +288,8 @@ sub ParseEnumDeclaration {
die "Enum declaration '$declaration' does not begin with 'typedef enum {' or 'enum XXX {'\n";
}
+ # TRACE@("public fields in enum: $declaration");
+
# Treat lines in sequence.
while ($declaration =~ m/\s*([^,\}]+)([,\}])/msg) {
my $line = $1;
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 996ea58..fe37697 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -1813,7 +1813,43 @@ sub OutputEnum {
$desc .= "\n";
$desc .= OutputSymbolExtraLinks($symbol);
- my $decl_out = &CreateValidSGML ($declaration);
+ my $decl_out = "";
+ my $public = 1;
+ my $new_declaration = "";
+ my $decl_line;
+ my $decl = $declaration;
+
+ if ($decl =~ m/^\s*(typedef\s+)?enum\s*\w*\s*(?:\/\*.*\*\/)?\s*{(.*)}\s*\w*\s*;\s*$/s) {
+ my $has_typedef = ($1 ne "")? 1 : 0;
+ my $enum_contents = $2;
+
+ foreach $decl_line (split (/\n/, $enum_contents)) {
+ #print "Enum line: $decl_line\n";
+ if ($decl_line =~ m%/\*\s*<\s*public\s*>\s*\*/%) {
+ $public = 1;
+ } elsif ($decl_line =~ m%/\*\s*<\s*(private|protected)\s*>\s*\*/%) {
+ $public = 0;
+ } elsif ($public) {
+ $new_declaration .= $decl_line . "\n";
+ }
+ }
+
+ if ($new_declaration) {
+ # Strip any blank lines off the ends.
+ $new_declaration =~ s/^\s*\n//;
+ $new_declaration =~ s/\n\s*$/\n/;
+
+ if ($has_typedef) {
+ $decl_out = "typedef enum {\n" . $new_declaration
+ . "} $symbol;\n";
+ } else {
+ $decl_out = "enum $symbol {\n" . $new_declaration
+ . "};\n";
+ }
+ }
+ }
+
+ $decl_out = &CreateValidSGML ($decl_out);
$desc .= "<programlisting>$decl_out</programlisting>\n";
$desc .= &MakeDeprecationNote($symbol);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]