Re: [PATCH] <![CDATA[ and ]]> in the description in the source.
- From: Shiino Yuki <shiino yuki be to>
- To: gtk-doc-list gnome org
- Subject: Re: [PATCH] <![CDATA[ and ]]> in the description in the source.
- Date: Sun, 29 Oct 2006 22:52:28 +0900
Hi, Yeti,
Thank you for your quick reply and bug report.
I ashamed my careless mistake.
> > ...
> > - print OUTPUT &ExpandAbbreviationsExceptCDATA($contents);
> > + print OUTPUT &ExpandAbbreviationsExceptCDATAExceptCDATA($contents);
> > ...
>
> A bit too careless application of search and replace?
Yes, you are right. The attached patch is the fixed version.
Thanks very much.
--
Shiino Yuki <shiino yuki be to>
diff -Naur gtk-doc.cvs/gtkdoc-mkdb.in gtk-doc/gtkdoc-mkdb.in
--- gtk-doc.cvs/gtkdoc-mkdb.in 2006-10-14 23:01:13.000000000 +0900
+++ gtk-doc/gtkdoc-mkdb.in 2006-10-29 22:31:17.000000000 +0900
@@ -790,7 +790,7 @@
my $parameters_output = 0;
if (defined ($SymbolDocs{$symbol})) {
- my $symbol_docs = &ExpandAbbreviations($SymbolDocs{$symbol});
+ my $symbol_docs = &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
# Try to insert the parameter table at the author's desired position.
# Otherwise we need to tag it onto the end.
@@ -835,7 +835,7 @@
$desc .= &MakeDeprecationNote($symbol);
if (defined ($SymbolDocs{$symbol})) {
- $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});
+ $desc .= &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
}
$desc .= OutputSymbolTraits ($symbol);
$desc .= "</refsect2>\n";
@@ -957,7 +957,7 @@
$desc .= &MakeDeprecationNote($symbol);
if (defined ($SymbolDocs{$symbol})) {
- $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});
+ $desc .= &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
}
# Create a table of fields and descriptions
@@ -998,7 +998,7 @@
$desc .= "<varlistentry>\n<term>$text</term>\n";
if (defined $field_descr) {
- $desc .= "<listitem><simpara>".&ExpandAbbreviations($field_descr)."</simpara></listitem>\n";
+ $desc .= "<listitem><simpara>".&ExpandAbbreviationsExceptCDATA($field_descr)."</simpara></listitem>\n";
} else {
$desc .= "<listitem></listitem>\n";
}
@@ -1035,7 +1035,7 @@
$desc .= &MakeDeprecationNote($symbol);
if (defined ($SymbolDocs{$symbol})) {
- $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});
+ $desc .= &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
}
# Create a table of fields and descriptions
@@ -1069,7 +1069,7 @@
$condition = &MakeConditionDescription ($member_name);
$desc .= "<varlistentry>\n<term><anchor id=\"$id\" role=\"constant\"${condition}${empty_element_end}<literal>$member_name</literal></term>\n";
if (defined $member_descr) {
- $desc .= "<listitem><simpara>".&ExpandAbbreviations($member_descr)."</simpara></listitem>\n";
+ $desc .= "<listitem><simpara>".&ExpandAbbreviationsExceptCDATA($member_descr)."</simpara></listitem>\n";
} else {
$desc .= "<listitem></listitem>\n";
}
@@ -1107,7 +1107,7 @@
$desc .= &MakeDeprecationNote($symbol);
if (defined ($SymbolDocs{$symbol})) {
- $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});
+ $desc .= &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
}
$desc .= OutputSymbolTraits ($symbol);
$desc .= "</refsect2>\n";
@@ -1148,7 +1148,7 @@
$desc .= &MakeDeprecationNote($symbol);
if (defined ($SymbolDocs{$symbol})) {
- $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});
+ $desc .= &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
}
$desc .= OutputSymbolTraits ($symbol);
$desc .= "</refsect2>\n";
@@ -1326,7 +1326,7 @@
my $parameters_output = 0;
if (defined ($SymbolDocs{$symbol})) {
- my $symbol_docs = &ExpandAbbreviations($SymbolDocs{$symbol});
+ my $symbol_docs = &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
# Try to insert the parameter table at the author's desired position.
# Otherwise we need to tag it onto the end.
@@ -1367,12 +1367,12 @@
my $param_name = $$params[$j];
my $param = $$params[$j + 1];
if ($param_name eq "Returns") {
- $returns = &ExpandAbbreviations($param);
+ $returns = &ExpandAbbreviationsExceptCDATA($param);
} else {
if ($param_name eq "Varargs") {
$param_name = "...";
}
- $param = &ExpandAbbreviations($param);
+ $param = &ExpandAbbreviationsExceptCDATA($param);
$params_desc .= "<varlistentry><term><parameter>$param_name</parameter> :</term>\n<listitem><simpara>$param</simpara></listitem></varlistentry>\n";
}
}
@@ -1474,21 +1474,21 @@
# $short_desc = "one line description goes here.";
$short_desc = "";
} else {
- $short_desc = &ExpandAbbreviations($short_desc);
+ $short_desc = &ExpandAbbreviationsExceptCDATA($short_desc);
# print "Found short_desc: $short_desc";
}
my $long_desc = $SymbolDocs{"$TMPL_DIR/$file:Long_Description"};
if (!defined ($long_desc) || $long_desc =~ m/^\s*$/) {
$long_desc = "<para>\nA longer description goes here.\n</para>\n";
} else {
- $long_desc = &ExpandAbbreviations($long_desc);
+ $long_desc = &ExpandAbbreviationsExceptCDATA($long_desc);
# print "Found long_desc: $long_desc";
}
my $see_also = $SymbolDocs{"$TMPL_DIR/$file:See_Also"};
if (!defined ($see_also) || $see_also =~ m%^\s*(<para>)?\s*(</para>)?\s*$%) {
$see_also = "";
} else {
- $see_also = &ExpandAbbreviations($see_also);
+ $see_also = &ExpandAbbreviationsExceptCDATA($see_also);
# print "Found see_also: $see_also";
}
if ($see_also) {
@@ -1764,17 +1764,37 @@
sub ConvertSGMLChars {
my ($text) = @_;
- if ($SGML_MODE) {
- $text =~ s/&(?![a-zA-Z#])/&/g; # Do this first, or the others get messed up.
- $text =~ s/<(?![a-zA-Z\/!])/</g;
- $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
- }
- else {
+
+ if (! $SGML_MODE) {
$text =~ s/&/&/g; # Do this first, or the others get messed up.
$text =~ s/</</g;
$text =~ s/>/>/g;
+ return $text;
}
- return $text;
+
+ # SGML mode.
+ my ($i, $part, @out);
+ foreach $part (split /<!\[CDATA\[/, $text) {
+ if (defined $i) {
+ my @p = split /]]>/, $part;
+ if (scalar @p != 2) {
+ warn "Cannot find CDATA section end";
+ @p = ('', join(']]>', @p));
+ }
+ $p[1] =~ s/&(?![a-zA-Z#])/&/g; # Do this first, or the others get messed up.
+ $p[1] =~ s/<(?![a-zA-Z\/!])/</g;
+ $p[1] =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
+ push @out, join(']]>', @p);
+ }
+ else {
+ $part =~ s/&(?![a-zA-Z#])/&/g; # Do this first, or the others get messed up.
+ $part =~ s/<(?![a-zA-Z\/!])/</g;
+ $part =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
+ push @out, $part;
+ }
+ $i = 'really inside CDATA';
+ }
+ return join('<![CDATA[', @out);
}
@@ -1929,7 +1949,7 @@
$desc .= "<para><literal>$symbol</literal> is deprecated and should not be used in newly-written code.";
}
if ($Deprecated{$symbol} ne "") {
- $note = &ExpandAbbreviations($Deprecated{$symbol});
+ $note = &ExpandAbbreviationsExceptCDATA($Deprecated{$symbol});
$note =~ s/^\s*([0-9\.]+)\s*:\s*//;
$note =~ s/^\s+//;
$note =~ s/\s+$//;
@@ -2370,7 +2390,7 @@
$AllSymbols{$symbol} = 1;
if (defined ($SymbolDocs{$symbol})) {
- my $symbol_docs = &ExpandAbbreviations($SymbolDocs{$symbol});
+ my $symbol_docs = &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
# Try to insert the parameter table at the author's desired
# position. Otherwise we need to tag it onto the end.
@@ -2468,7 +2488,7 @@
my $blurb;
if (defined($SymbolDocs{$symbol}) &&
!IsEmptyDoc($SymbolDocs{$symbol})) {
- $blurb = &ExpandAbbreviations($SymbolDocs{$symbol});
+ $blurb = &ExpandAbbreviationsExceptCDATA($SymbolDocs{$symbol});
$AllDocumentedSymbols{$symbol} = 1;
}
else {
@@ -3069,9 +3089,24 @@
$src_doc =~ s%\n+\s*<!--PARAMETERS-->\s*\n+%\n</para>\n<!--PARAMETERS-->\n<para>\n%g;
# If there is a blank line, finish the paragraph and start another.
- if ($src_doc =~ s%\n{2,}%\n</para>\n<para>\n%g) {
-# print "Converted blank lines:\n$src_doc\n";
+ my ($i, $part, @out);
+ foreach $part (split /<!\[CDATA\[/, $src_doc) {
+ if (defined $i) {
+ my @p = split /]]>/, $part;
+ if (scalar @p != 2) {
+ warn "Cannot find CDATA section end";
+ @p = ('', join(']]>', @p));
+ }
+ $p[1] =~ s%\n{2,}%\n</para>\n<para>\n%g;
+ push @out, join(']]>', @p);
+ }
+ else {
+ $part =~ s%\n{2,}%\n</para>\n<para>\n%g;
+ push @out, $part;
+ }
+ $i = 'really inside CDATA';
}
+ $src_doc = join('<![CDATA[', @out);
if ($symbol =~ m/$TMPL_DIR\/.+:Long_Description/) {
# FIXME: should we check for empty $tmpl_doc ?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]