4 # gtk-doc - GTK DocBook documentation generator.
5 # Copyright (C) 1998 Damon Chaplin
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #############################################################################
23 # Script : gtkdoc-mkdb
24 # Description : This creates the DocBook files from the edited templates.
26 # NOTE: When creating SGML IDS, we append ":CAPS" to all
27 # all-caps identifiers to prevent name clashes. (It basically
28 # never is the case that mixed-case identifiers would collide.)
29 # See the CreateValidSGMLID function.
30 #############################################################################
35 unshift @INC, '@PACKAGE_DATA_DIR@';
36 require "gtkdoc-common.pl";
40 # name of documentation module
45 my $SOURCE_SUFFIXES = "";
46 my $IGNORE_FILES = "";
49 my $OUTPUT_ALL_SYMBOLS;
51 my $EXPAND_CONTENT_FILES = "";
53 my $DEFAULT_STABILITY;
57 my %optctl = (module => \$MODULE,
58 'source-dir' => \@SOURCE_DIRS,
59 'source-suffixes' => \$SOURCE_SUFFIXES,
60 'ignore-files' => \$IGNORE_FILES,
61 'output-dir' => \$SGML_OUTPUT_DIR,
62 'tmpl-dir' => \$TMPL_DIR,
63 'version' => \$PRINT_VERSION,
64 'help' => \$PRINT_HELP,
65 'main-sgml-file' => \$MAIN_SGML_FILE,
66 'expand-content-files' => \$EXPAND_CONTENT_FILES,
67 'outputallsymbols' => \$OUTPUT_ALL_SYMBOLS,
68 'sgml-mode' => \$SGML_MODE,
69 'default-stability' => \$DEFAULT_STABILITY,
70 'default-includes' => \$DEFAULT_INCLUDES,
71 'output-format' => \$OUTPUT_FORMAT);
72 GetOptions(\%optctl, "module=s", "source-dir:s", "source-suffixes:s", "ignore-files:s", "output-dir:s", "tmpl-dir:s", "version", "outputallsymbols", "expand-content-files:s", "main-sgml-file:s", "extra-db-files:s", "help", "sgml-mode", "default-stability:s", "default-includes:s", "output-format:s");
83 if ($DEFAULT_STABILITY && $DEFAULT_STABILITY ne "Stable"
84 && $DEFAULT_STABILITY ne "Private" && $DEFAULT_STABILITY ne "Unstable") {
89 print "gtkdoc-mkdb version @VERSION@\n";
90 print "\n--module=MODULE_NAME Name of the doc module being parsed";
91 print "\n--source-dir=DIRNAME Directories which contain inline reference material";
92 print "\n--source-suffixes=SUFFIXES Suffixes of source files to scan, comma-separated";
93 print "\n--ignore-files=FILES Files or directories which should not be scanned";
94 print "\n May be used more than once for multiple directories";
95 print "\n--output-dir=DIRNAME Directory to put the generated DocBook files in";
96 print "\n--tmpl-dir=DIRNAME Directory in which template files may be found";
97 print "\n--main-sgml-file=FILE File containing the toplevel DocBook file.";
98 print "\n--expand-content-files=FILES Extra DocBook files to expand abbreviations in.";
99 print "\n--output-format=FORMAT The format to use for the generated docbook, XML or SGML.";
100 print "\n--sgml-mode Allow DocBook markup in inline documentation.";
101 print "\n--default-stability=LEVEL Specify default stability Level. Valid values are";
102 print "\n Stable, Unstable, or Private.";
103 print "\n--default-includes=FILENAMES Specify default includes for section Synopsis";
104 print "\n--version Print the version of this program";
105 print "\n--help Print this help\n";
109 if (!$MAIN_SGML_FILE) {
110 $MAIN_SGML_FILE="${MODULE}-docs.sgml";
113 my ($empty_element_end, $doctype_header);
115 if (lc($OUTPUT_FORMAT) eq "xml") {
116 $OUTPUT_FORMAT = "xml";
117 $empty_element_end = "/>";
119 if ($MAIN_SGML_FILE && -e $MAIN_SGML_FILE) {
120 open(INPUT, "<$MAIN_SGML_FILE") || die "Can't open $MAIN_SGML_FILE";
121 $doctype_header = "";
123 if (/^\s*<(book|chapter|article)/) {
124 if ($_ !~ m/http:\/\/www.w3.org\/200[13]\/XInclude/) {
125 $doctype_header = "";
129 $doctype_header .= $_;
134 "<?xml version=\"1.0\"?>\n" .
135 "<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\n" .
136 " \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">\n";
138 $doctype_header =~ s/<!DOCTYPE \w+/<!DOCTYPE refentry/;
140 $OUTPUT_FORMAT = "sgml";
141 $doctype_header = "";
142 $empty_element_end = ">";
147 # All the files are written in subdirectories beneath here.
148 $TMPL_DIR = $TMPL_DIR ? $TMPL_DIR : "$ROOT_DIR/tmpl";
150 # This is where we put all the DocBook output.
151 $SGML_OUTPUT_DIR = $SGML_OUTPUT_DIR ? $SGML_OUTPUT_DIR : "$ROOT_DIR/$OUTPUT_FORMAT";
153 # This file contains the object hierarchy.
154 my $OBJECT_TREE_FILE = "$ROOT_DIR/$MODULE.hierarchy";
156 # This file contains the interfaces.
157 my $INTERFACES_FILE = "$ROOT_DIR/$MODULE.interfaces";
159 # This file contains the prerequisites.
160 my $PREREQUISITES_FILE = "$ROOT_DIR/$MODULE.prerequisites";
162 # This file contains signal arguments and names.
163 my $SIGNALS_FILE = "$ROOT_DIR/$MODULE.signals";
165 # The file containing Arg information.
166 my $ARGS_FILE = "$ROOT_DIR/$MODULE.args";
168 # These global arrays store information on signals. Each signal has an entry
169 # in each of these arrays at the same index, like a multi-dimensional array.
170 my @SignalObjects; # The GtkObject which emits the signal.
171 my @SignalNames; # The signal name.
172 my @SignalReturns; # The return type.
173 my @SignalFlags; # Flags for the signal
174 my @SignalPrototypes; # The rest of the prototype of the signal handler.
176 # These global arrays store information on Args. Each Arg has an entry
177 # in each of these arrays at the same index, like a multi-dimensional array.
178 my @ArgObjects; # The GtkObject which has the Arg.
179 my @ArgNames; # The Arg name.
180 my @ArgTypes; # The Arg type - gint, GtkArrowType etc.
181 my @ArgFlags; # How the Arg can be used - readable/writable etc.
182 my @ArgNicks; # The nickname of the Arg.
183 my @ArgBlurbs; # Docstring of the Arg.
184 my @ArgDefaults; # Default value of the Arg.
185 my @ArgRanges; # The range of the Arg type
186 # These global hashes store declaration info keyed on a symbol name.
188 my %DeclarationTypes;
189 my %DeclarationConditional;
190 my %DeclarationOutput;
194 my %StructHasTypedef;
196 # These global hashes store the existing documentation.
201 # These global hashes store documentation scanned from the source files.
202 my %SourceSymbolDocs;
203 my %SourceSymbolParams;
205 # all documentation goes in here, so we can do coverage analysis
207 my %AllIncompleteSymbols;
208 my %AllDocumentedSymbols;
210 # Undeclared yet documented symbols
211 my %UndeclaredSymbols;
213 # These global arrays store GtkObject and subclasses and the hierarchy.
220 # holds the symbols which are mentioned in $MODULE-sections.txt
223 # Standard C preprocessor directives, which we ignore for '#' abbreviations.
224 my %PreProcessorDirectives;
225 $PreProcessorDirectives{"assert"} = 1;
226 $PreProcessorDirectives{"define"} = 1;
227 $PreProcessorDirectives{"elif"} = 1;
228 $PreProcessorDirectives{"else"} = 1;
229 $PreProcessorDirectives{"endif"} = 1;
230 $PreProcessorDirectives{"error"} = 1;
231 $PreProcessorDirectives{"if"} = 1;
232 $PreProcessorDirectives{"ifdef"} = 1;
233 $PreProcessorDirectives{"ifndef"} = 1;
234 $PreProcessorDirectives{"include"} = 1;
235 $PreProcessorDirectives{"line"} = 1;
236 $PreProcessorDirectives{"pragma"} = 1;
237 $PreProcessorDirectives{"unassert"} = 1;
238 $PreProcessorDirectives{"undef"} = 1;
239 $PreProcessorDirectives{"warning"} = 1;
241 # Create the root DocBook output directory if it doens't exist.
242 if (! -e $SGML_OUTPUT_DIR) {
243 mkdir ("$SGML_OUTPUT_DIR", 0777)
244 || die "Can't create directory: $SGML_OUTPUT_DIR";
247 # Function and other declaration output settings.
248 my $RETURN_TYPE_FIELD_WIDTH = 20;
249 my $SYMBOL_FIELD_WIDTH = 36;
250 my $SIGNAL_FIELD_WIDTH = 16;
252 &ReadKnownSymbols ("$ROOT_DIR/$MODULE-sections.txt");
253 &ReadSignalsFile ($SIGNALS_FILE);
254 &ReadArgsFile ($ARGS_FILE);
255 &ReadObjectHierarchy;
259 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-decl.txt", 0);
260 if (-f "$ROOT_DIR/$MODULE-overrides.txt") {
261 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-overrides.txt", 1);
264 for my $dir (@SOURCE_DIRS) {
265 &ReadSourceDocumentation ($dir);
268 my $changed = &OutputSGML ("$ROOT_DIR/$MODULE-sections.txt");
270 # If any of the DocBook SGML files have changed, update the timestamp file (so
271 # it can be used for Makefile dependencies).
272 if ($changed || ! -e "$ROOT_DIR/sgml.stamp") {
273 open (TIMESTAMP, ">$ROOT_DIR/sgml.stamp")
274 || die "Can't create $ROOT_DIR/sgml.stamp";
275 print (TIMESTAMP "timestamp");
279 #############################################################################
280 # Function : OutputObjectList
281 # Description : This outputs the alphabetical list of objects, in a columned
282 # table. FIXME: Currently this also outputs ancestor objects
283 # which may not actually be in this module.
285 #############################################################################
287 sub OutputObjectList {
289 my $old_object_index = "$SGML_OUTPUT_DIR/object_index.sgml";
290 my $new_object_index = "$SGML_OUTPUT_DIR/object_index.new";
292 open (OUTPUT, ">$new_object_index")
293 || die "Can't create $new_object_index";
294 print (OUTPUT <<EOF);
295 <informaltable pgwide="1" frame="none">
296 <tgroup cols="$cols">
297 <colspec colwidth="1*"${empty_element_end}
298 <colspec colwidth="1*"${empty_element_end}
299 <colspec colwidth="1*"${empty_element_end}
305 foreach $object (sort(@Objects)) {
306 my $xref = &MakeXRef ($object);
307 if ($count % $cols == 0) { print (OUTPUT "<row>\n"); }
308 print (OUTPUT "<entry>$xref</entry>\n");
309 if ($count % $cols == ($cols - 1)) { print (OUTPUT "</row>\n"); }
313 # emit an empty row, since empty tables are invalid
314 print (OUTPUT "<row><entry> </entry></row>\n");
317 print (OUTPUT <<EOF);
318 </tbody></tgroup></informaltable>
322 &UpdateFileIfChanged ($old_object_index, $new_object_index, 0);
326 #############################################################################
327 # Function : OutputSGML
328 # Description : This collects the output for each section of the docs, and
329 # outputs each file when the end of the section is found.
330 # Arguments : $file - the $MODULE-sections.txt file which contains all of
331 # the functions/macros/structs etc. being documented, organised
332 # into sections and subsections.
333 #############################################################################
338 # print "Reading: $file\n";
340 || die "Can't open $file";
342 my $book_bottom = "";
343 my $includes = (defined $DEFAULT_INCLUDES) ? $DEFAULT_INCLUDES : "";
344 my $section_includes = "";
352 my $signals_synop = "";
353 my $signals_desc = "";
355 my $child_args_synop = "";
356 my $style_args_synop = "";
358 my $child_args_desc = "";
359 my $style_args_desc = "";
362 my $implementations = "";
363 my $prerequisites = "";
365 my @file_objects = ();
371 } elsif (m/^<SECTION>/) {
378 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
382 } elsif (m/^<SUBSECTION>/) {
384 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
386 # print "Section: $title\n";
388 # We don't want warnings if object & class structs aren't used.
389 $DeclarationOutput{$title} = 1;
390 $DeclarationOutput{"${title}Class"} = 1;
392 } elsif (m/^<FILE>(.*)<\/FILE>/) {
399 &ReadTemplateFile ("$TMPL_DIR/$file", 1);
400 &MergeSourceDocumentation;
402 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
404 $section_includes = $1;
406 if (defined $DEFAULT_INCLUDES) {
408 WARNING: Default <INCLUDE> being overridden by command line option
416 } elsif (m/^<\/SECTION>/) {
420 # print "End of section: $title\n";
424 my $section_id = $SourceSymbolDocs{"$TMPL_DIR/$file:Section_Id"};
425 if (defined ($section_id) && $section_id !~ m/^\s*$/) {
426 # Do nothing. Use section_id as it is.
427 } elsif (&CheckIsObject ($title)) {
428 # GtkObjects use their class name as the ID.
429 $section_id = &CreateValidSGMLID ($title);
431 $section_id = &CreateValidSGMLID ("$MODULE-$title");
434 if ($num_symbols > 0) {
435 if (lc($OUTPUT_FORMAT) eq "xml") {
436 $book_bottom .= " <xi:include href=\"xml/$file.xml\"/>\n";
438 $book_top.="<!ENTITY $section_id SYSTEM \"sgml/$file.sgml\">\n";
439 $book_bottom .= " &$section_id;\n";
442 if (defined ($SourceSymbolDocs{"$TMPL_DIR/$file:Include"})) {
443 if ($section_includes) {
445 WARNING: Section <INCLUDE> for file $file being overridden by inline comments
448 $section_includes = $SourceSymbolDocs{"$TMPL_DIR/$file:Include"};
450 if ($section_includes eq "") {
451 $section_includes = $includes;
454 if ($signals_synop ne '') {
455 $signals_synop = <<EOF;
456 <refsect1 role="signal_proto">
457 <title role="signal_proto.title">Signals</title>
460 ${signals_synop}</synopsis>
463 $signals_desc = <<EOF;
464 <refsect1 role="signals">
465 <title role="signals.title">Signal Details</title>
471 if ($args_synop ne '') {
473 <refsect1 role="properties">
474 <title role="properties.title">Properties</title>
477 ${args_synop}</synopsis>
481 <refsect1 role="property_details">
482 <title role="property_details.title">Property Details</title>
488 if ($child_args_synop ne '') {
489 $args_synop .= <<EOF;
490 <refsect1 role="child_properties">
491 <title role="child_properties.title">Child Properties</title>
494 ${child_args_synop}</synopsis>
498 <refsect1 role="child_property_details">
499 <title role="child_property_details.title">Child Property Details</title>
505 if ($style_args_synop ne '') {
506 $args_synop .= <<EOF;
507 <refsect1 role="style_properties">
508 <title role="style_properties.title">Style Properties</title>
511 ${style_args_synop}</synopsis>
515 <refsect1 role="style_properties_details">
516 <title role="style_properties_details.title">Style Property Details</title>
522 if ($hierarchy ne "") {
524 <refsect1 role="object_hierarchy">
525 <title role="object_hierarchy.title">Object Hierarchy</title>
531 if ($interfaces ne "") {
533 <refsect1 role="impl_interfaces">
534 <title role="impl_interfaces.title">Implemented Interfaces</title>
540 if ($implementations ne "") {
541 $implementations = <<EOF;
542 <refsect1 role="implementations">
543 <title role="implementations.title">Known Implementations</title>
549 if ($prerequisites ne "") {
550 $prerequisites = <<EOF;
551 <refsect1 role="prerequisites">
552 <title role="prerequisites.title">Prerequisites</title>
558 if ($derived ne "") {
560 <refsect1 role="derived_interfaces">
561 <title role="derived_interfaces.title">Known Derived Interfaces</title>
567 my $file_changed = &OutputSGMLFile ($file, $title, $section_id,
569 \$synopsis, \$details,
570 \$signals_synop, \$signals_desc,
571 \$args_synop, \$args_desc,
572 \$hierarchy, \$interfaces,
574 \$prerequisites, \$derived,
583 $section_includes = "";
587 $child_args_synop = "";
588 $style_args_synop = "";
590 $child_args_desc = "";
591 $style_args_desc = "";
594 $implementations = "";
598 } elsif (m/^(\S+)/) {
600 # print " Symbol: $symbol\n";
602 my $declaration = $Declarations{$symbol};
603 if (defined ($declaration)) {
604 # We don't want standard macros/functions of GtkObjects,
605 # or private declarations.
606 if ($subsection ne "Standard" && $subsection ne "Private") {
607 if (&CheckIsObject ($symbol)) {
608 push @file_objects, $symbol;
610 my ($synop, $desc) = &OutputDeclaration ($symbol,
612 my ($sig_synop, $sig_desc) = &GetSignals ($symbol);
613 my ($arg_synop, $child_arg_synop, $style_arg_synop,
614 $arg_desc, $child_arg_desc, $style_arg_desc) = &GetArgs ($symbol);
615 my $hier = &GetHierarchy ($symbol);
616 my $ifaces = &GetInterfaces ($symbol);
617 my $impls = &GetImplementations ($symbol);
618 my $prereqs = &GetPrerequisites ($symbol);
619 my $der = &GetDerived ($symbol);
622 $signals_synop .= $sig_synop;
623 $signals_desc .= $sig_desc;
624 $args_synop .= $arg_synop;
625 $child_args_synop .= $child_arg_synop;
626 $style_args_synop .= $style_arg_synop;
627 $args_desc .= $arg_desc;
628 $child_args_desc .= $child_arg_desc;
629 $style_args_desc .= $style_arg_desc;
631 $interfaces .= $ifaces;
632 $implementations .= $impls;
633 $prerequisites .= $prereqs;
637 # Note that the declaration has been output.
638 $DeclarationOutput{$symbol} = 1;
639 } elsif ($subsection ne "Standard" && $subsection ne "Private") {
640 $UndeclaredSymbols{$1} = 1;
641 print "WARNING: No declaration found for: $1\n";
648 &OutputMissingDocumentation;
649 &OutputUndeclaredSymbols;
651 if ($OUTPUT_ALL_SYMBOLS) {
655 for $file (split (' ', $EXPAND_CONTENT_FILES)) {
656 my $file_changed = &OutputExtraFile ($file);
662 &OutputBook ($book_top, $book_bottom);
668 #############################################################################
669 # Function : ReadKnownSymbols
670 # Description : This collects the names of non-private symbols from the
671 # $MODULE-sections.txt file.
672 # Arguments : $file - the $MODULE-sections.txt file which contains all of
673 # the functions/macros/structs etc. being documented, organised
674 # into sections and subsections.
675 #############################################################################
677 sub ReadKnownSymbols {
682 # print "Reading: $file\n";
684 || die "Can't open $file";
690 } elsif (m/^<SECTION>/) {
693 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
696 } elsif (m/^<SUBSECTION>/) {
699 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
702 } elsif (m/^<FILE>(.*)<\/FILE>/) {
705 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
708 } elsif (m/^<\/SECTION>/) {
711 } elsif (m/^(\S+)/) {
714 if ($subsection ne "Standard" && $subsection ne "Private") {
715 $KnownSymbols{$symbol} = 1;
718 $KnownSymbols{$symbol} = 0;
726 #############################################################################
727 # Function : OutputDeclaration
728 # Description : Returns the synopsis and detailed description DocBook
729 # describing one function/macro etc.
730 # Arguments : $symbol - the name of the function/macro begin described.
731 # $declaration - the declaration of the function/macro.
732 #############################################################################
734 sub OutputDeclaration {
735 my ($symbol, $declaration) = @_;
737 my $type = $DeclarationTypes {$symbol};
738 if ($type eq 'MACRO') {
739 return &OutputMacro ($symbol, $declaration);
740 } elsif ($type eq 'TYPEDEF') {
741 return &OutputTypedef ($symbol, $declaration);
742 } elsif ($type eq 'STRUCT') {
743 return &OutputStruct ($symbol, $declaration);
744 } elsif ($type eq 'ENUM') {
745 return &OutputEnum ($symbol, $declaration);
746 } elsif ($type eq 'UNION') {
747 return &OutputUnion ($symbol, $declaration);
748 } elsif ($type eq 'VARIABLE') {
749 return &OutputVariable ($symbol, $declaration);
751 } elsif ($type eq 'FUNCTION') {
752 return &OutputFunction ($symbol, $declaration, $type);
753 } elsif ($type eq 'USER_FUNCTION') {
754 return &OutputFunction ($symbol, $declaration, $type);
756 die "Unknown symbol type";
761 #############################################################################
762 # Function : OutputSymbolTraits
763 # Description : Returns the Since and StabilityLevel paragraphs for a symbol.
764 # Arguments : $symbol - the name of the function/macro begin described.
765 #############################################################################
767 sub OutputSymbolTraits {
771 if (exists $Since{$symbol}) {
772 $desc .= "<para role=\"since\">Since $Since{$symbol}</para>";
774 if (exists $StabilityLevel{$symbol}) {
775 $desc .= "<para role=\"stability\">Stability Level: $StabilityLevel{$symbol}</para>";
781 #############################################################################
782 # Function : OutputMacro
783 # Description : Returns the synopsis and detailed description of a macro.
784 # Arguments : $symbol - the macro.
785 # $declaration - the declaration of the macro.
786 #############################################################################
789 my ($symbol, $declaration) = @_;
790 my $id = &CreateValidSGMLID ($symbol);
791 my $condition = &MakeConditionDescription ($symbol);
792 my $synop = &MakeReturnField("#define") . "<link linkend=\"$id\">$symbol</link>";
798 if ($declaration =~ m/^\s*#\s*define(\s+)\w+(\([^\)]*\))/) {
802 if (length ($symbol) < $SYMBOL_FIELD_WIDTH) {
803 $synop .= (' ' x ($SYMBOL_FIELD_WIDTH - length ($symbol)));
806 # Try to align all the lines of args correctly.
807 $pad = ' ' x ($RETURN_TYPE_FIELD_WIDTH + $SYMBOL_FIELD_WIDTH + 1);
808 my $args_padded = $args;
809 $args_padded =~ s/ *\\\n */\n$pad/gm;
810 $synop .= &CreateValidSGML ($args_padded);
815 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"macro\"${condition}${empty_element_end}${symbol}()</title>\n";
817 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"macro\"${condition}${empty_element_end}$symbol</title>\n";
819 $desc .= MakeIndexterms($symbol);
821 # Don't output the macro definition if is is a conditional macro or it
822 # looks like a function, i.e. starts with "g_" or "_?gnome_", or it is
823 # longer than 2 lines, otherwise we get lots of complicated macros like
825 if (!defined ($DeclarationConditional{$symbol}) && ($symbol !~ m/^g_/)
826 && ($symbol !~ m/^_?gnome_/) && (($declaration =~ tr/\n//) < 2)) {
827 $declaration = &CreateValidSGML ($declaration);
828 $desc .= "<programlisting>$declaration</programlisting>\n";
830 $desc .= "<programlisting>" . &MakeReturnField("#define") . "$symbol";
831 # Align each line so that if should all line up OK.
832 $pad = ' ' x ($RETURN_TYPE_FIELD_WIDTH - length ("#define "));
833 $args =~ s/\n/\n$pad/gm;
834 $desc .= &CreateValidSGML ($args);
835 $desc .= "</programlisting>\n";
838 $desc .= &MakeDeprecationNote($symbol);
840 my $parameters = &OutputParamDescriptions ("MACRO", $symbol);
841 my $parameters_output = 0;
843 if (defined ($SymbolDocs{$symbol})) {
844 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
846 # Try to insert the parameter table at the author's desired position.
847 # Otherwise we need to tag it onto the end.
848 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
849 $parameters_output = 1;
851 $desc .= $symbol_docs;
854 if ($parameters_output == 0) {
855 $desc .= $parameters;
858 $desc .= OutputSymbolTraits ($symbol);
859 $desc .= "</refsect2>\n";
860 return ($synop, $desc);
864 #############################################################################
865 # Function : OutputTypedef
866 # Description : Returns the synopsis and detailed description of a typedef.
867 # Arguments : $symbol - the typedef.
868 # $declaration - the declaration of the typedef,
869 # e.g. 'typedef unsigned int guint;'
870 #############################################################################
873 my ($symbol, $declaration) = @_;
874 my $id = &CreateValidSGMLID ($symbol);
875 my $condition = &MakeConditionDescription ($symbol);
876 my $synop = &MakeReturnField("typedef") . "<link linkend=\"$id\">$symbol</link>;\n";
877 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"typedef\"${condition}${empty_element_end}$symbol</title>\n";
879 $desc .= MakeIndexterms($symbol);
881 if (!defined ($DeclarationConditional{$symbol})) {
882 $declaration = &CreateValidSGML ($declaration);
883 $desc .= "<programlisting>$declaration</programlisting>\n";
886 $desc .= &MakeDeprecationNote($symbol);
888 if (defined ($SymbolDocs{$symbol})) {
889 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
891 $desc .= OutputSymbolTraits ($symbol);
892 $desc .= "</refsect2>\n";
893 return ($synop, $desc);
897 #############################################################################
898 # Function : OutputStruct
899 # Description : Returns the synopsis and detailed description of a struct.
900 # We check if it is a widget struct, and if so we only output
901 # parts of it that are noted as public fields.
902 # We also use a different SGML ID for widget structs, since the
903 # original ID is used for the entire RefEntry.
904 # Arguments : $symbol - the struct.
905 # $declaration - the declaration of the struct.
906 #############################################################################
909 my ($symbol, $declaration) = @_;
911 my $is_widget_struct = 0;
912 my $default_to_public = 1;
913 if (&CheckIsObject ($symbol)) {
914 # print "Found widget struct: $symbol\n";
915 $is_widget_struct = 1;
916 $default_to_public = 0;
921 if ($is_widget_struct) {
922 $id = &CreateValidSGMLID ($symbol . "_struct");
923 $condition = &MakeConditionDescription ($symbol . "_struct");
925 $id = &CreateValidSGMLID ($symbol);
926 $condition = &MakeConditionDescription ($symbol);
929 # Determine if it is a simple struct or it also has a typedef.
931 if ($StructHasTypedef{$symbol} || $declaration =~ m/^\s*typedef\s+/) {
938 # For structs with typedefs we just output the struct name.
939 $synop = &MakeReturnField("") . "<link linkend=\"$id\">$symbol</link>;\n";
940 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"struct\"${condition}${empty_element_end}$symbol</title>\n";
942 $synop = &MakeReturnField("struct") . "<link linkend=\"$id\">$symbol</link>;\n";
943 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"struct\"${condition}${empty_element_end}struct $symbol</title>\n";
946 $desc .= MakeIndexterms($symbol);
948 # Form a pretty-printed, private-data-removed form of the declaration
951 if ($declaration =~ m/^\s*$/) {
952 # print "Found opaque struct: $symbol\n";
953 $decl_out = "typedef struct _$symbol $symbol;";
954 } elsif ($declaration =~ m/^\s*struct\s+\w+\s*;\s*$/) {
955 # print "Found opaque struct: $symbol\n";
956 $decl_out = "struct $symbol;";
958 my $public = $default_to_public;
959 my $new_declaration = "";
961 my $decl = $declaration;
963 if ($decl =~ m/^\s*(typedef\s+)?struct\s*\w*\s*(?:\/\*.*\*\/)?\s*{(.*)}\s*\w*\s*;\s*$/s) {
964 my $struct_contents = $2;
966 foreach $decl_line (split (/\n/, $struct_contents)) {
967 # print "Struct line: $decl_line\n";
968 if ($decl_line =~ m%/\*\s*<\s*public\s*>\s*\*/%) {
970 } elsif ($decl_line =~ m%/\*\s*<\s*(private|protected)\s*>\s*\*/%) {
973 $new_declaration .= $decl_line . "\n";
977 if ($new_declaration) {
978 # Strip any blank lines off the ends.
979 $new_declaration =~ s/^\s*\n//;
980 $new_declaration =~ s/\n\s*$/\n/;
983 $decl_out = "typedef struct {\n" . $new_declaration
986 $decl_out = "struct $symbol {\n" . $new_declaration
991 print "WARNING: Couldn't parse struct:\n$declaration\n";
994 # If we couldn't parse the struct or it was all private, output an
995 # empty struct declaration.
996 if ($decl_out eq "") {
998 $decl_out = "typedef struct _$symbol $symbol;";
1000 $decl_out = "struct $symbol;";
1005 $decl_out = &CreateValidSGML ($decl_out);
1006 $desc .= "<programlisting>$decl_out</programlisting>\n";
1008 $desc .= &MakeDeprecationNote($symbol);
1010 if (defined ($SymbolDocs{$symbol})) {
1011 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1014 # Create a table of fields and descriptions
1016 # FIXME: Inserting  's into the produced type declarations here would
1017 # improve the output in most situations ... except for function
1018 # members of structs!
1019 my @fields = ParseStructDeclaration($declaration, !$default_to_public,
1022 "<structfield>$_[0]</structfield>";
1024 my $params = $SymbolParams{$symbol};
1026 # If no parameters are filled in, we don't generate the description
1027 # table, for backwards compatibility
1030 if (defined $params) {
1031 for (my $i = 1; $i <= $#$params; $i += 2) {
1032 if ($params->[$i] =~ /\S/) {
1040 my %field_descrs = @$params;
1043 <variablelist role="struct">
1046 my $field_name = shift @fields;
1047 my $text = shift @fields;
1048 my $field_descr = $field_descrs{$field_name};
1050 $desc .= "<varlistentry>\n<term>$text</term>\n";
1051 if (defined $field_descr) {
1052 $desc .= "<listitem><simpara>".&ExpandAbbreviations($symbol, $field_descr)."</simpara></listitem>\n";
1054 $desc .= "<listitem></listitem>\n";
1056 $desc .= "</varlistentry>\n";
1059 $desc .= "</variablelist>";
1061 $desc .= OutputSymbolTraits ($symbol);
1062 $desc .= "</refsect2>\n";
1063 return ($synop, $desc);
1067 #############################################################################
1068 # Function : OutputEnum
1069 # Description : Returns the synopsis and detailed description of a enum.
1070 # Arguments : $symbol - the enum.
1071 # $declaration - the declaration of the enum.
1072 #############################################################################
1075 my ($symbol, $declaration) = @_;
1076 my $id = &CreateValidSGMLID ($symbol);
1077 my $condition = &MakeConditionDescription ($symbol);
1078 my $synop = &MakeReturnField("enum") . "<link linkend=\"$id\">$symbol</link>;\n";
1079 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"enum\"${condition}${empty_element_end}enum $symbol</title>\n";
1081 $desc .= MakeIndexterms($symbol);
1083 $declaration = &CreateValidSGML ($declaration);
1084 $desc .= "<programlisting>$declaration</programlisting>\n";
1086 $desc .= &MakeDeprecationNote($symbol);
1088 if (defined ($SymbolDocs{$symbol})) {
1089 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1092 # Create a table of fields and descriptions
1094 my @members = ParseEnumDeclaration($declaration);
1095 my $params = $SymbolParams{$symbol};
1097 # If no parameters are filled in, we don't generate the description
1098 # table, for backwards compatibility
1101 if (defined $params) {
1102 for (my $i = 1; $i <= $#$params; $i += 2) {
1103 if ($params->[$i] =~ /\S/) {
1111 my %member_descrs = @$params;
1114 <variablelist role="enum">
1116 for my $member_name (@members) {
1117 my $member_descr = $member_descrs{$member_name};
1119 $id = &CreateValidSGMLID ($member_name);
1120 $condition = &MakeConditionDescription ($member_name);
1121 $desc .= "<varlistentry>\n<term><anchor id=\"$id\" role=\"constant\"${condition}${empty_element_end}<literal>$member_name</literal></term>\n";
1122 if (defined $member_descr) {
1123 $desc .= "<listitem><simpara>".&ExpandAbbreviations($symbol, $member_descr)."</simpara></listitem>\n";
1125 $desc .= "<listitem></listitem>\n";
1127 $desc .= "</varlistentry>\n";
1130 $desc .= "</variablelist>";
1133 $desc .= OutputSymbolTraits ($symbol);
1134 $desc .= "</refsect2>\n";
1135 return ($synop, $desc);
1139 #############################################################################
1140 # Function : OutputUnion
1141 # Description : Returns the synopsis and detailed description of a union.
1142 # Arguments : $symbol - the union.
1143 # $declaration - the declaration of the union.
1144 #############################################################################
1147 my ($symbol, $declaration) = @_;
1148 my $id = &CreateValidSGMLID ($symbol);
1149 my $condition = &MakeConditionDescription ($symbol);
1150 my $synop = &MakeReturnField("union") . "<link linkend=\"$id\">$symbol</link>;\n";
1151 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"union\"${condition}${empty_element_end}union $symbol</title>\n";
1153 $desc .= MakeIndexterms($symbol);
1155 $declaration = &CreateValidSGML ($declaration);
1156 $desc .= "<programlisting>$declaration</programlisting>\n";
1158 $desc .= &MakeDeprecationNote($symbol);
1160 if (defined ($SymbolDocs{$symbol})) {
1161 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1163 $desc .= OutputSymbolTraits ($symbol);
1164 $desc .= "</refsect2>\n";
1165 return ($synop, $desc);
1169 #############################################################################
1170 # Function : OutputVariable
1171 # Description : Returns the synopsis and detailed description of a variable.
1172 # Arguments : $symbol - the extern'ed variable.
1173 # $declaration - the declaration of the variable.
1174 #############################################################################
1176 sub OutputVariable {
1177 my ($symbol, $declaration) = @_;
1178 my $id = &CreateValidSGMLID ($symbol);
1179 my $condition = &MakeConditionDescription ($symbol);
1182 if ($declaration =~ m/^\s*extern\s+((const\s+|unsigned\s+)*\w+)(\s+\*+|\*+|\s)(\s*)([A-Za-z]\w*)\s*;/) {
1183 my $mod = defined ($1) ? $1 : "";
1184 my $ptr = defined ($3) ? $3 : "";
1185 my $space = defined ($4) ? $4 : "";
1186 $synop = &MakeReturnField("extern") . "$mod$ptr$space<link linkend=\"$id\">$symbol</link>;\n";
1189 $synop = &MakeReturnField("extern") . "<link linkend=\"$id\">$symbol</link>;\n";
1192 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"variable\"${condition}${empty_element_end}$symbol</title>\n";
1194 $desc .= MakeIndexterms($symbol);
1196 $declaration = &CreateValidSGML ($declaration);
1197 $desc .= "<programlisting>$declaration</programlisting>\n";
1199 $desc .= &MakeDeprecationNote($symbol);
1201 if (defined ($SymbolDocs{$symbol})) {
1202 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1204 $desc .= OutputSymbolTraits ($symbol);
1205 $desc .= "</refsect2>\n";
1206 return ($synop, $desc);
1210 #############################################################################
1211 # Function : OutputFunction
1212 # Description : Returns the synopsis and detailed description of a function.
1213 # Arguments : $symbol - the function.
1214 # $declaration - the declaration of the function.
1215 #############################################################################
1217 sub OutputFunction {
1218 my ($symbol, $declaration, $symbol_type) = @_;
1219 my $id = &CreateValidSGMLID ($symbol);
1220 my $condition = &MakeConditionDescription ($symbol);
1222 # Take out the return type
1223 $declaration =~ s/<RETURNS>\s*((const\s+|G_CONST_RETURN\s+|unsigned\s+|struct\s+|enum\s+)*)(\w+)\s*(\**\s*(const|G_CONST_RETURN)?\s*\**\s*(restrict)?\s*)<\/RETURNS>\n//;
1224 my $type_modifier = defined($1) ? $1 : "";
1227 # print "$symbol pointer is $pointer\n";
1228 my $xref = &MakeXRef ($type);
1230 if ($symbol_type eq 'USER_FUNCTION') {
1231 # $start = "typedef ";
1234 # We output const rather than G_CONST_RETURN.
1235 $type_modifier =~ s/G_CONST_RETURN/const/g;
1236 $pointer =~ s/G_CONST_RETURN/const/g;
1238 my $ret_type_len = length ($start) + length ($type_modifier)
1239 + length ($pointer) + length ($type);
1240 my $ret_type_output;
1242 if ($ret_type_len < $RETURN_TYPE_FIELD_WIDTH) {
1243 $ret_type_output = "$start$type_modifier$xref$pointer"
1244 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
1247 # $ret_type_output = "$start$type_modifier$xref$pointer\n"
1248 # . (' ' x $RETURN_TYPE_FIELD_WIDTH);
1250 $ret_type_output = "$start$type_modifier$xref$pointer ";
1251 $symbol_len = $ret_type_len + 1 - $RETURN_TYPE_FIELD_WIDTH;
1254 $symbol_len += length ($symbol);
1255 my $char1 = my $char2 = my $char3 = "";
1256 if ($symbol_type eq 'USER_FUNCTION') {
1263 my ($symbol_output, $symbol_desc_output);
1264 if ($symbol_len < $SYMBOL_FIELD_WIDTH) {
1265 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3"
1266 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1267 $symbol_desc_output = "$char1$char2$symbol$char3"
1268 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1270 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3\n"
1271 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1272 $symbol_desc_output = "$char1$char2$symbol$char3\n"
1273 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1276 my $synop = $ret_type_output . $symbol_output . '(';
1277 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"function\"${condition}${empty_element_end}${symbol} ()</title>\n";
1279 $desc .= MakeIndexterms($symbol);
1281 $desc .= "<programlisting>${ret_type_output}$symbol_desc_output(";
1284 while ($declaration ne "") {
1285 if ($declaration =~ s/^[\s,]+//) {
1286 # skip whitespace and commas
1289 } elsif ($declaration =~ s/^void\s*[,\n]//) {
1293 } elsif ($declaration =~ s/^...\s*[,\n]//) {
1294 if ($param_num == 0) {
1299 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1302 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1306 # allow alphanumerics, '_', '[' & ']' in param names
1307 # Try to match a standard parameter (keep in sync with gtkdoc-mktmpl)
1309 } elsif ($declaration =~ s/^\s*((?:G_CONST_RETURN|G_GNUC_UNUSED|unsigned|signed|long|short|volatile|const)\s+)*((?:struct\b|enum\b)?\s*\w+)\s*((?:(?:const|restrict)?\s*\*?\s*(?:const\b|restrict\b)?\s*)*)(\w+)?\s*((?:\[\S*\])*)\s*[,\n]//) {
1310 my $pre = defined($1) ? $1 : "";
1312 my $ptr = defined($3) ? $3 : "";
1313 my $name = defined($4) ? $4 : "";
1314 my $array = defined($5) ? $5 : "";
1320 if ($ptr && $ptr !~ m/\*$/) { $ptr .= " "; }
1322 if (($name eq "") && $pre =~ m/^((un)?signed)\s?/ ) {
1328 my $xref = &MakeXRef ($type);
1329 my $label = "$pre$xref $ptr$name$array";
1331 #print "$symbol: '$pre' '$type' '$ptr' '$name' '$array'\n";
1333 if ($param_num == 0) {
1338 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1341 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1345 # Try to match parameters which are functions (keep in sync with gtkdoc-mktmpl)
1346 # $1 $2 $3 $4 $5 $7 $8
1347 } elsif ($declaration =~ s/^(const\s+|G_CONST_RETURN\s+|unsigned\s+)*(struct\s+)?(\w+)\s*(\**)\s*(?:restrict\b)?\s*(const\s+)?\(\s*\*+\s*(\w+)\s*\)\s*\(([^)]*)\)\s*[,\n]//) {
1348 my $mod1 = defined($1) ? $1 : "";
1349 if (defined($2)) { $mod1 .= $2; }
1352 my $mod2 = defined($5) ? $5 : "";
1355 my $func_params = $8;
1357 if ($ptr1 && $ptr1 !~ m/\*$/) { $ptr1 .= " "; }
1358 $func_ptr =~ s/\s+//g;
1359 my $xref = &MakeXRef ($type);
1360 my $label = "$mod1$xref$ptr1$mod2 ($func_ptr$name) ($func_params)";
1362 #print "Type: $mod1$type$ptr1$mod2($func_ptr$name)($func_params)\n";
1363 if ($param_num == 0) {
1368 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1371 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1376 print "###Can't parse args for function $symbol: $declaration\n";
1382 $desc .= ");</programlisting>\n";
1384 $desc .= &MakeDeprecationNote($symbol);
1386 my $parameters = &OutputParamDescriptions ("FUNCTION", $symbol);
1387 my $parameters_output = 0;
1389 if (defined ($SymbolDocs{$symbol})) {
1390 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1392 # Try to insert the parameter table at the author's desired position.
1393 # Otherwise we need to tag it onto the end.
1394 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
1395 $parameters_output = 1;
1397 $desc .= $symbol_docs;
1400 if ($parameters_output == 0) {
1401 $desc .= $parameters;
1404 $desc .= OutputSymbolTraits ($symbol);
1405 $desc .= "</refsect2>\n";
1406 return ($synop, $desc);
1410 #############################################################################
1411 # Function : OutputParamDescriptions
1412 # Description : Returns the DocBook output describing the parameters of a
1413 # function, macro or signal handler.
1414 # Arguments : $symbol_type - 'FUNCTION', 'MACRO' or 'SIGNAL'. Signal
1415 # handlers have an implicit user_data parameter last.
1416 # $symbol - the name of the function/macro being described.
1417 #############################################################################
1419 sub OutputParamDescriptions {
1420 my ($symbol_type, $symbol) = @_;
1422 if (defined ($SymbolParams{$symbol})) {
1424 my $params = $SymbolParams{$symbol};
1425 my $params_desc = "";
1427 for ($j = 0; $j <= $#$params; $j += 2) {
1428 my $param_name = $$params[$j];
1429 my $param = $$params[$j + 1];
1430 if ($param_name eq "Returns") {
1431 $returns = &ExpandAbbreviations($symbol, $param);
1433 if ($param_name eq "Varargs") {
1434 $param_name = "...";
1436 $param = &ExpandAbbreviations($symbol, $param);
1437 $params_desc .= "<varlistentry><term><parameter>$param_name</parameter> :</term>\n<listitem><simpara>$param</simpara></listitem></varlistentry>\n";
1441 # Signals have an implicit user_data parameter which we describe.
1442 if ($symbol_type eq "SIGNAL") {
1443 $params_desc .= "<varlistentry><term><parameter>user_data</parameter> :</term>\n<listitem><simpara>user data set when the signal handler was connected.</simpara></listitem></varlistentry>\n";
1446 # Start a table if we need one.
1447 if ($params_desc || $returns) {
1449 <variablelist role="params">
1452 if ($params_desc ne "") {
1453 # $output .= "<varlistentry><term>Parameters:</term><listitem></listitem></varlistentry>\n";
1454 $output .= $params_desc;
1457 # Output the returns info last.
1459 $output .= "<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>$returns</simpara></listitem></varlistentry>\n";
1463 $output .= "</variablelist>";
1470 #############################################################################
1471 # Function : ParseStabilityLevel
1472 # Description : Parses a stability level and outputs a warning if it isn't
1474 # Arguments : $stability - the stability text.
1475 # $message - description of where the level is from, to use in
1476 # any error message.
1477 # Returns : The parsed stability level string.
1478 #############################################################################
1480 sub ParseStabilityLevel {
1481 my ($stability, $message) = @_;
1483 $stability =~ s/^\s*//;
1484 $stability =~ s/\s*$//;
1485 if ($stability =~ m/^stable$/i) {
1486 $stability = "Stable";
1487 } elsif ($stability =~ m/^unstable$/i) {
1488 $stability = "Unstable";
1489 } elsif ($stability =~ m/^private$/i) {
1490 $stability = "Private";
1493 WARNING: $message is $stability.
1494 It should be one of these: Stable, Unstable, or Private.
1501 #############################################################################
1502 # Function : OutputSGMLFile
1503 # Description : Outputs the final DocBook file for one section.
1504 # Arguments : $file - the name of the file.
1505 # $title - the title from the $MODULE-sections.txt file, which
1506 # will be overridden by the title in the template file.
1507 # $section_id - the SGML id to use for the toplevel tag.
1508 # $includes - comma-separates list of include files added at top
1509 # of synopsis, with '<' '>' around them (if not already enclosed in "").
1510 # $synopsis - reference to the DocBook for the Synopsis part.
1511 # $details - reference to the DocBook for the Details part.
1512 # $signal_synop - reference to the DocBook for the Signal Synopsis part
1513 # $signal_desc - reference to the DocBook for the Signal Description part
1514 # $args_synop - reference to the DocBook for the Arg Synopsis part
1515 # $args_desc - reference to the DocBook for the Arg Description part
1516 # $hierarchy - reference to the DocBook for the Object Hierarchy part
1517 # $interfaces - reference to the DocBook for the Interfaces part
1518 # $implementations - reference to the DocBook for the Known Implementations part
1519 # $prerequisites - reference to the DocBook for the Prerequisites part
1520 # $derived - reference to the DocBook for the Derived Interfaces part
1521 # $file_objects - reference to an array of objects in this file
1522 #############################################################################
1524 sub OutputSGMLFile {
1525 my ($file, $title, $section_id, $includes, $synopsis, $details, $signals_synop, $signals_desc, $args_synop, $args_desc, $hierarchy, $interfaces, $implementations, $prerequisites, $derived, $file_objects) = @_;
1527 # The edited title overrides the one from the sections file.
1528 my $new_title = $SymbolDocs{"$TMPL_DIR/$file:Title"};
1529 if (defined ($new_title) && $new_title !~ m/^\s*$/) {
1530 $title = $new_title;
1531 # print "Found title: $title\n";
1533 my $short_desc = $SymbolDocs{"$TMPL_DIR/$file:Short_Description"};
1534 if (!defined ($short_desc) || $short_desc =~ m/^\s*$/) {
1535 # $short_desc = "one line description goes here.";
1538 $short_desc = &ExpandAbbreviations("$title:Short_description",
1540 # print "Found short_desc: $short_desc";
1542 my $long_desc = $SymbolDocs{"$TMPL_DIR/$file:Long_Description"};
1543 if (!defined ($long_desc) || $long_desc =~ m/^\s*$/) {
1544 $long_desc = "<para>\nA longer description goes here.\n</para>\n";
1546 $long_desc = &ExpandAbbreviations("$title:Long_description",
1548 # print "Found long_desc: $long_desc";
1550 my $see_also = $SymbolDocs{"$TMPL_DIR/$file:See_Also"};
1551 if (!defined ($see_also) || $see_also =~ m%^\s*(<para>)?\s*(</para>)?\s*$%) {
1554 $see_also = &ExpandAbbreviations("$title:See_Also", $see_also);
1555 # print "Found see_also: $see_also";
1558 $see_also = "<refsect1>\n<title>See Also</title>\n$see_also\n</refsect1>\n";
1560 my $stability = $SymbolDocs{"$TMPL_DIR/$file:Stability_Level"};
1561 if (!defined ($stability) || $stability =~ m/^\s*$/) {
1564 $stability = &ParseStabilityLevel($stability, "Section stability level for $file");
1565 # print "Found stability: $stability";
1568 $stability = "<refsect1>\n<title>Stability Level</title>\n$stability, unless otherwise indicated\n</refsect1>\n";
1569 } elsif ($DEFAULT_STABILITY) {
1570 $stability = "<refsect1>\n<title>Stability Level</title>\n$DEFAULT_STABILITY, unless otherwise indicated\n</refsect1>\n";
1573 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
1575 my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
1578 my $include_output = "";
1580 foreach $include (split (/,/, $includes)) {
1581 if ($include =~ m/^\".+\"$/) {
1582 $include_output .= "#include ${include}\n";
1585 $include =~ s/^\s+|\s+$//gs;
1586 $include_output .= "#include <${include}>\n";
1590 my $old_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT";
1591 my $new_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT.new";
1593 open (OUTPUT, ">$new_sgml_file")
1594 || die "Can't create $new_sgml_file";
1596 my $object_anchors = "";
1597 foreach my $object (@$file_objects) {
1598 next if ($object eq $section_id);
1599 my $id = CreateValidSGMLID($object);
1600 # print "Debug: Adding anchor for $object\n";
1601 $object_anchors .= "<anchor id=\"$id\"$empty_element_end";
1604 # We used to output this, but is messes up our UpdateFileIfChanged code
1605 # since it changes every day (and it is only used in the man pages):
1606 # "<refentry id="$section_id" revision="$mday $month $year">"
1608 if (lc($OUTPUT_FORMAT) eq "xml") {
1609 print OUTPUT $doctype_header;
1613 <refentry id="$section_id">
1615 <refentrytitle role="top_of_page">$title</refentrytitle>
1616 <manvolnum>3</manvolnum>
1617 <refmiscinfo>\U$MODULE\E Library</refmiscinfo>
1621 <refname>$title</refname>
1622 <refpurpose>$short_desc</refpurpose>
1623 <!--[<xref linkend="desc" endterm="desc.title"/>]-->
1626 <refsynopsisdiv role="synopsis">
1627 <title role="synopsis.title">Synopsis</title>
1633 $${synopsis}</synopsis>
1644 <refsect1 role="desc">
1645 <title role="desc.title">Description</title>
1649 <refsect1 role="details">
1650 <title role="details.title">Details</title>
1661 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
1665 #############################################################################
1666 # Function : OutputExtraFile
1667 # Description : Copies an "extra" DocBook file into the output directory,
1668 # expanding abbreviations
1669 # Arguments : $file - the source file.
1670 #############################################################################
1671 sub OutputExtraFile {
1676 ($basename = $file) =~ s!^.*/!!;
1678 my $old_sgml_file = "$SGML_OUTPUT_DIR/$basename";
1679 my $new_sgml_file = "$SGML_OUTPUT_DIR/$basename.new";
1683 open(EXTRA_FILE, "<$file") || die "Can't open $file";
1687 $contents = <EXTRA_FILE>;
1690 open (OUTPUT, ">$new_sgml_file")
1691 || die "Can't create $new_sgml_file";
1693 print OUTPUT &ExpandAbbreviations ("$basename file", $contents);
1696 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
1699 #############################################################################
1700 # Function : OutputBook
1701 # Description : Outputs the SGML entities that need to be included into the
1702 # main SGML file for the module.
1703 # Arguments : $book_top - the declarations of the entities, which are added
1704 # at the top of the main SGML file.
1705 # $book_bottom - the references to the entities, which are
1706 # added in the main SGML file at the desired position.
1707 #############################################################################
1710 my ($book_top, $book_bottom) = @_;
1712 my $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top";
1713 my $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top.new";
1715 open (OUTPUT, ">$new_file")
1716 || die "Can't create $new_file";
1717 print OUTPUT $book_top;
1720 &UpdateFileIfChanged ($old_file, $new_file, 0);
1723 $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom";
1724 $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom.new";
1726 open (OUTPUT, ">$new_file")
1727 || die "Can't create $new_file";
1728 print OUTPUT $book_bottom;
1731 &UpdateFileIfChanged ($old_file, $new_file, 0);
1734 # If the main SGML file hasn't been created yet, we create it here.
1735 # The user can tweak it later.
1736 if ($MAIN_SGML_FILE && ! -e $MAIN_SGML_FILE) {
1737 open (OUTPUT, ">$MAIN_SGML_FILE")
1738 || die "Can't create $MAIN_SGML_FILE";
1740 if (lc($OUTPUT_FORMAT) eq "xml") {
1742 <?xml version="1.0"?>
1743 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
1744 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
1745 <book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
1749 <!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
1751 print OUTPUT $book_top;
1760 <title>$MODULE Reference Manual</title>
1762 for $MODULE [VERSION]
1763 The latest version of this documentation can be found on-line at
1764 <ulink role="online-location" url="http://[SERVER]/$MODULE/index.html">http://[SERVER]/$MODULE/</ulink>.
1769 <title>[Insert title here]</title>
1771 print OUTPUT $book_bottom;
1783 #############################################################################
1784 # Function : CreateValidSGMLID
1785 # Description : Creates a valid SGML 'id' from the given string.
1786 # NOTE: SGML ids are case-insensitive, so we have a few special
1787 # cases to avoid clashes of ids.
1788 # Arguments : $id - the string to be converted into a valid SGML id.
1789 #############################################################################
1791 sub CreateValidSGMLID {
1794 # Append ":CAPS" to all all-caps identifiers
1796 # Special case, '_' would end up as '' so we use 'gettext-macro' instead.
1797 if ($id eq "_") { return "gettext-macro"; }
1799 if ($id !~ /[a-z]/) { $id .= ":CAPS" };
1810 #############################################################################
1811 # Function : CreateValidSGML
1812 # Description : This turns any chars which are used in SGML into entities,
1813 # e.g. '<' into '<'
1814 # Arguments : $text - the text to turn into proper SGML.
1815 #############################################################################
1817 sub CreateValidSGML {
1819 $text =~ s/&/&/g; # Do this first, or the others get messed up.
1820 $text =~ s/</</g;
1821 $text =~ s/>/>/g;
1825 #############################################################################
1826 # Function : ConvertSGMLChars
1827 # Description : This is used for text in source code comment blocks, to turn
1828 # chars which are used in SGML into entities, e.g. '<' into
1829 # '<'. Depending on $SGML_MODE, this is done
1830 # unconditionally or only if the character doesn't seem to be
1831 # part of an SGML construct (tag or entity reference).
1832 # Arguments : $text - the text to turn into proper SGML.
1833 #############################################################################
1835 sub ConvertSGMLChars {
1836 my ($symbol, $text) = @_;
1839 # For the SGML mode only convert to entities outside CDATA sections.
1840 return &ModifyXMLElements ($text, $symbol,
1841 "<!\\[CDATA\\[|<programlisting[^>]*>",
1842 \&ConvertSGMLCharsEndTag,
1843 \&ConvertSGMLCharsCallback);
1845 # For the simple non-sgml mode, convert to entities everywhere.
1846 $text =~ s/&/&/g; # Do this first, or the others get messed up.
1847 $text =~ s/</</g;
1848 $text =~ s/>/>/g;
1854 sub ConvertSGMLCharsEndTag {
1855 if ($_[0] eq "<!\[CDATA\[") {
1858 return "</programlisting>";
1862 sub ConvertSGMLCharsCallback {
1863 my ($text, $symbol, $tag) = @_;
1865 if ($tag =~ m/^<programlisting/) {
1866 # We can handle <programlisting> specially here.
1867 return &ModifyXMLElements ($text, $symbol,
1869 \&ConvertSGMLCharsEndTag,
1870 \&ConvertSGMLCharsCallback2);
1871 } elsif ($tag eq "") {
1872 # If we're not in CDATA convert to entities.
1873 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
1874 $text =~ s/<(?![a-zA-Z\/!])/</g;
1875 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
1877 # Handle "#include <xxxxx>"
1878 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
1884 sub ConvertSGMLCharsCallback2 {
1885 my ($text, $symbol, $tag) = @_;
1887 # If we're not in CDATA convert to entities.
1888 # We could handle <programlisting> differently, though I'm not sure it helps.
1890 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
1891 # $text =~ s/&/&/g; # Do this first, or the others get messed up.
1892 $text =~ s/<(?![a-zA-Z\/!])/</g;
1893 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
1895 # Handle "#include <xxxxx>"
1896 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
1903 #############################################################################
1904 # Function : ExpandAbbreviations
1905 # Description : This turns the abbreviations function(), macro(), @param,
1906 # %constant, and #symbol into appropriate DocBook markup.
1907 # CDATA sections and <programlisting> parts are skipped.
1908 # Arguments : $symbol - the symbol being documented, for error messages.
1909 # $text - the text to expand.
1910 #############################################################################
1912 sub ExpandAbbreviations {
1913 my ($symbol, $text) = @_;
1915 # Convert "|[" and "]|" into the start and end of program listing examples.
1916 $text =~ s%\|\[%<informalexample><programlisting>%g;
1917 $text =~ s%\]\|%</programlisting></informalexample>%g;
1919 return &ModifyXMLElements ($text, $symbol,
1920 "<!\\[CDATA\\[|<programlisting[^>]*>",
1921 \&ExpandAbbreviationsEndTag,
1922 \&ExpandAbbreviationsCallback);
1926 # Returns the end tag corresponding to the given start tag.
1927 sub ExpandAbbreviationsEndTag {
1928 if ($_[0] eq "<!\[CDATA\[") {
1931 return "</programlisting>";
1935 # Called inside or outside each CDATA or <programlisting> section.
1936 sub ExpandAbbreviationsCallback {
1937 my ($text, $symbol, $tag) = @_;
1939 if ($tag =~ m/^<programlisting/) {
1940 # Handle any embedded CDATA sections.
1941 return &ModifyXMLElements ($text, $symbol,
1943 \&ExpandAbbreviationsEndTag,
1944 \&ExpandAbbreviationsCallback2);
1945 } elsif ($tag eq "") {
1946 # We are outside any CDATA or <programlisting> sections, so we expand
1947 # any gtk-doc abbreviations.
1949 # Convert 'function()' or 'macro()'
1950 $text =~ s/(\w+)\s*\(\)/&MakeXRef($1, &tagify($1 . "()", "function"));/eg;
1953 $text =~ s/\@(\w+((\.|->)\w+)*)/<parameter>$1<\/parameter>/g;
1955 # Convert '%constant'. Also allow negative numbers, e.g. %-1.
1956 $text =~ s/\%(-?\w+)/&MakeXRef($1, &tagify($1, "literal"));/eg;
1959 $text =~ s/#([\w\-:]+)/&MakeHashXRef($1, "type");/eg;
1965 # This is called inside a <programlisting>
1966 sub ExpandAbbreviationsCallback2 {
1967 my ($text, $symbol, $tag) = @_;
1970 # We are inside a <programlisting> but outside any CDATA sections,
1971 # so we expand any gtk-doc abbreviations.
1972 $text =~ s/#(\w+)/&MakeHashXRef($1, "");/eg;
1979 my ($symbol, $tag) = @_;;
1982 # Check for things like '#include', '#define', and skip them.
1983 if ($PreProcessorDirectives{$symbol}) {
1987 # Get rid of any special '-struct' suffix.
1988 $text =~ s/-struct$//;
1990 # If the symbol is in the form "Object::signal", then change the symbol to
1991 # "Object-signal" and use "signal" as the text.
1992 if ($symbol =~ s/::/-/) {
1996 # If the symbol is in the form "Object:property", then change the symbol to
1997 # "Object--property" and use "property" as the text.
1998 if ($symbol =~ s/:/--/) {
2003 $text = tagify ($text, $tag);
2006 return &MakeXRef($symbol, $text);
2010 #############################################################################
2011 # Function : ModifyXMLElements
2012 # Description : Looks for given XML element tags within the text, and calls
2013 # the callback on pieces of text inside & outside those elements.
2014 # Used for special handling of text inside things like CDATA
2015 # and <programlisting>.
2016 # Arguments : $text - the text.
2017 # $symbol - the symbol currently being documented (only used for
2019 # $start_tag_regexp - the regular expression to match start tags.
2020 # e.g. "<!\\[CDATA\\[|<programlisting[^>]*>" to match
2021 # CDATA sections or programlisting elements.
2022 # $end_tag_func - function which is passed the matched start tag
2023 # and should return the appropriate end tag string.
2024 # $callback - callback called with each part of the text. It is
2025 # called with a piece of text, the symbol being
2026 # documented, and the matched start tag or "" if the text
2027 # is outside the XML elements being matched.
2028 #############################################################################
2029 sub ModifyXMLElements {
2030 my ($text, $symbol, $start_tag_regexp, $end_tag_func, $callback) = @_;
2031 my ($before_tag, $start_tag, $end_tag_regexp, $end_tag);
2034 while ($text =~ m/$start_tag_regexp/s) {
2039 $result .= &$callback ($before_tag, $symbol, "");
2040 $result .= $start_tag;
2042 $end_tag_regexp = &$end_tag_func ($start_tag);
2044 if ($text =~ m/$end_tag_regexp/s) {
2049 $result .= &$callback ($before_tag, $symbol, $start_tag);
2050 $result .= $end_tag;
2052 print "WARNING: Can't find tag end: $end_tag_regexp in docs for: $symbol\n";
2053 # Just assume it is all inside the tag.
2054 $result .= &$callback ($text, $symbol, $start_tag);
2059 # Handle any remaining text outside the tags.
2060 $result .= &$callback ($text, $symbol, "");
2069 # Adds a tag around some text.
2070 # e.g tagify("Text", "literal") => "<literal>Text</literal>".
2072 my ($text, $elem) = @_;
2073 return "<" . $elem . ">" . $text . "</" . $elem . ">";
2077 #############################################################################
2078 # Function : MakeXRef
2079 # Description : This returns a cross-reference link to the given symbol.
2080 # Though it doesn't try to do this for a few standard C types
2081 # that it knows won't be in the documentation.
2082 # Arguments : $symbol - the symbol to try to create a XRef to.
2083 # $text - text text to put inside the XRef, defaults to $symbol
2084 #############################################################################
2087 my ($symbol, $text) = ($_[0], $_[1]);
2088 if (!defined($text)) {
2091 # Get rid of special '-struct' suffix.
2092 $text =~ s/-struct$//;
2095 #print "Getting type link for $symbol -> $text\n";
2097 my $symbol_id = &CreateValidSGMLID ($symbol);
2098 return "<link linkend=\"$symbol_id\">$text</link>";
2102 #############################################################################
2103 # Function : MakeIndexterms
2104 # Description : This returns a indexterm elements for the given symbol
2105 # Arguments : $symbol - the symbol to create indexterms for
2106 #############################################################################
2108 sub MakeIndexterms {
2109 my ($symbol) = $_[0];
2112 if (exists $Deprecated{$symbol}) {
2113 $terms .= "<indexterm role=\"deprecated\"><primary>$symbol</primary></indexterm>"
2115 if (exists $Since{$symbol}) {
2116 my $since = $Since{$symbol};
2120 $terms .= "<indexterm role=\"$since\"><primary>$symbol</primary></indexterm>";
2124 $terms .= "<indexterm><primary>$symbol</primary></indexterm>";
2130 #############################################################################
2131 # Function : MakeDeprecationNote
2132 # Description : This returns a deprecation warning for the given symbol.
2133 # Arguments : $symbol - the symbol to try to create a warning for.
2134 #############################################################################
2136 sub MakeDeprecationNote {
2137 my ($symbol) = $_[0];
2140 if (exists $Deprecated{$symbol}) {
2141 $desc .= "<warning>";
2143 if ($Deprecated{$symbol} =~ /^\s*([0-9\.]+)\s*:/) {
2144 $desc .= "<para><literal>$symbol</literal> has been deprecated since version $1 and should not be used in newly-written code.";
2146 $desc .= "<para><literal>$symbol</literal> is deprecated and should not be used in newly-written code.";
2148 if ($Deprecated{$symbol} ne "") {
2149 $note = &ExpandAbbreviations($symbol, $Deprecated{$symbol});
2150 $note =~ s/^\s*([0-9\.]+)\s*:\s*//;
2153 $note =~ s%\n{2,}%\n</para>\n<para>\n%g;
2154 $desc .= " " . $note;
2156 $desc .= "</para></warning>\n";
2161 #############################################################################
2162 # Function : MakeConditionDescription
2163 # Description : This returns a sumary of conditions for the given symbol.
2164 # Arguments : $symbol - the symbol to try to create the sumary.
2165 #############################################################################
2167 sub MakeConditionDescription {
2168 my ($symbol) = $_[0];
2171 if (exists $Deprecated{$symbol}) {
2176 if ($Deprecated{$symbol} =~ /^\s*(.*?)\s*$/) {
2177 $desc .= "deprecated:$1";
2179 $desc .= "deprecated";
2183 if (exists $Since{$symbol}) {
2188 if ($Since{$symbol} =~ /^\s*(.*?)\s*$/) {
2189 $desc .= "since:$1";
2195 if (exists $StabilityLevel{$symbol}) {
2199 $desc .= "stability:".$StabilityLevel{$symbol};
2203 $desc=" condition=\"".$desc."\"";
2204 #print "condition for '$symbol' = '$desc'\n";
2209 #############################################################################
2210 # Function : GetHierarchy
2211 # Description : Returns the DocBook output describing the ancestors and
2212 # immediate children of a GObject subclass. It uses the
2213 # global @Objects and @ObjectLevels arrays to walk the tree.
2214 # Arguments : $object - the GtkObject subclass.
2215 #############################################################################
2220 # Find object in the objects array.
2226 for ($i = 0; $i < @Objects; $i++) {
2228 if ($ObjectLevels[$i] <= $level) {
2231 elsif ($ObjectLevels[$i] == $level + 1) {
2232 push (@children, $Objects[$i]);
2235 elsif ($Objects[$i] eq $object) {
2238 $level = $ObjectLevels[$i];
2245 # Walk up the hierarchy, pushing ancestors onto the ancestors array.
2247 push (@ancestors, $object);
2248 # print "Level: $level\n";
2249 while ($level > 1) {
2251 if ($ObjectLevels[$j] < $level) {
2252 push (@ancestors, $Objects[$j]);
2253 $level = $ObjectLevels[$j];
2254 # print "Level: $level\n";
2258 # Output the ancestors list, indented and with links.
2259 my $hierarchy = "<synopsis>\n\n";
2261 for ($i = $#ancestors; $i >= 0; $i--) {
2263 # Don't add a link to the current widget, i.e. when i == 0.
2265 my $ancestor_id = &CreateValidSGMLID ($ancestors[$i]);
2266 $link_text = "<link linkend=\"$ancestor_id\">$ancestors[$i]</link>";
2268 $link_text = "$ancestors[$i]";
2271 $hierarchy .= " $link_text\n";
2273 # $hierarchy .= ' ' x ($level * 6 - 3) . "|\n";
2274 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
2278 for ($i = 0; $i <= $#children; $i++) {
2279 my $id = &CreateValidSGMLID ($children[$i]);
2280 my $link_text = "<link linkend=\"$id\">$children[$i]</link>";
2281 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
2283 $hierarchy .= "</synopsis>\n";
2289 #############################################################################
2290 # Function : GetInterfaces
2291 # Description : Returns the DocBook output describing the interfaces
2292 # implemented by a class. It uses the global %Interfaces hash.
2293 # Arguments : $object - the GtkObject subclass.
2294 #############################################################################
2301 # Find object in the objects array.
2302 if (exists($Interfaces{$object})) {
2303 my @ifaces = split(' ', $Interfaces{$object});
2308 for ($i = 0; $i <= $#ifaces; $i++) {
2309 my $id = &CreateValidSGMLID ($ifaces[$i]);
2310 $text .= " <link linkend=\"$id\">$ifaces[$i]</link>";
2311 if ($i < $#ifaces - 1) {
2314 elsif ($i < $#ifaces) {
2329 #############################################################################
2330 # Function : GetImplementations
2331 # Description : Returns the DocBook output describing the implementations
2332 # of an interface. It uses the global %Interfaces hash.
2333 # Arguments : $object - the GtkObject subclass.
2334 #############################################################################
2336 sub GetImplementations {
2341 foreach my $key (keys %Interfaces) {
2342 if ($Interfaces{$key} =~ /\b$object\b/) {
2343 push (@impls, $key);
2349 $object is implemented by
2351 for ($i = 0; $i <= $#impls; $i++) {
2352 my $id = &CreateValidSGMLID ($impls[$i]);
2353 $text .= " <link linkend=\"$id\">$impls[$i]</link>";
2354 if ($i < $#impls - 1) {
2357 elsif ($i < $#impls) {
2372 #############################################################################
2373 # Function : GetPrerequisites
2374 # Description : Returns the DocBook output describing the prerequisites
2375 # of an interface. It uses the global %Prerequisites hash.
2376 # Arguments : $iface - the interface.
2377 #############################################################################
2379 sub GetPrerequisites {
2384 if (exists($Prerequisites{$iface})) {
2389 my @prereqs = split(' ', $Prerequisites{$iface});
2390 for ($i = 0; $i <= $#prereqs; $i++) {
2391 my $id = &CreateValidSGMLID ($prereqs[$i]);
2392 $text .= " <link linkend=\"$id\">$prereqs[$i]</link>";
2393 if ($i < $#prereqs - 1) {
2396 elsif ($i < $#prereqs) {
2410 #############################################################################
2411 # Function : GetDerived
2412 # Description : Returns the DocBook output describing the derived interfaces
2413 # of an interface. It uses the global %Prerequisites hash.
2414 # Arguments : $iface - the interface.
2415 #############################################################################
2423 foreach my $key (keys %Prerequisites) {
2424 if ($Prerequisites{$key} =~ /\b$iface\b/) {
2425 push (@derived, $key);
2428 if ($#derived >= 0) {
2431 $iface is required by
2433 for ($i = 0; $i <= $#derived; $i++) {
2434 my $id = &CreateValidSGMLID ($derived[$i]);
2435 $text .= " <link linkend=\"$id\">$derived[$i]</link>";
2436 if ($i < $#derived - 1) {
2439 elsif ($i < $#derived) {
2454 #############################################################################
2455 # Function : GetSignals
2456 # Description : Returns the synopsis and detailed description DocBook output
2457 # for the signal handlers of a given GtkObject subclass.
2458 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
2459 #############################################################################
2467 for ($i = 0; $i <= $#SignalObjects; $i++) {
2468 if ($SignalObjects[$i] eq $object) {
2469 # print "Found signal: $SignalNames[$i]\n";
2470 my $name = $SignalNames[$i];
2471 my $symbol = "${object}::${name}";
2472 my $id = &CreateValidSGMLID ("$object-$name");
2474 my $pad = ' ' x (46 - length($name));
2475 $synop .= " "<link linkend=\"$id\">$name</link>"$pad ";
2477 $desc .= "<refsect2><title><anchor id=\"$id\"${empty_element_end}The <literal>"$name"</literal> signal</title>\n";
2478 $desc .= MakeIndexterms($symbol);
2479 $desc .= "<programlisting>";
2481 $SignalReturns[$i] =~ m/\s*(const\s+)?(\w+)\s*(\**)/;
2482 my $type_modifier = defined($1) ? $1 : "";
2485 my $xref = &MakeXRef ($type);
2487 my $ret_type_len = length ($type_modifier) + length ($pointer)
2489 my $ret_type_output = "$type_modifier$xref$pointer"
2490 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
2492 $desc .= "${ret_type_output}user_function " . &MakeReturnField("") . " (";
2494 my $sourceparams = $SourceSymbolParams{$symbol};
2495 my @params = split ("\n", $SignalPrototypes[$i]);
2498 my $type_len = length("gpointer");
2499 my $name_len = length("user_data");
2500 # do two passes, the first one is to calculate padding
2501 for ($l = 0; $l < 2; $l++) {
2502 for ($j = 0; $j <= $#params; $j++) {
2503 # allow alphanumerics, '_', '[' & ']' in param names
2504 if ($params[$j] =~ m/^\s*(\w+)\s*(\**)\s*([\w\[\]]+)\s*$/) {
2507 if (defined($sourceparams)) {
2508 $name = $$sourceparams[2 * $j];
2513 if (!defined($name)) {
2517 if (length($type) + length($pointer) > $type_len) {
2518 $type_len = length($type) + length($pointer);
2520 if (length($name) > $name_len) {
2521 $name_len = length($name);
2525 $xref = &MakeXRef ($type);
2526 $pad = ' ' x ($type_len - length($type) - length($pointer));
2527 $desc .= "$xref$pad $pointer$name,\n";
2528 $desc .= (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
2531 print "###Can't parse arg: $params[$j]\nArgs:$SignalPrototypes[$i]\n";
2535 $xref = &MakeXRef ("gpointer");
2536 $pad = ' ' x ($type_len - length("gpointer"));
2537 $desc .= "$xref$pad user_data)";
2539 my $flags = $SignalFlags[$i];
2540 my $flags_string = "";
2542 if (defined ($flags)) {
2543 if ($flags =~ m/f/) {
2544 $flags_string = "Run First";
2546 elsif ($flags =~ m/l/) {
2547 $flags_string = "Run Last";
2549 elsif ($flags =~ m/c/) {
2550 $flags_string = "Cleanup";
2552 if ($flags =~ m/r/) {
2553 if ($flags_string) { $flags_string .= " / "; }
2554 $flags_string .= "No Recursion";
2556 if ($flags =~ m/d/) {
2557 if ($flags_string) { $flags_string .= " / "; }
2558 $flags_string .= "Has Details";
2560 if ($flags =~ m/a/) {
2561 if ($flags_string) { $flags_string .= " / "; }
2562 $flags_string .= "Action";
2564 if ($flags =~ m/h/) {
2565 if ($flags_string) { $flags_string .= " / "; }
2566 $flags_string .= "No Hooks";
2572 $synop .= ": $flags_string\n";
2574 $pad = ' ' x (5 + $name_len - length("user_data"));
2575 $desc .= "$pad : $flags_string</programlisting>\n";
2580 $desc .= "</programlisting>\n";
2583 my $parameters = &OutputParamDescriptions ("SIGNAL", $symbol);
2584 my $parameters_output = 0;
2586 $AllSymbols{$symbol} = 1;
2587 if (defined ($SymbolDocs{$symbol})) {
2588 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2590 # Try to insert the parameter table at the author's desired
2591 # position. Otherwise we need to tag it onto the end.
2592 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
2593 $parameters_output = 1;
2595 $desc .= $symbol_docs;
2597 if (!IsEmptyDoc($SymbolDocs{$symbol})) {
2598 $AllDocumentedSymbols{$symbol} = 1;
2602 if ($parameters_output == 0) {
2603 $desc .= $parameters;
2606 if (exists $Since{$symbol}) {
2607 $desc .= "<para>Since $Since{$symbol}</para>";
2609 if (exists $StabilityLevel{$symbol}) {
2610 $desc .= "<para>Stability Level: $StabilityLevel{$symbol}</para>";
2612 $desc .= "</refsect2>";
2615 return ($synop, $desc);
2619 #############################################################################
2620 # Function : GetArgs
2621 # Description : Returns the synopsis and detailed description DocBook output
2622 # for the Args of a given GtkObject subclass.
2623 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
2624 #############################################################################
2630 my $child_synop = "";
2631 my $child_desc = "";
2632 my $style_synop = "";
2633 my $style_desc = "";
2636 for ($i = 0; $i <= $#ArgObjects; $i++) {
2637 if ($ArgObjects[$i] eq $object) {
2638 # print "Found arg: $ArgNames[$i]\n";
2639 my $name = $ArgNames[$i];
2640 # Remember only one colon so we don't clash with signals.
2641 my $symbol = "${object}:${name}";
2642 # I've used two dashes here for the same reason.
2643 my $id = &CreateValidSGMLID ("$object--$name");
2645 my $type = $ArgTypes[$i];
2647 my $range = $ArgRanges[$i];
2648 my $range_output = CreateValidSGML($range);
2649 my $default = $ArgDefaults[$i];
2650 my $default_output = CreateValidSGML($default);
2652 if ($type eq "GtkSignal") {
2653 $type = "GtkSignalFunc, gpointer";
2654 $type_output = &MakeXRef ("GtkSignalFunc") . ", "
2655 . &MakeXRef ("gpointer");
2656 } elsif ($type eq "GtkString") {
2658 $type_output = &MakeXRef ("gchar") . "*";
2660 $type_output = &MakeXRef ($type);
2663 my $flags = $ArgFlags[$i];
2664 my $flags_string = "";
2666 if ($flags =~ m/r/) {
2667 $flags_string = "Read";
2669 if ($flags =~ m/w/) {
2670 if ($flags_string) { $flags_string .= " / "; }
2671 $flags_string .= "Write";
2673 if ($flags =~ m/x/) {
2674 if ($flags_string) { $flags_string .= " / "; }
2675 $flags_string .= "Construct";
2677 if ($flags =~ m/X/) {
2678 if ($flags_string) { $flags_string .= " / "; }
2679 $flags_string .= "Construct Only";
2682 $AllSymbols{$symbol} = 1;
2684 if (defined($SymbolDocs{$symbol}) &&
2685 !IsEmptyDoc($SymbolDocs{$symbol})) {
2686 $blurb = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2687 $AllDocumentedSymbols{$symbol} = 1;
2690 if (!($ArgBlurbs[$i] eq "")) {
2691 $AllDocumentedSymbols{$symbol} = 1;
2693 $blurb = "<para>" . &CreateValidSGML ($ArgBlurbs[$i]) . "</para>";
2696 my $pad1 = " " x (24 - length ($name));
2697 my $pad2 = " " x (20 - length ($type));
2700 if ($flags =~ m/c/) {
2701 $kind = "child property";
2703 elsif ($flags =~ m/s/) {
2704 $kind = "style property";
2710 my $arg_synop = " "<link linkend=\"$id\">$name</link>"$pad1 $type_output $pad2 : $flags_string\n";
2711 my $arg_desc = "<refsect2><title><anchor id=\"$id\"${empty_element_end}The <literal>"$name"</literal> $kind</title>\n";
2712 $arg_desc .= MakeIndexterms($symbol);
2713 $arg_desc .= "<programlisting> "$name"$pad1 $type_output $pad2 : $flags_string</programlisting>\n";
2714 $arg_desc .= $blurb;
2716 $arg_desc .= "<para>Allowed values: $range_output</para>\n";
2718 if ($default ne "") {
2719 $arg_desc .= "<para>Default value: $default_output</para>\n";
2721 if (exists $Since{$symbol}) {
2722 $arg_desc .= "<para>Since $Since{$symbol}</para>\n";
2724 if (exists $StabilityLevel{$symbol}) {
2725 $arg_desc .= "<para>Stability Level $StabilityLevel{$symbol}</para>\n";
2727 $arg_desc .= "</refsect2>\n";
2729 if ($flags =~ m/c/) {
2730 $child_synop .= $arg_synop;
2731 $child_desc .= $arg_desc;
2733 elsif ($flags =~ m/s/) {
2734 $style_synop .= $arg_synop;
2735 $style_desc .= $arg_desc;
2738 $synop .= $arg_synop;
2743 return ($synop, $child_synop, $style_synop, $desc, $child_desc, $style_desc);
2747 #############################################################################
2748 # Function : ReadSourceDocumentation
2749 # Description : This reads in the documentation embedded in comment blocks
2750 # in the source code (for Gnome).
2752 # Parameter descriptions override any in the template files.
2753 # Function descriptions are placed before any description from
2754 # the template files.
2756 # It recursively descends the source directory looking for .c
2757 # files and scans them looking for specially-formatted comment
2760 # Arguments : $source_dir - the directory to scan.
2761 #############m###############################################################
2763 sub ReadSourceDocumentation {
2764 my ($source_dir) = @_;
2765 my ($file, $dir, @suffix_list, $suffix);
2766 # print "Scanning source directory: $source_dir\n";
2768 # This array holds any subdirectories found.
2771 @suffix_list = split (/,/, $SOURCE_SUFFIXES);
2773 opendir (SRCDIR, $source_dir)
2774 || die "Can't open source directory $source_dir: $!";
2776 foreach $file (readdir (SRCDIR)) {
2777 if ($file =~ /^\./) {
2779 } elsif (-d "$source_dir/$file") {
2780 push (@subdirs, $file);
2781 } elsif (@suffix_list) {
2782 foreach $suffix (@suffix_list) {
2783 if ($file =~ m/\.\Q${suffix}\E$/) {
2784 &ScanSourceFile ("$source_dir/$file");
2787 } elsif ($file =~ m/\.[ch]$/) {
2788 &ScanSourceFile ("$source_dir/$file");
2793 # Now recursively scan the subdirectories.
2794 foreach $dir (@subdirs) {
2795 next if ($IGNORE_FILES =~ m/(\s|^)\Q${dir}\E(\s|$)/);
2796 &ReadSourceDocumentation ("$source_dir/$dir");
2801 #############################################################################
2802 # Function : ScanSourceFile
2803 # Description : Scans one source file looking for specially-formatted comment
2804 # blocks. Later &MergeSourceDocumentation is used to merge any
2805 # documentation found with the documentation already read in
2806 # from the template files.
2808 # Arguments : $file - the file to scan.
2809 #############################################################################
2811 sub ScanSourceFile {
2815 if ($file =~ m/^.*[\/\\]([^\/\\]*)$/) {
2818 print "WARNING: Can't find basename of file $file\n";
2822 # Check if the basename is in the list of files to ignore.
2823 if ($IGNORE_FILES =~ m/(\s|^)\Q${basename}\E(\s|$)/) {
2827 # print "DEBUG: Scanning $file\n";
2829 open (SRCFILE, $file)
2830 || die "Can't open $file: $!";
2831 my $in_comment_block = 0;
2833 my ($in_description, $in_return, $in_since, $in_stability, $in_deprecated);
2834 my ($description, $return_desc, $return_start, $return_style);
2835 my ($since_desc, $stability_desc, $deprecated_desc);
2837 my $ignore_broken_returns;
2840 # Look for the start of a comment block.
2841 if (!$in_comment_block) {
2842 if (m%^\s*/\*.*\*/%) {
2843 #one-line comment - not gtkdoc
2844 } elsif (m%^\s*/\*\*\s%) {
2845 # print "Found comment block start\n";
2847 $in_comment_block = 1;
2849 # Reset all the symbol data.
2851 $in_description = 0;
2860 $deprecated_desc = "";
2861 $stability_desc = "";
2862 $current_param = -1;
2863 $ignore_broken_returns = 0;
2869 # We're in a comment block. Check if we've found the end of it.
2873 WARNING: Symbol name not found at the start of the comment block.
2877 # Add the return value description onto the end of the params.
2879 push (@params, "Returns");
2880 push (@params, $return_desc);
2881 if ($return_style eq 'broken') {
2883 WARNING: Free-form return value description in $symbol.
2884 Use `Returns:' to avoid ambiguities.
2888 # Convert special SGML characters
2889 $description = &ConvertSGMLChars ($symbol, $description);
2891 for ($k = 1; $k <= $#params; $k += 2) {
2892 $params[$k] = &ConvertSGMLChars ($symbol, $params[$k]);
2895 # Handle Section docs
2896 if ($symbol =~ m/SECTION:\s*(.*)/) {
2900 #print "SECTION DOCS found in source for : '$real_symbol'\n";
2901 $ignore_broken_returns = 1;
2902 for ($k = 0; $k <= $#params; $k += 2) {
2903 #print " '".$params[$k]."'\n";
2904 $params[$k] = "\L$params[$k]";
2905 if ($params[$k] eq "short_description") {
2906 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Short_Description"}=$params[$k+1];
2907 } elsif ($params[$k] eq "see_also") {
2908 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:See_Also"}=$params[$k+1];
2909 } elsif ($params[$k] eq "title") {
2910 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Title"}=$params[$k+1];
2911 } elsif ($params[$k] eq "stability") {
2912 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Stability_Level"}=$params[$k+1];
2913 } elsif ($params[$k] eq "section_id") {
2914 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Section_Id"}=$params[$k+1];
2915 } elsif ($params[$k] eq "include") {
2916 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Include"}=$params[$k+1];
2919 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Long_Description"}=$description;
2921 #print "SYMBOL DOCS found in source for : '$symbol' ",length($description), "\n";
2922 $SourceSymbolDocs{$symbol} = $description;
2923 $SourceSymbolParams{$symbol} = [ @params ];
2927 $Since{$symbol} = &ConvertSGMLChars ($symbol, $since_desc);
2930 if ($stability_desc) {
2931 $stability_desc = &ParseStabilityLevel($stability_desc, "Stability level for $symbol");
2932 $StabilityLevel{$symbol} = &ConvertSGMLChars ($symbol, $stability_desc);
2935 if ($deprecated_desc) {
2936 if (exists $Deprecated{$symbol}) {
2940 WARNING: $symbol is deprecated in the inline comments
2941 but no deprecation guards were found around the declaration.
2942 (See the --deprecated-guards option for gtkdoc-scan.)
2945 $Deprecated{$symbol} = &ConvertSGMLChars ($symbol, $deprecated_desc);
2949 $in_comment_block = 0;
2953 # Get rid of ' * ' at start of every line in the comment block.
2955 # But make sure we don't get rid of the newline at the end.
2959 # print "DEBUG: scanning :$_";
2961 # If we haven't found the symbol name yet, look for it.
2963 if (m%^\s*(SECTION:\s*\S+)%) {
2965 #print "SECTION DOCS found in source for : '$symbol'\n";
2966 $ignore_broken_returns = 1;
2967 } elsif (m%^\s*([\w:-]*\w)\s*:?%) {
2969 #print "SYMBOL DOCS found in source for : '$symbol'\n";
2974 # If we're in the return value description, add it to the end.
2976 # If we find another valid returns line, we assume that the first
2977 # one was really part of the description.
2978 if (m/^\s*(returns:|return\s+value:)/i) {
2979 $description .= $return_start . $return_desc;
2981 if ($return_style eq 'sane') {
2983 WARNING: Multiple Returns for $symbol
2986 $return_style = 'sane';
2987 $ignore_broken_returns = 1;
2989 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
2990 $description .= $return_start . $return_desc;
2992 $return_style = 'broken';
2994 } elsif (m%^\s*since:%i) {
2998 } elsif (m%^\s*stability:%i) {
2999 $stability_desc = $';
3002 } elsif (m%^\s*deprecated:%i) {
3003 $deprecated_desc = $';
3013 if (m/^\s*(returns:|return\s+value:)/i) {
3015 if ($return_style eq 'sane') {
3017 WARNING: Multiple Returns for $symbol
3020 $return_style = 'sane';
3021 $ignore_broken_returns = 1;
3025 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3027 $return_style = 'broken';
3031 } elsif (m%^\s*deprecated:%i) {
3032 $deprecated_desc = $';
3035 } elsif (m%^\s*stability:%i) {
3036 $stability_desc = $';
3045 if ($in_stability) {
3046 if (m/^\s*(returns:|return\s+value:)/i) {
3048 if ($return_style eq 'sane') {
3050 WARNING: Multiple Returns for $symbol
3053 $return_style = 'sane';
3054 $ignore_broken_returns = 1;
3058 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3060 $return_style = 'broken';
3064 } elsif (m%^\s*deprecated:%i) {
3065 $deprecated_desc = $';
3068 } elsif (m%^\s*since:%i) {
3073 $stability_desc .= $_;
3078 if ($in_deprecated) {
3079 if (m/^\s*(returns:|return\s+value:)/i) {
3081 if ($return_style eq 'sane') {
3083 WARNING: Multiple Returns for $symbol
3086 $return_style = 'sane';
3087 $ignore_broken_returns = 1;
3091 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3093 $return_style = 'broken';
3097 } elsif (m%^\s*since:%i) {
3101 } elsif (m%^\s*stability:%i) {
3102 $stability_desc = $';
3106 $deprecated_desc .= $_;
3111 # If we're in the description part, check for the 'Returns:' line.
3112 # If that isn't found, add the text to the end.
3113 if ($in_description) {
3114 # Get rid of 'Description:'
3115 s%^\s*Description:%%;
3117 if (m/^\s*(returns:|return\s+value:)/i) {
3119 if ($return_style eq 'sane') {
3121 WARNING: Multiple Returns for $symbol
3124 $return_style = 'sane';
3125 $ignore_broken_returns = 1;
3129 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3131 $return_style = 'broken';
3135 } elsif (m%^\s*since:%i) {
3139 } elsif (m%^\s*deprecated:%i) {
3140 $deprecated_desc = $';
3143 } elsif (m%^\s*stability:%i) {
3144 $stability_desc = $';
3153 # We must be in the parameters. Check for the empty line below them.
3155 $in_description = 1;
3159 # Look for a parameter name.
3160 if (m%^\s*@(\S+)\s*:%) {
3161 my $param_name = $1;
3162 # print "Found parameter: $param_name\n";
3163 # Allow '...' as the Varargs parameter.
3164 if ($param_name eq "...") {
3165 $param_name = "Varargs";
3167 if ("\L$param_name" eq "returns") {
3168 $return_style = 'sane';
3169 $ignore_broken_returns = 1;
3171 push (@params, $param_name);
3173 $current_param += 2;
3177 # We must be in the middle of a parameter description, so add it on
3178 # to the last element in @params.
3179 if ($current_param == -1) {
3181 ERROR parsing comment block file : parameter expected -
3185 $params[$#params] .= $_;
3191 #############################################################################
3192 # Function : OutputMissingDocumentation
3193 # Description : Outputs report of documentation coverage to a file
3196 #############################################################################
3198 sub OutputMissingDocumentation {
3199 my $n_documented = 0;
3200 my $n_incomplete = 0;
3206 my $buffer_deprecated = "";
3207 my $buffer_descriptions = "";
3209 open (UNDOCUMENTED, ">$ROOT_DIR/$MODULE-undocumented.txt")
3210 || die "Can't create $ROOT_DIR/$MODULE-undocumented.txt";
3212 foreach $symbol (sort (keys (%AllSymbols))) {
3213 if ($symbol !~ /:(Title|Long_Description|Short_Description|See_Also|Stability_Level|Include)/) {
3215 if (exists ($AllDocumentedSymbols{$symbol})) {
3217 if (exists ($AllIncompleteSymbols{$symbol})) {
3219 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3221 } elsif (exists $Deprecated{$symbol}) {
3222 if (exists ($AllIncompleteSymbols{$symbol})) {
3224 $buffer_deprecated .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3226 $buffer_deprecated .= $symbol . "\n";
3229 if (exists ($AllIncompleteSymbols{$symbol})) {
3231 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3233 $buffer .= $symbol . "\n";
3236 } elsif ($symbol =~ /:(Long_Description|Short_Description)/) {
3238 #my $len1=(exists($SymbolDocs{$symbol}))?length($SymbolDocs{$symbol}):-1;
3239 #my $len2=(exists($AllDocumentedSymbols{$symbol}))?length($AllDocumentedSymbols{$symbol}):-1;
3240 #print "%%%% $symbol : $len1,$len2\n";
3241 if (((exists ($SymbolDocs{$symbol})) && (length ($SymbolDocs{$symbol}) > 0))
3242 || ((exists ($AllDocumentedSymbols{$symbol})) && (length ($AllDocumentedSymbols{$symbol}) > 0))) {
3245 $symbol =~ m/^.*\/(.*)$/;
3246 $buffer_descriptions .= $1 . "\n";
3251 $buffer .= "\n" . $buffer_deprecated . "\n" . $buffer_descriptions;
3256 $percent = ($n_documented / $total) * 100.0;
3259 printf UNDOCUMENTED "%.0f%% symbol docs coverage.\n", $percent;
3260 print UNDOCUMENTED "$n_documented symbols documented.\n";
3261 print UNDOCUMENTED "$n_incomplete symbols incomplete.\n";
3262 print UNDOCUMENTED ($total - $n_documented) . " not documented.\n\n\n";
3264 print UNDOCUMENTED $buffer;
3266 close (UNDOCUMENTED);
3268 printf (("%.0f%% symbol docs coverage ($n_documented symbols documented, $n_incomplete symbols incomplete, " . ($total - $n_documented) . " not documented)\nSee $MODULE-undocumented.txt for a list of missing docs.\nThe doc coverage percentage doesn't include intro sections.\n"), $percent);
3272 #############################################################################
3273 # Function : OutputUndeclaredSymbols
3274 # Description : Outputs symbols that are undeclared yet documented to a file
3277 #############################################################################
3279 sub OutputUndeclaredSymbols {
3280 open(UNDECLARED, ">$ROOT_DIR/$MODULE-undeclared.txt")
3281 || die "Can't create $ROOT_DIR/$MODULE-undeclared.txt";
3283 if (%UndeclaredSymbols) {
3284 print UNDECLARED (join("\n", sort keys %UndeclaredSymbols));
3285 print UNDECLARED "\n";
3286 print "See $MODULE-undeclared.txt for the list of undeclared symbols.\n"
3292 #############################################################################
3293 # Function : OutputAllSymbols
3294 # Description : Outputs list of all symbols to a file
3297 #############################################################################
3299 sub OutputAllSymbols {
3300 my $n_documented = 0;
3306 open (SYMBOLS, ">$ROOT_DIR/$MODULE-symbols.txt")
3307 || die "Can't create $ROOT_DIR/$MODULE-symbols.txt";
3309 foreach $symbol (sort (keys (%AllSymbols))) {
3310 print SYMBOLS $symbol . "\n"
3317 #############################################################################
3318 # Function : MergeSourceDocumentation
3319 # Description : This merges documentation read from a source file into the
3320 # documentation read in from a template file.
3322 # Parameter descriptions override any in the template files.
3323 # Function descriptions are placed before any description from
3324 # the template files.
3327 #############################################################################
3329 sub MergeSourceDocumentation {
3331 foreach $symbol (keys (%SymbolDocs)) {
3332 $AllSymbols{$symbol} = 1;
3334 my $have_tmpl_docs = 0;
3336 ## See if the symbol is documented out-of-line
3337 my $tmpl_doc = $SymbolDocs{$symbol};
3338 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3339 $tmpl_doc =~ s/<\/?[a-z]+>//g;
3340 $tmpl_doc =~ s/\s//g;
3341 if ($tmpl_doc ne "") {
3342 $have_tmpl_docs = 1;
3345 if (exists ($SourceSymbolDocs{$symbol})) {
3346 my $src_doc = $SourceSymbolDocs{$symbol};
3347 my $tmpl_doc = $SymbolDocs{$symbol};
3348 my $type = $DeclarationTypes {$symbol};
3350 my $item = "Parameter";
3351 if (defined ($type)) {
3352 if ($type eq 'STRUCT') {
3354 } elsif ($type eq 'ENUM') {
3356 } elsif ($type eq 'UNION') {
3363 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3364 $src_doc =~ s/^\s+//;
3365 $src_doc =~ s/\s+$//;
3367 # Don't output warnings for overridden titles as titles are
3368 # automatically generated in the -sections.txt file so are often
3370 if ($have_tmpl_docs && $symbol !~ m/:Title$/) {
3372 WARNING: Documentation in template file for $symbol being overridden by inline comments
3376 if ($src_doc ne "") {
3377 $AllDocumentedSymbols{$symbol} = 1;
3380 # Convert <!--PARAMETERS--> with any blank lines around it to
3381 # a </para> followed by <!--PARAMETERS--> followed by <para>.
3382 $src_doc =~ s%\n+\s*<!--PARAMETERS-->\s*\n+%\n</para>\n<!--PARAMETERS-->\n<para>\n%g;
3384 # If there is a blank line, finish the paragraph and start another.
3385 $src_doc = &ConvertBlankLines ($src_doc, $symbol);
3387 if ($symbol =~ m/$TMPL_DIR\/.+:Long_Description/) {
3388 # FIXME: should we check for empty $tmpl_doc ?
3389 $SymbolDocs{$symbol} = "<para>\n$src_doc</para>\n$tmpl_doc"
3390 } elsif ($symbol =~ m/$TMPL_DIR\/.+:.+/) {
3391 # For the title/summary/see also section docs we don't want to
3392 # add any <para> tags.
3393 $SymbolDocs{$symbol} = "$src_doc"
3395 $SymbolDocs{$symbol} = "<para>\n$src_doc</para>\n$tmpl_doc";
3398 if ($symbol =~ m/.*::.*/) {
3399 # For signals we prefer the param names from the source docs,
3400 # since the ones from the templates are likely to contain the
3401 # artificial argn names which are generated by gtkdoc-scangobj.
3402 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol}
3403 # FIXME: we need to check for empty docs here as well!
3405 # The templates contain the definitive parameter names and order,
3406 # so we will not change that. We only override the actual text.
3407 my $tmpl_params = $SymbolParams{$symbol};
3408 if (!defined ($tmpl_params)) {
3409 #print "No merge for $symbol\n";
3413 my $params = $SourceSymbolParams{$symbol};
3415 for ($j = 0; $j <= $#$tmpl_params; $j += 2) {
3416 my $tmpl_param_name = $$tmpl_params[$j];
3418 # Allow '...' as the Varargs parameter.
3419 if ($tmpl_param_name eq "...") {
3420 $tmpl_param_name = "Varargs";
3423 # Try to find the param in the source comment documentation.
3426 for ($k = 0; $k <= $#$params; $k += 2) {
3427 my $param_name = $$params[$k];
3428 my $param_desc = $$params[$k + 1];
3430 # We accept changes in case, since the Gnome source docs
3431 # contain a lot of these.
3432 if ("\L$param_name" eq "\L$tmpl_param_name") {
3435 # Override the description.
3436 $$tmpl_params[$j + 1] = $param_desc ;
3438 # Set the name to "" to mark it as used.
3444 # If it looks like the parameters are there, but not
3445 # in the right place, try to explain a bit better.
3446 if ((!$found) && ($src_doc =~ m/\@$tmpl_param_name:/)) {
3448 Parameters must start on the line immediately after the function
3454 # Now we output a warning if parameters have been described which
3456 for ($j = 0; $j <= $#$params; $j += 2) {
3457 my $param_name = $$params[$j];
3459 # the template builder cannot detect if a macro returns
3461 if(($type eq "MACRO") && ($param_name eq "Returns")) {
3465 WARNING: $item described in source code comment block but does not exist -
3466 $type: $symbol $item: $param_name.
3472 if ($have_tmpl_docs) {
3473 $AllDocumentedSymbols{$symbol} = 1;
3476 # if this symbol is documented, check if docs are complete
3477 $tmpl_doc = $SymbolDocs{$symbol};
3478 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3479 $tmpl_doc =~ s/<\/?[a-z]+>//g;
3480 $tmpl_doc =~ s/\s//g;
3481 if ($tmpl_doc ne "") {
3482 my $tmpl_params = $SymbolParams{$symbol};
3483 if (defined ($tmpl_params)) {
3484 my $type = $DeclarationTypes {$symbol};
3486 my $item = "Parameter";
3487 if (defined ($type)) {
3488 if ($type eq 'STRUCT') {
3490 } elsif ($type eq 'ENUM') {
3492 } elsif ($type eq 'UNION') {
3500 for ($j = 0; $j <= $#$tmpl_params; $j += 2) {
3501 # Output a warning if the parameter is empty and
3502 # remember for stats.
3503 my $tmpl_param_name = $$tmpl_params[$j];
3504 my $tmpl_param_desc = $$tmpl_params[$j + 1];
3505 if ($tmpl_param_desc !~ m/\S/) {
3506 if (exists ($AllIncompleteSymbols{$symbol})) {
3507 $AllIncompleteSymbols{$symbol}.=", ".$tmpl_param_name;
3509 $AllIncompleteSymbols{$symbol}=$tmpl_param_name;
3512 #WARNING: $item description missing in source code comment block -
3513 # $type: $symbol $item: $tmpl_param_name.
3525 if ($doc =~ /^\s*<para>\s*(FIXME)?\s*<\/para>\s*$/) {
3533 # This converts blank lines to "</para><para>", but only outside CDATA and
3534 # <programlisting> tags.
3535 sub ConvertBlankLines {
3536 return &ModifyXMLElements ($_[0], $_[1],
3537 "<!\\[CDATA\\[|<programlisting[^>]*>|\\|\\[",
3538 \&ConvertBlankLinesEndTag,
3539 \&ConvertBlankLinesCallback);
3543 sub ConvertBlankLinesEndTag {
3544 if ($_[0] eq "<!\[CDATA\[") {
3546 } elsif ($_[0] eq "|[") {
3549 return "</programlisting>";
3553 sub ConvertBlankLinesCallback {
3554 my ($text, $symbol, $tag) = @_;
3556 # If we're not in CDATA or a <programlisting> we convert blank lines so
3557 # they start a new <para>.
3559 $text =~ s%\n{2,}%\n</para>\n<para>\n%g;
3566 #############################################################################
3567 # LIBRARY FUNCTIONS - These functions are used in both gtkdoc-mkdb and
3568 # gtkdoc-mktmpl and should eventually be moved to a
3570 #############################################################################
3572 #############################################################################
3573 # Function : ReadDeclarationsFile
3574 # Description : This reads in a file containing the function/macro/enum etc.
3577 # Note that in some cases there are several declarations with
3578 # the same name, e.g. for conditional macros. In this case we
3579 # set a flag in the %DeclarationConditional hash so the
3580 # declaration is not shown in the docs.
3582 # If a macro and a function have the same name, e.g. for
3583 # gtk_object_ref, the function declaration takes precedence.
3585 # Some opaque structs are just declared with 'typedef struct
3586 # _name name;' in which case the declaration may be empty.
3587 # The structure may have been found later in the header, so
3588 # that overrides the empty declaration.
3590 # Arguments : $file - the declarations file to read
3591 # $override - if declarations in this file should override
3592 # any current declaration.
3593 #############################################################################
3595 sub ReadDeclarationsFile {
3596 my ($file, $override) = @_;
3598 if ($override == 0) {
3600 %DeclarationTypes = ();
3601 %DeclarationConditional = ();
3602 %DeclarationOutput = ();
3606 || die "Can't open $file";
3607 my $declaration_type = "";
3608 my $declaration_name;
3610 my $is_deprecated = 0;
3612 if (!$declaration_type) {
3613 if (m/^<([^>]+)>/) {
3614 $declaration_type = $1;
3615 $declaration_name = "";
3616 # print "Found declaration: $declaration_type\n";
3620 if (m%^<NAME>(.*)</NAME>%) {
3621 $declaration_name = $1;
3622 } elsif (m%^<DEPRECATED/>%) {
3624 } elsif (m%^</$declaration_type>%) {
3625 # print "Found end of declaration: $declaration_name\n";
3626 # Check that the declaration has a name
3627 if ($declaration_name eq "") {
3628 print "ERROR: $declaration_type has no name $file:$.\n";
3631 # If the declaration is an empty typedef struct _XXX XXX
3632 # set the flag to indicate the struct has a typedef.
3633 if ($declaration_type eq 'STRUCT'
3634 && $declaration =~ m/^\s*$/) {
3635 # print "Struct has typedef: $declaration_name\n";
3636 $StructHasTypedef{$declaration_name} = 1;
3639 # Check if the symbol is already defined.
3640 if (defined ($Declarations{$declaration_name})
3641 && $override == 0) {
3642 # Function declarations take precedence.
3643 if ($DeclarationTypes{$declaration_name} eq 'FUNCTION') {
3645 } elsif ($declaration_type eq 'FUNCTION') {
3646 if ($is_deprecated) {
3647 $Deprecated{$declaration_name} = "";
3649 $Declarations{$declaration_name} = $declaration;
3650 $DeclarationTypes{$declaration_name} = $declaration_type;
3651 } elsif ($DeclarationTypes{$declaration_name}
3652 eq $declaration_type) {
3653 # If the existing declaration is empty, or is just a
3654 # forward declaration of a struct, override it.
3655 if ($declaration_type eq 'STRUCT') {
3656 if ($Declarations{$declaration_name} =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
3657 if ($is_deprecated) {
3658 $Deprecated{$declaration_name} = "";
3660 $Declarations{$declaration_name} = $declaration;
3661 } elsif ($declaration =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
3662 # Ignore an empty or forward declaration.
3664 print "WARNING: Structure has multiple definitions: $declaration_name\n";
3668 # set flag in %DeclarationConditional hash for
3669 # multiply defined macros/typedefs.
3670 $DeclarationConditional{$declaration_name} = 1;
3673 print "ERROR: $declaration_name has multiple definitions\n";
3676 if ($is_deprecated) {
3677 $Deprecated{$declaration_name} = "";
3679 $Declarations{$declaration_name} = $declaration;
3680 $DeclarationTypes{$declaration_name} = $declaration_type;
3683 $declaration_type = "";
3694 #############################################################################
3695 # Function : ReadSignalsFile
3696 # Description : This reads in an existing file which contains information on
3697 # all GTK signals. It creates the arrays @SignalNames and
3698 # @SignalPrototypes containing info on the signals. The first
3699 # line of the SignalPrototype is the return type of the signal
3700 # handler. The remaining lines are the parameters passed to it.
3701 # The last parameter, "gpointer user_data" is always the same
3702 # so is not included.
3703 # Arguments : $file - the file containing the signal handler prototype
3705 #############################################################################
3707 sub ReadSignalsFile {
3715 my $signal_prototype;
3717 # Reset the signal info.
3718 @SignalObjects = ();
3720 @SignalReturns = ();
3722 @SignalPrototypes = ();
3727 if (!open (INPUT, $file)) {
3728 warn "Can't open $file - skipping signals\n";
3735 $signal_object = "";
3737 $signal_returns = "";
3738 $signal_prototype = "";
3741 if (m/^<NAME>(.*)<\/NAME>/) {
3743 if ($signal_name =~ m/^(.*)::(.*)$/) {
3744 $signal_object = $1;
3745 ($signal_name = $2) =~ s/_/-/g;
3746 # print "Found signal: $signal_name\n";
3748 print "Invalid signal name: $signal_name\n";
3750 } elsif (m/^<RETURNS>(.*)<\/RETURNS>/) {
3751 $signal_returns = $1;
3752 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
3754 } elsif (m%^</SIGNAL>%) {
3755 # print "Found end of signal: ${signal_object}::${signal_name}\nReturns: ${signal_returns}\n${signal_prototype}";
3756 push (@SignalObjects, $signal_object);
3757 push (@SignalNames, $signal_name);
3758 push (@SignalReturns, $signal_returns);
3759 push (@SignalFlags, $signal_flags);
3760 push (@SignalPrototypes, $signal_prototype);
3763 $signal_prototype .= $_;
3771 #############################################################################
3772 # Function : ReadTemplateFile
3773 # Description : This reads in the manually-edited documentation file
3774 # corresponding to the file currently being created, so we can
3775 # insert the documentation at the appropriate places.
3776 # It outputs %SymbolTypes, %SymbolDocs and %SymbolParams, which
3777 # is a hash of arrays.
3778 # NOTE: This function is duplicated in gtkdoc-mkdb (but
3779 # slightly different).
3780 # Arguments : $docsfile - the template file to read in.
3781 # $skip_unused_params - 1 if the unused parameters should be
3783 #############################################################################
3785 sub ReadTemplateFile {
3786 my ($docsfile, $skip_unused_params) = @_;
3788 my $template = "$docsfile.sgml";
3789 # print "Reading $template\n";
3790 if (! -f $template) {
3791 print "File doesn't exist: $template\n";
3795 my $current_type = ""; # Type of symbol being read.
3796 my $current_symbol = ""; # Name of symbol being read.
3797 my $symbol_doc = ""; # Description of symbol being read.
3798 my @params; # Parameter names and descriptions of current
3799 # function/macro/function typedef.
3800 my $current_param = -1; # Index of parameter currently being read.
3801 # Note that the param array contains pairs
3802 # of param name & description.
3803 my $in_unused_params = 0; # True if we are reading in the unused params.
3804 my $in_deprecated = 0;
3806 my $in_stability = 0;
3808 open (DOCS, "$template")
3809 || die "Can't open file $template: $!";
3811 if (m/^<!-- ##### ([A-Z_]+) (\S+) ##### -->/) {
3814 if ($symbol eq "Title"
3815 || $symbol eq "Short_Description"
3816 || $symbol eq "Long_Description"
3817 || $symbol eq "See_Also"
3818 || $symbol eq "Stability_Level"
3819 || $symbol eq "Include") {
3821 $symbol = $docsfile . ":" . $symbol;
3824 # print "Found symbol: $symbol\n";
3826 # Store previous symbol, but remove any trailing blank lines.
3827 if ($current_symbol ne "") {
3828 $symbol_doc =~ s/\s+$//;
3829 $SymbolTypes{$current_symbol} = $current_type;
3830 $SymbolDocs{$current_symbol} = $symbol_doc;
3832 # Check that the stability level is valid.
3833 if ($StabilityLevel{$current_symbol}) {
3834 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, "Stability level for $current_symbol");
3837 if ($current_param >= 0) {
3838 $SymbolParams{$current_symbol} = [ @params ];
3840 # Delete any existing params in case we are overriding a
3841 # previously read template.
3842 delete $SymbolParams{$current_symbol};
3845 $current_type = $type;
3846 $current_symbol = $symbol;
3847 $current_param = -1;
3848 $in_unused_params = 0;
3855 } elsif (m/^<!-- # Unused Parameters # -->/) {
3856 # print "DEBUG: Found unused parameters\n";
3857 $in_unused_params = 1;
3860 } elsif ($in_unused_params && $skip_unused_params) {
3861 # When outputting the DocBook we skip unused parameters.
3862 # print "DEBUG: Skipping unused param: $_";
3866 # Check if param found. Need to handle "..." and "format...".
3867 if (s/^\@([\w\.]+):\040?//) {
3868 my $param_name = $1;
3869 # Allow variations of 'Returns'
3870 if ($param_name =~ m/^[Rr]eturns?$/) {
3871 $param_name = "Returns";
3873 # print "Found param for symbol $current_symbol : '$param_name'= '$_'\n";
3875 if ($param_name eq "Deprecated") {
3877 $Deprecated{$current_symbol} = $_;
3878 } elsif ($param_name eq "Since") {
3880 $Since{$current_symbol} = $_;
3881 } elsif ($param_name eq "Stability") {
3883 $StabilityLevel{$current_symbol} = $_;
3885 push (@params, $param_name);
3887 $current_param += 2;
3890 if ($in_deprecated) {
3891 $Deprecated{$current_symbol} .= $_;
3892 } elsif ($in_since) {
3893 $Since{$current_symbol} .= $_;
3894 } elsif ($in_stability) {
3895 $StabilityLevel{$current_symbol} .= $_;
3896 } elsif ($current_param >= 0) {
3897 $params[$current_param] .= $_;
3905 # Remember to finish the current symbol doccs.
3906 if ($current_symbol ne "") {
3908 $symbol_doc =~ s/\s+$//;
3909 $SymbolTypes{$current_symbol} = $current_type;
3910 $SymbolDocs{$current_symbol} = $symbol_doc;
3912 # Check that the stability level is valid.
3913 if ($StabilityLevel{$current_symbol}) {
3914 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, "Stability level for $current_symbol");
3917 if ($current_param >= 0) {
3918 $SymbolParams{$current_symbol} = [ @params ];
3920 # Delete any existing params in case we are overriding a
3921 # previously read template.
3922 delete $SymbolParams{$current_symbol};
3930 #############################################################################
3931 # Function : ReadObjectHierarchy
3932 # Description : This reads in the $MODULE-hierarchy.txt file containing all
3933 # the GtkObject subclasses described in this module (and their
3935 # It places them in the @Objects array, and places their level
3936 # in the widget hierarchy in the @ObjectLevels array, at the
3937 # same index. GtkObject, the root object, has a level of 1.
3939 # FIXME: the version in gtkdoc-mkdb also generates tree_index.sgml
3940 # as it goes along, this should be split out into a separate
3944 #############################################################################
3946 sub ReadObjectHierarchy {
3950 if (! -f $OBJECT_TREE_FILE) {
3953 if (!open (INPUT, $OBJECT_TREE_FILE)) {
3954 warn "Can't open $OBJECT_TREE_FILE - skipping object tree\n";
3958 my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.sgml";
3959 my $new_tree_index = "$SGML_OUTPUT_DIR/tree_index.new";
3960 my $tree_header = $doctype_header;
3961 $tree_header =~ s/<!DOCTYPE \w+/<!DOCTYPE screen/;
3963 open (OUTPUT, ">$new_tree_index")
3964 || die "Can't create $new_tree_index";
3965 print (OUTPUT "$tree_header<screen>\n");
3967 # Only emit objects if they are supposed to be documented, or if
3968 # they have documented children. To implement this, we maintain a
3969 # stack of pending objects which will be emitted if a documented
3971 my @pending_objects = ();
3972 my @pending_levels = ();
3976 my $level = (length($`)) / 2 + 1;
3979 while (($#pending_levels >= 0) && ($pending_levels[$#pending_levels] >= $level)) {
3980 my $pobject = pop(@pending_objects);
3981 my $plevel = pop(@pending_levels);
3984 push (@pending_objects, $object);
3985 push (@pending_levels, $level);
3987 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
3988 while ($#pending_levels >= 0) {
3989 $object = shift @pending_objects;
3990 $level = shift @pending_levels;
3991 $xref = &MakeXRef ($object);
3993 print (OUTPUT ' ' x ($level * 4), "$xref\n");
3994 push (@Objects, $object);
3995 push (@ObjectLevels, $level);
4000 print (OUTPUT "</screen>\n");
4005 &UpdateFileIfChanged ($old_tree_index, $new_tree_index, 0);
4010 #############################################################################
4011 # Function : ReadInterfaces
4012 # Description : This reads in the $MODULE.interfaces file.
4015 #############################################################################
4017 sub ReadInterfaces {
4020 if (! -f $INTERFACES_FILE) {
4023 if (!open (INPUT, $INTERFACES_FILE)) {
4024 warn "Can't open $INTERFACES_FILE - skipping interfaces\n";
4030 my ($object, @ifaces) = split;
4031 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
4032 my @knownIfaces = ();
4034 # filter out private interfaces, but leave foreign interfaces
4035 foreach my $iface (@ifaces) {
4036 if (!exists($KnownSymbols{$iface}) || $KnownSymbols{$iface} == 1) {
4037 push (@knownIfaces, $iface);
4041 $Interfaces{$object} = join(' ', @knownIfaces);
4047 #############################################################################
4048 # Function : ReadPrerequisites
4049 # Description : This reads in the $MODULE.prerequisites file.
4052 #############################################################################
4054 sub ReadPrerequisites {
4055 %Prerequisites = ();
4057 if (! -f $PREREQUISITES_FILE) {
4060 if (!open (INPUT, $PREREQUISITES_FILE)) {
4061 warn "Can't open $PREREQUISITES_FILE - skipping prerequisites\n";
4067 my ($iface, @prereqs) = split;
4068 if (exists($KnownSymbols{$iface}) && $KnownSymbols{$iface} == 1) {
4069 my @knownPrereqs = ();
4071 # filter out private prerequisites, but leave foreign prerequisites
4072 foreach my $prereq (@prereqs) {
4073 if (!exists($KnownSymbols{$prereq}) || $KnownSymbols{$prereq} == 1) {
4074 push (@knownPrereqs, $prereq);
4078 $Prerequisites{$iface} = join(' ', @knownPrereqs);
4084 #############################################################################
4085 # Function : ReadArgsFile
4086 # Description : This reads in an existing file which contains information on
4087 # all GTK args. It creates the arrays @ArgObjects, @ArgNames,
4088 # @ArgTypes, @ArgFlags, @ArgNicks and @ArgBlurbs containing info
4090 # Arguments : $file - the file containing the arg information.
4091 #############################################################################
4106 # Reset the args info.
4119 if (!open (INPUT, $file)) {
4120 warn "Can't open $file - skipping args\n";
4137 if (m/^<NAME>(.*)<\/NAME>/) {
4139 if ($arg_name =~ m/^(.*)::(.*)$/) {
4141 ($arg_name = $2) =~ s/_/-/g;
4142 # print "Found arg: $arg_name\n";
4144 print "Invalid arg name: $arg_name\n";
4146 } elsif (m/^<TYPE>(.*)<\/TYPE>/) {
4148 } elsif (m/^<RANGE>(.*)<\/RANGE>/) {
4150 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
4152 } elsif (m/^<NICK>(.*)<\/NICK>/) {
4154 } elsif (m/^<BLURB>(.*)<\/BLURB>/) {
4156 if ($arg_blurb eq "(null)") {
4159 WARNING: Property ${arg_object}:${arg_name} has no documentation.
4162 } elsif (m/^<DEFAULT>(.*)<\/DEFAULT>/) {
4164 } elsif (m%^</ARG>%) {
4165 # print "Found end of arg: ${arg_object}::${arg_name}\n${arg_type} : ${arg_flags}\n";
4166 push (@ArgObjects, $arg_object);
4167 push (@ArgNames, $arg_name);
4168 push (@ArgTypes, $arg_type);
4169 push (@ArgRanges, $arg_range);
4170 push (@ArgFlags, $arg_flags);
4171 push (@ArgNicks, $arg_nick);
4172 push (@ArgBlurbs, $arg_blurb);
4173 push (@ArgDefaults, $arg_default);
4182 #############################################################################
4183 # Function : CheckIsObject
4184 # Description : Returns 1 if the given name is a GtkObject or a subclass.
4185 # It uses the global @Objects array.
4186 # Note that the @Objects array only contains classes in the
4187 # current module and their ancestors - not all GTK classes.
4188 # Arguments : $name - the name to check.
4189 #############################################################################
4195 foreach $object (@Objects) {
4196 if ($object eq $name) {
4204 #############################################################################
4205 # Function : MakeReturnField
4206 # Description : Pads a string to $RETURN_TYPE_FIELD_WIDTH.
4207 # Arguments : $str - the string to pad.
4208 #############################################################################
4210 sub MakeReturnField {
4213 return $str . (' ' x ($RETURN_TYPE_FIELD_WIDTH - length ($str)));