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 my ($empty_element_end, $doctype_header);
111 if (lc($OUTPUT_FORMAT) eq "xml") {
112 if (!$MAIN_SGML_FILE) {
113 # backwards compatibility
114 if (-e "${MODULE}-docs.sgml") {
115 $MAIN_SGML_FILE="${MODULE}-docs.sgml";
117 $MAIN_SGML_FILE="${MODULE}-docs.xml";
120 $OUTPUT_FORMAT = "xml";
121 $empty_element_end = "/>";
123 if (-e $MAIN_SGML_FILE) {
124 open(INPUT, "<$MAIN_SGML_FILE") || die "Can't open $MAIN_SGML_FILE";
125 $doctype_header = "";
127 if (/^\s*<(book|chapter|article)/) {
128 if ($_ !~ m/http:\/\/www.w3.org\/200[13]\/XInclude/) {
129 $doctype_header = "";
133 $doctype_header .= $_;
138 "<?xml version=\"1.0\"?>\n" .
139 "<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\n" .
140 " \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">\n";
142 $doctype_header =~ s/<!DOCTYPE \w+/<!DOCTYPE refentry/;
144 if (!$MAIN_SGML_FILE) {
145 $MAIN_SGML_FILE="${MODULE}-docs.sgml";
147 $OUTPUT_FORMAT = "sgml";
148 $doctype_header = "";
149 $empty_element_end = ">";
154 # All the files are written in subdirectories beneath here.
155 $TMPL_DIR = $TMPL_DIR ? $TMPL_DIR : "$ROOT_DIR/tmpl";
157 # This is where we put all the DocBook output.
158 $SGML_OUTPUT_DIR = $SGML_OUTPUT_DIR ? $SGML_OUTPUT_DIR : "$ROOT_DIR/$OUTPUT_FORMAT";
160 # This file contains the object hierarchy.
161 my $OBJECT_TREE_FILE = "$ROOT_DIR/$MODULE.hierarchy";
163 # This file contains the interfaces.
164 my $INTERFACES_FILE = "$ROOT_DIR/$MODULE.interfaces";
166 # This file contains the prerequisites.
167 my $PREREQUISITES_FILE = "$ROOT_DIR/$MODULE.prerequisites";
169 # This file contains signal arguments and names.
170 my $SIGNALS_FILE = "$ROOT_DIR/$MODULE.signals";
172 # The file containing Arg information.
173 my $ARGS_FILE = "$ROOT_DIR/$MODULE.args";
175 # These global arrays store information on signals. Each signal has an entry
176 # in each of these arrays at the same index, like a multi-dimensional array.
177 my @SignalObjects; # The GtkObject which emits the signal.
178 my @SignalNames; # The signal name.
179 my @SignalReturns; # The return type.
180 my @SignalFlags; # Flags for the signal
181 my @SignalPrototypes; # The rest of the prototype of the signal handler.
183 # These global arrays store information on Args. Each Arg has an entry
184 # in each of these arrays at the same index, like a multi-dimensional array.
185 my @ArgObjects; # The GtkObject which has the Arg.
186 my @ArgNames; # The Arg name.
187 my @ArgTypes; # The Arg type - gint, GtkArrowType etc.
188 my @ArgFlags; # How the Arg can be used - readable/writable etc.
189 my @ArgNicks; # The nickname of the Arg.
190 my @ArgBlurbs; # Docstring of the Arg.
191 my @ArgDefaults; # Default value of the Arg.
192 my @ArgRanges; # The range of the Arg type
193 # These global hashes store declaration info keyed on a symbol name.
195 my %DeclarationTypes;
196 my %DeclarationConditional;
197 my %DeclarationOutput;
201 my %StructHasTypedef;
203 # These global hashes store the existing documentation.
208 # These global hashes store documentation scanned from the source files.
209 my %SourceSymbolDocs;
210 my %SourceSymbolParams;
212 # all documentation goes in here, so we can do coverage analysis
214 my %AllIncompleteSymbols;
215 my %AllDocumentedSymbols;
217 # Undeclared yet documented symbols
218 my %UndeclaredSymbols;
220 # These global arrays store GtkObject and subclasses and the hierarchy.
227 # holds the symbols which are mentioned in $MODULE-sections.txt
230 # Standard C preprocessor directives, which we ignore for '#' abbreviations.
231 my %PreProcessorDirectives;
232 $PreProcessorDirectives{"assert"} = 1;
233 $PreProcessorDirectives{"define"} = 1;
234 $PreProcessorDirectives{"elif"} = 1;
235 $PreProcessorDirectives{"else"} = 1;
236 $PreProcessorDirectives{"endif"} = 1;
237 $PreProcessorDirectives{"error"} = 1;
238 $PreProcessorDirectives{"if"} = 1;
239 $PreProcessorDirectives{"ifdef"} = 1;
240 $PreProcessorDirectives{"ifndef"} = 1;
241 $PreProcessorDirectives{"include"} = 1;
242 $PreProcessorDirectives{"line"} = 1;
243 $PreProcessorDirectives{"pragma"} = 1;
244 $PreProcessorDirectives{"unassert"} = 1;
245 $PreProcessorDirectives{"undef"} = 1;
246 $PreProcessorDirectives{"warning"} = 1;
248 # Create the root DocBook output directory if it doens't exist.
249 if (! -e $SGML_OUTPUT_DIR) {
250 mkdir ("$SGML_OUTPUT_DIR", 0777)
251 || die "Can't create directory: $SGML_OUTPUT_DIR";
254 # Function and other declaration output settings.
255 my $RETURN_TYPE_FIELD_WIDTH = 20;
256 my $SYMBOL_FIELD_WIDTH = 36;
257 my $SIGNAL_FIELD_WIDTH = 16;
259 &ReadKnownSymbols ("$ROOT_DIR/$MODULE-sections.txt");
260 &ReadSignalsFile ($SIGNALS_FILE);
261 &ReadArgsFile ($ARGS_FILE);
262 &ReadObjectHierarchy;
266 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-decl.txt", 0);
267 if (-f "$ROOT_DIR/$MODULE-overrides.txt") {
268 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-overrides.txt", 1);
271 for my $dir (@SOURCE_DIRS) {
272 &ReadSourceDocumentation ($dir);
275 my $changed = &OutputSGML ("$ROOT_DIR/$MODULE-sections.txt");
277 # If any of the DocBook SGML files have changed, update the timestamp file (so
278 # it can be used for Makefile dependencies).
279 if ($changed || ! -e "$ROOT_DIR/sgml.stamp") {
280 open (TIMESTAMP, ">$ROOT_DIR/sgml.stamp")
281 || die "Can't create $ROOT_DIR/sgml.stamp";
282 print (TIMESTAMP "timestamp");
286 #############################################################################
287 # Function : OutputObjectList
288 # Description : This outputs the alphabetical list of objects, in a columned
289 # table. FIXME: Currently this also outputs ancestor objects
290 # which may not actually be in this module.
292 #############################################################################
294 sub OutputObjectList {
296 my $old_object_index = "$SGML_OUTPUT_DIR/object_index.sgml";
297 my $new_object_index = "$SGML_OUTPUT_DIR/object_index.new";
299 open (OUTPUT, ">$new_object_index")
300 || die "Can't create $new_object_index";
301 print (OUTPUT <<EOF);
302 <informaltable pgwide="1" frame="none">
303 <tgroup cols="$cols">
304 <colspec colwidth="1*"${empty_element_end}
305 <colspec colwidth="1*"${empty_element_end}
306 <colspec colwidth="1*"${empty_element_end}
312 foreach $object (sort(@Objects)) {
313 my $xref = &MakeXRef ($object);
314 if ($count % $cols == 0) { print (OUTPUT "<row>\n"); }
315 print (OUTPUT "<entry>$xref</entry>\n");
316 if ($count % $cols == ($cols - 1)) { print (OUTPUT "</row>\n"); }
320 # emit an empty row, since empty tables are invalid
321 print (OUTPUT "<row><entry> </entry></row>\n");
324 print (OUTPUT <<EOF);
325 </tbody></tgroup></informaltable>
329 &UpdateFileIfChanged ($old_object_index, $new_object_index, 0);
333 #############################################################################
334 # Function : OutputSGML
335 # Description : This collects the output for each section of the docs, and
336 # outputs each file when the end of the section is found.
337 # Arguments : $file - the $MODULE-sections.txt file which contains all of
338 # the functions/macros/structs etc. being documented, organised
339 # into sections and subsections.
340 #############################################################################
345 # print "Reading: $file\n";
347 || die "Can't open $file";
349 my $book_bottom = "";
350 my $includes = (defined $DEFAULT_INCLUDES) ? $DEFAULT_INCLUDES : "";
351 my $section_includes = "";
359 my $signals_synop = "";
360 my $signals_desc = "";
362 my $child_args_synop = "";
363 my $style_args_synop = "";
365 my $child_args_desc = "";
366 my $style_args_desc = "";
369 my $implementations = "";
370 my $prerequisites = "";
372 my @file_objects = ();
378 } elsif (m/^<SECTION>/) {
385 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
389 } elsif (m/^<SUBSECTION>/) {
391 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
393 # print "Section: $title\n";
395 # We don't want warnings if object & class structs aren't used.
396 $DeclarationOutput{$title} = 1;
397 $DeclarationOutput{"${title}Class"} = 1;
399 } elsif (m/^<FILE>(.*)<\/FILE>/) {
406 &ReadTemplateFile ("$TMPL_DIR/$file", 1);
407 &MergeSourceDocumentation;
409 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
411 $section_includes = $1;
413 if (defined $DEFAULT_INCLUDES) {
415 WARNING: Default <INCLUDE> being overridden by command line option
423 } elsif (m/^<\/SECTION>/) {
427 # print "End of section: $title\n";
431 my $section_id = $SourceSymbolDocs{"$TMPL_DIR/$file:Section_Id"};
432 if (defined ($section_id) && $section_id !~ m/^\s*$/) {
433 # Do nothing. Use section_id as it is.
434 } elsif (&CheckIsObject ($title)) {
435 # GtkObjects use their class name as the ID.
436 $section_id = &CreateValidSGMLID ($title);
438 $section_id = &CreateValidSGMLID ("$MODULE-$title");
441 if ($num_symbols > 0) {
442 if (lc($OUTPUT_FORMAT) eq "xml") {
443 $book_bottom .= " <xi:include href=\"xml/$file.xml\"/>\n";
445 $book_top.="<!ENTITY $section_id SYSTEM \"sgml/$file.sgml\">\n";
446 $book_bottom .= " &$section_id;\n";
449 if (defined ($SourceSymbolDocs{"$TMPL_DIR/$file:Include"})) {
450 if ($section_includes) {
452 WARNING: Section <INCLUDE> for file $file being overridden by inline comments
455 $section_includes = $SourceSymbolDocs{"$TMPL_DIR/$file:Include"};
457 if ($section_includes eq "") {
458 $section_includes = $includes;
461 if ($signals_synop ne '') {
462 $signals_synop = <<EOF;
463 <refsect1 role="signal_proto">
464 <title role="signal_proto.title">Signals</title>
467 ${signals_synop}</synopsis>
470 $signals_desc = <<EOF;
471 <refsect1 role="signals">
472 <title role="signals.title">Signal Details</title>
478 if ($args_synop ne '') {
480 <refsect1 role="properties">
481 <title role="properties.title">Properties</title>
484 ${args_synop}</synopsis>
488 <refsect1 role="property_details">
489 <title role="property_details.title">Property Details</title>
495 if ($child_args_synop ne '') {
496 $args_synop .= <<EOF;
497 <refsect1 role="child_properties">
498 <title role="child_properties.title">Child Properties</title>
501 ${child_args_synop}</synopsis>
505 <refsect1 role="child_property_details">
506 <title role="child_property_details.title">Child Property Details</title>
512 if ($style_args_synop ne '') {
513 $args_synop .= <<EOF;
514 <refsect1 role="style_properties">
515 <title role="style_properties.title">Style Properties</title>
518 ${style_args_synop}</synopsis>
522 <refsect1 role="style_properties_details">
523 <title role="style_properties_details.title">Style Property Details</title>
529 if ($hierarchy ne "") {
531 <refsect1 role="object_hierarchy">
532 <title role="object_hierarchy.title">Object Hierarchy</title>
538 if ($interfaces ne "") {
540 <refsect1 role="impl_interfaces">
541 <title role="impl_interfaces.title">Implemented Interfaces</title>
547 if ($implementations ne "") {
548 $implementations = <<EOF;
549 <refsect1 role="implementations">
550 <title role="implementations.title">Known Implementations</title>
556 if ($prerequisites ne "") {
557 $prerequisites = <<EOF;
558 <refsect1 role="prerequisites">
559 <title role="prerequisites.title">Prerequisites</title>
565 if ($derived ne "") {
567 <refsect1 role="derived_interfaces">
568 <title role="derived_interfaces.title">Known Derived Interfaces</title>
574 my $file_changed = &OutputSGMLFile ($file, $title, $section_id,
576 \$synopsis, \$details,
577 \$signals_synop, \$signals_desc,
578 \$args_synop, \$args_desc,
579 \$hierarchy, \$interfaces,
581 \$prerequisites, \$derived,
590 $section_includes = "";
594 $child_args_synop = "";
595 $style_args_synop = "";
597 $child_args_desc = "";
598 $style_args_desc = "";
601 $implementations = "";
605 } elsif (m/^(\S+)/) {
607 # print " Symbol: $symbol\n";
609 my $declaration = $Declarations{$symbol};
610 if (defined ($declaration)) {
611 # We don't want standard macros/functions of GtkObjects,
612 # or private declarations.
613 if ($subsection ne "Standard" && $subsection ne "Private") {
614 if (&CheckIsObject ($symbol)) {
615 push @file_objects, $symbol;
617 my ($synop, $desc) = &OutputDeclaration ($symbol,
619 my ($sig_synop, $sig_desc) = &GetSignals ($symbol);
620 my ($arg_synop, $child_arg_synop, $style_arg_synop,
621 $arg_desc, $child_arg_desc, $style_arg_desc) = &GetArgs ($symbol);
622 my $hier = &GetHierarchy ($symbol);
623 my $ifaces = &GetInterfaces ($symbol);
624 my $impls = &GetImplementations ($symbol);
625 my $prereqs = &GetPrerequisites ($symbol);
626 my $der = &GetDerived ($symbol);
629 $signals_synop .= $sig_synop;
630 $signals_desc .= $sig_desc;
631 $args_synop .= $arg_synop;
632 $child_args_synop .= $child_arg_synop;
633 $style_args_synop .= $style_arg_synop;
634 $args_desc .= $arg_desc;
635 $child_args_desc .= $child_arg_desc;
636 $style_args_desc .= $style_arg_desc;
638 $interfaces .= $ifaces;
639 $implementations .= $impls;
640 $prerequisites .= $prereqs;
644 # Note that the declaration has been output.
645 $DeclarationOutput{$symbol} = 1;
646 } elsif ($subsection ne "Standard" && $subsection ne "Private") {
647 $UndeclaredSymbols{$symbol} = 1;
648 print "WARNING: No declaration found for: $symbol\n";
655 &OutputMissingDocumentation;
656 &OutputUndeclaredSymbols;
658 if ($OUTPUT_ALL_SYMBOLS) {
662 for $file (split (' ', $EXPAND_CONTENT_FILES)) {
663 my $file_changed = &OutputExtraFile ($file);
669 &OutputBook ($book_top, $book_bottom);
675 #############################################################################
676 # Function : ReadKnownSymbols
677 # Description : This collects the names of non-private symbols from the
678 # $MODULE-sections.txt file.
679 # Arguments : $file - the $MODULE-sections.txt file which contains all of
680 # the functions/macros/structs etc. being documented, organised
681 # into sections and subsections.
682 #############################################################################
684 sub ReadKnownSymbols {
689 # print "Reading: $file\n";
691 || die "Can't open $file";
697 } elsif (m/^<SECTION>/) {
700 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
703 } elsif (m/^<SUBSECTION>/) {
706 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
709 } elsif (m/^<FILE>(.*)<\/FILE>/) {
712 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
715 } elsif (m/^<\/SECTION>/) {
718 } elsif (m/^(\S+)/) {
721 if ($subsection ne "Standard" && $subsection ne "Private") {
722 $KnownSymbols{$symbol} = 1;
725 $KnownSymbols{$symbol} = 0;
733 #############################################################################
734 # Function : OutputDeclaration
735 # Description : Returns the synopsis and detailed description DocBook
736 # describing one function/macro etc.
737 # Arguments : $symbol - the name of the function/macro begin described.
738 # $declaration - the declaration of the function/macro.
739 #############################################################################
741 sub OutputDeclaration {
742 my ($symbol, $declaration) = @_;
744 my $type = $DeclarationTypes {$symbol};
745 if ($type eq 'MACRO') {
746 return &OutputMacro ($symbol, $declaration);
747 } elsif ($type eq 'TYPEDEF') {
748 return &OutputTypedef ($symbol, $declaration);
749 } elsif ($type eq 'STRUCT') {
750 return &OutputStruct ($symbol, $declaration);
751 } elsif ($type eq 'ENUM') {
752 return &OutputEnum ($symbol, $declaration);
753 } elsif ($type eq 'UNION') {
754 return &OutputUnion ($symbol, $declaration);
755 } elsif ($type eq 'VARIABLE') {
756 return &OutputVariable ($symbol, $declaration);
758 } elsif ($type eq 'FUNCTION') {
759 return &OutputFunction ($symbol, $declaration, $type);
760 } elsif ($type eq 'USER_FUNCTION') {
761 return &OutputFunction ($symbol, $declaration, $type);
763 die "Unknown symbol type";
768 #############################################################################
769 # Function : OutputSymbolTraits
770 # Description : Returns the Since and StabilityLevel paragraphs for a symbol.
771 # Arguments : $symbol - the name of the function/macro begin described.
772 #############################################################################
774 sub OutputSymbolTraits {
778 if (exists $Since{$symbol}) {
779 $desc .= "<para role=\"since\">Since $Since{$symbol}</para>";
781 if (exists $StabilityLevel{$symbol}) {
782 $desc .= "<para role=\"stability\">Stability Level: $StabilityLevel{$symbol}</para>";
788 #############################################################################
789 # Function : OutputMacro
790 # Description : Returns the synopsis and detailed description of a macro.
791 # Arguments : $symbol - the macro.
792 # $declaration - the declaration of the macro.
793 #############################################################################
796 my ($symbol, $declaration) = @_;
797 my $id = &CreateValidSGMLID ($symbol);
798 my $condition = &MakeConditionDescription ($symbol);
799 my $synop = &MakeReturnField("#define") . "<link linkend=\"$id\">$symbol</link>";
805 if ($declaration =~ m/^\s*#\s*define(\s+)\w+(\([^\)]*\))/) {
809 if (length ($symbol) < $SYMBOL_FIELD_WIDTH) {
810 $synop .= (' ' x ($SYMBOL_FIELD_WIDTH - length ($symbol)));
813 # Try to align all the lines of args correctly.
814 $pad = ' ' x ($RETURN_TYPE_FIELD_WIDTH + $SYMBOL_FIELD_WIDTH + 1);
815 my $args_padded = $args;
816 $args_padded =~ s/ *\\\n */\n$pad/gm;
817 $synop .= &CreateValidSGML ($args_padded);
822 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"macro\"${condition}${empty_element_end}${symbol}()</title>\n";
824 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"macro\"${condition}${empty_element_end}$symbol</title>\n";
826 $desc .= MakeIndexterms($symbol);
828 # Don't output the macro definition if is is a conditional macro or it
829 # looks like a function, i.e. starts with "g_" or "_?gnome_", or it is
830 # longer than 2 lines, otherwise we get lots of complicated macros like
832 if (!defined ($DeclarationConditional{$symbol}) && ($symbol !~ m/^g_/)
833 && ($symbol !~ m/^_?gnome_/) && (($declaration =~ tr/\n//) < 2)) {
834 $declaration = &CreateValidSGML ($declaration);
835 $desc .= "<programlisting>$declaration</programlisting>\n";
837 $desc .= "<programlisting>" . &MakeReturnField("#define") . "$symbol";
838 # Align each line so that if should all line up OK.
839 $pad = ' ' x ($RETURN_TYPE_FIELD_WIDTH - length ("#define "));
840 $args =~ s/\n/\n$pad/gm;
841 $desc .= &CreateValidSGML ($args);
842 $desc .= "</programlisting>\n";
845 $desc .= &MakeDeprecationNote($symbol);
847 my $parameters = &OutputParamDescriptions ("MACRO", $symbol);
848 my $parameters_output = 0;
850 if (defined ($SymbolDocs{$symbol})) {
851 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
853 # Try to insert the parameter table at the author's desired position.
854 # Otherwise we need to tag it onto the end.
855 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
856 $parameters_output = 1;
858 $desc .= $symbol_docs;
861 if ($parameters_output == 0) {
862 $desc .= $parameters;
865 $desc .= OutputSymbolTraits ($symbol);
866 $desc .= "</refsect2>\n";
867 return ($synop, $desc);
871 #############################################################################
872 # Function : OutputTypedef
873 # Description : Returns the synopsis and detailed description of a typedef.
874 # Arguments : $symbol - the typedef.
875 # $declaration - the declaration of the typedef,
876 # e.g. 'typedef unsigned int guint;'
877 #############################################################################
880 my ($symbol, $declaration) = @_;
881 my $id = &CreateValidSGMLID ($symbol);
882 my $condition = &MakeConditionDescription ($symbol);
883 my $synop = &MakeReturnField("typedef") . "<link linkend=\"$id\">$symbol</link>;\n";
884 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"typedef\"${condition}${empty_element_end}$symbol</title>\n";
886 $desc .= MakeIndexterms($symbol);
888 if (!defined ($DeclarationConditional{$symbol})) {
889 $declaration = &CreateValidSGML ($declaration);
890 $desc .= "<programlisting>$declaration</programlisting>\n";
893 $desc .= &MakeDeprecationNote($symbol);
895 if (defined ($SymbolDocs{$symbol})) {
896 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
898 $desc .= OutputSymbolTraits ($symbol);
899 $desc .= "</refsect2>\n";
900 return ($synop, $desc);
904 #############################################################################
905 # Function : OutputStruct
906 # Description : Returns the synopsis and detailed description of a struct.
907 # We check if it is a widget struct, and if so we only output
908 # parts of it that are noted as public fields.
909 # We also use a different SGML ID for widget structs, since the
910 # original ID is used for the entire RefEntry.
911 # Arguments : $symbol - the struct.
912 # $declaration - the declaration of the struct.
913 #############################################################################
916 my ($symbol, $declaration) = @_;
918 my $is_widget_struct = 0;
919 my $default_to_public = 1;
920 if (&CheckIsObject ($symbol)) {
921 # print "Found widget struct: $symbol\n";
922 $is_widget_struct = 1;
923 $default_to_public = 0;
928 if ($is_widget_struct) {
929 $id = &CreateValidSGMLID ($symbol . "_struct");
930 $condition = &MakeConditionDescription ($symbol . "_struct");
932 $id = &CreateValidSGMLID ($symbol);
933 $condition = &MakeConditionDescription ($symbol);
936 # Determine if it is a simple struct or it also has a typedef.
938 if ($StructHasTypedef{$symbol} || $declaration =~ m/^\s*typedef\s+/) {
945 # For structs with typedefs we just output the struct name.
946 $synop = &MakeReturnField("") . "<link linkend=\"$id\">$symbol</link>;\n";
947 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"struct\"${condition}${empty_element_end}$symbol</title>\n";
949 $synop = &MakeReturnField("struct") . "<link linkend=\"$id\">$symbol</link>;\n";
950 $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"struct\"${condition}${empty_element_end}struct $symbol</title>\n";
953 $desc .= MakeIndexterms($symbol);
955 # Form a pretty-printed, private-data-removed form of the declaration
958 if ($declaration =~ m/^\s*$/) {
959 # print "Found opaque struct: $symbol\n";
960 $decl_out = "typedef struct _$symbol $symbol;";
961 } elsif ($declaration =~ m/^\s*struct\s+\w+\s*;\s*$/) {
962 # print "Found opaque struct: $symbol\n";
963 $decl_out = "struct $symbol;";
965 my $public = $default_to_public;
966 my $new_declaration = "";
968 my $decl = $declaration;
970 if ($decl =~ m/^\s*(typedef\s+)?struct\s*\w*\s*(?:\/\*.*\*\/)?\s*{(.*)}\s*\w*\s*;\s*$/s) {
971 my $struct_contents = $2;
973 foreach $decl_line (split (/\n/, $struct_contents)) {
974 # print "Struct line: $decl_line\n";
975 if ($decl_line =~ m%/\*\s*<\s*public\s*>\s*\*/%) {
977 } elsif ($decl_line =~ m%/\*\s*<\s*(private|protected)\s*>\s*\*/%) {
980 $new_declaration .= $decl_line . "\n";
984 if ($new_declaration) {
985 # Strip any blank lines off the ends.
986 $new_declaration =~ s/^\s*\n//;
987 $new_declaration =~ s/\n\s*$/\n/;
990 $decl_out = "typedef struct {\n" . $new_declaration
993 $decl_out = "struct $symbol {\n" . $new_declaration
998 print "WARNING: Couldn't parse struct:\n$declaration\n";
1001 # If we couldn't parse the struct or it was all private, output an
1002 # empty struct declaration.
1003 if ($decl_out eq "") {
1005 $decl_out = "typedef struct _$symbol $symbol;";
1007 $decl_out = "struct $symbol;";
1012 $decl_out = &CreateValidSGML ($decl_out);
1013 $desc .= "<programlisting>$decl_out</programlisting>\n";
1015 $desc .= &MakeDeprecationNote($symbol);
1017 if (defined ($SymbolDocs{$symbol})) {
1018 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1021 # Create a table of fields and descriptions
1023 # FIXME: Inserting  's into the produced type declarations here would
1024 # improve the output in most situations ... except for function
1025 # members of structs!
1026 my @fields = ParseStructDeclaration($declaration, !$default_to_public,
1029 "<structfield>$_[0]</structfield>";
1031 my $params = $SymbolParams{$symbol};
1033 # If no parameters are filled in, we don't generate the description
1034 # table, for backwards compatibility
1037 if (defined $params) {
1038 for (my $i = 1; $i <= $#$params; $i += 2) {
1039 if ($params->[$i] =~ /\S/) {
1047 my %field_descrs = @$params;
1050 <variablelist role="struct">
1053 my $field_name = shift @fields;
1054 my $text = shift @fields;
1055 my $field_descr = $field_descrs{$field_name};
1057 $desc .= "<varlistentry>\n<term>$text</term>\n";
1058 if (defined $field_descr) {
1059 $desc .= "<listitem><simpara>".&ExpandAbbreviations($symbol, $field_descr)."</simpara></listitem>\n";
1061 $desc .= "<listitem></listitem>\n";
1063 $desc .= "</varlistentry>\n";
1066 $desc .= "</variablelist>";
1068 $desc .= OutputSymbolTraits ($symbol);
1069 $desc .= "</refsect2>\n";
1070 return ($synop, $desc);
1074 #############################################################################
1075 # Function : OutputEnum
1076 # Description : Returns the synopsis and detailed description of a enum.
1077 # Arguments : $symbol - the enum.
1078 # $declaration - the declaration of the enum.
1079 #############################################################################
1082 my ($symbol, $declaration) = @_;
1083 my $id = &CreateValidSGMLID ($symbol);
1084 my $condition = &MakeConditionDescription ($symbol);
1085 my $synop = &MakeReturnField("enum") . "<link linkend=\"$id\">$symbol</link>;\n";
1086 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"enum\"${condition}${empty_element_end}enum $symbol</title>\n";
1088 $desc .= MakeIndexterms($symbol);
1090 $declaration = &CreateValidSGML ($declaration);
1091 $desc .= "<programlisting>$declaration</programlisting>\n";
1093 $desc .= &MakeDeprecationNote($symbol);
1095 if (defined ($SymbolDocs{$symbol})) {
1096 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1099 # Create a table of fields and descriptions
1101 my @members = ParseEnumDeclaration($declaration);
1102 my $params = $SymbolParams{$symbol};
1104 # If no parameters are filled in, we don't generate the description
1105 # table, for backwards compatibility
1108 if (defined $params) {
1109 for (my $i = 1; $i <= $#$params; $i += 2) {
1110 if ($params->[$i] =~ /\S/) {
1118 my %member_descrs = @$params;
1121 <variablelist role="enum">
1123 for my $member_name (@members) {
1124 my $member_descr = $member_descrs{$member_name};
1126 $id = &CreateValidSGMLID ($member_name);
1127 $condition = &MakeConditionDescription ($member_name);
1128 $desc .= "<varlistentry>\n<term><anchor id=\"$id\" role=\"constant\"${condition}${empty_element_end}<literal>$member_name</literal></term>\n";
1129 if (defined $member_descr) {
1130 $desc .= "<listitem><simpara>".&ExpandAbbreviations($symbol, $member_descr)."</simpara></listitem>\n";
1132 $desc .= "<listitem></listitem>\n";
1134 $desc .= "</varlistentry>\n";
1137 $desc .= "</variablelist>";
1140 $desc .= OutputSymbolTraits ($symbol);
1141 $desc .= "</refsect2>\n";
1142 return ($synop, $desc);
1146 #############################################################################
1147 # Function : OutputUnion
1148 # Description : Returns the synopsis and detailed description of a union.
1149 # Arguments : $symbol - the union.
1150 # $declaration - the declaration of the union.
1151 #############################################################################
1154 my ($symbol, $declaration) = @_;
1155 my $id = &CreateValidSGMLID ($symbol);
1156 my $condition = &MakeConditionDescription ($symbol);
1157 my $synop = &MakeReturnField("union") . "<link linkend=\"$id\">$symbol</link>;\n";
1158 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"union\"${condition}${empty_element_end}union $symbol</title>\n";
1160 $desc .= MakeIndexterms($symbol);
1162 $declaration = &CreateValidSGML ($declaration);
1163 $desc .= "<programlisting>$declaration</programlisting>\n";
1165 $desc .= &MakeDeprecationNote($symbol);
1167 if (defined ($SymbolDocs{$symbol})) {
1168 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1170 $desc .= OutputSymbolTraits ($symbol);
1171 $desc .= "</refsect2>\n";
1172 return ($synop, $desc);
1176 #############################################################################
1177 # Function : OutputVariable
1178 # Description : Returns the synopsis and detailed description of a variable.
1179 # Arguments : $symbol - the extern'ed variable.
1180 # $declaration - the declaration of the variable.
1181 #############################################################################
1183 sub OutputVariable {
1184 my ($symbol, $declaration) = @_;
1185 my $id = &CreateValidSGMLID ($symbol);
1186 my $condition = &MakeConditionDescription ($symbol);
1189 if ($declaration =~ m/^\s*extern\s+((const\s+|unsigned\s+)*\w+)(\s+\*+|\*+|\s)(\s*)([A-Za-z]\w*)\s*;/) {
1190 my $mod = defined ($1) ? $1 : "";
1191 my $ptr = defined ($3) ? $3 : "";
1192 my $space = defined ($4) ? $4 : "";
1193 $synop = &MakeReturnField("extern") . "$mod$ptr$space<link linkend=\"$id\">$symbol</link>;\n";
1196 $synop = &MakeReturnField("extern") . "<link linkend=\"$id\">$symbol</link>;\n";
1199 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"variable\"${condition}${empty_element_end}$symbol</title>\n";
1201 $desc .= MakeIndexterms($symbol);
1203 $declaration = &CreateValidSGML ($declaration);
1204 $desc .= "<programlisting>$declaration</programlisting>\n";
1206 $desc .= &MakeDeprecationNote($symbol);
1208 if (defined ($SymbolDocs{$symbol})) {
1209 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1211 $desc .= OutputSymbolTraits ($symbol);
1212 $desc .= "</refsect2>\n";
1213 return ($synop, $desc);
1217 #############################################################################
1218 # Function : OutputFunction
1219 # Description : Returns the synopsis and detailed description of a function.
1220 # Arguments : $symbol - the function.
1221 # $declaration - the declaration of the function.
1222 #############################################################################
1224 sub OutputFunction {
1225 my ($symbol, $declaration, $symbol_type) = @_;
1226 my $id = &CreateValidSGMLID ($symbol);
1227 my $condition = &MakeConditionDescription ($symbol);
1229 # Take out the return type
1230 $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//;
1231 my $type_modifier = defined($1) ? $1 : "";
1234 # print "$symbol pointer is $pointer\n";
1235 my $xref = &MakeXRef ($type);
1237 if ($symbol_type eq 'USER_FUNCTION') {
1238 # $start = "typedef ";
1241 # We output const rather than G_CONST_RETURN.
1242 $type_modifier =~ s/G_CONST_RETURN/const/g;
1243 $pointer =~ s/G_CONST_RETURN/const/g;
1245 my $ret_type_len = length ($start) + length ($type_modifier)
1246 + length ($pointer) + length ($type);
1247 my $ret_type_output;
1249 if ($ret_type_len < $RETURN_TYPE_FIELD_WIDTH) {
1250 $ret_type_output = "$start$type_modifier$xref$pointer"
1251 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
1254 # $ret_type_output = "$start$type_modifier$xref$pointer\n"
1255 # . (' ' x $RETURN_TYPE_FIELD_WIDTH);
1257 $ret_type_output = "$start$type_modifier$xref$pointer ";
1258 $symbol_len = $ret_type_len + 1 - $RETURN_TYPE_FIELD_WIDTH;
1261 $symbol_len += length ($symbol);
1262 my $char1 = my $char2 = my $char3 = "";
1263 if ($symbol_type eq 'USER_FUNCTION') {
1270 my ($symbol_output, $symbol_desc_output);
1271 if ($symbol_len < $SYMBOL_FIELD_WIDTH) {
1272 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3"
1273 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1274 $symbol_desc_output = "$char1$char2$symbol$char3"
1275 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1277 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3\n"
1278 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1279 $symbol_desc_output = "$char1$char2$symbol$char3\n"
1280 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1283 my $synop = $ret_type_output . $symbol_output . '(';
1284 my $desc = "<refsect2>\n<title><anchor id=\"$id\" role=\"function\"${condition}${empty_element_end}${symbol} ()</title>\n";
1286 $desc .= MakeIndexterms($symbol);
1288 $desc .= "<programlisting>${ret_type_output}$symbol_desc_output(";
1291 while ($declaration ne "") {
1292 #print "$declaration";
1294 if ($declaration =~ s/^[\s,]+//) {
1295 # skip whitespace and commas
1298 } elsif ($declaration =~ s/^void\s*[,\n]//) {
1302 } elsif ($declaration =~ s/^...\s*[,\n]//) {
1303 if ($param_num == 0) {
1308 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1311 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1315 # allow alphanumerics, '_', '[' & ']' in param names
1316 # Try to match a standard parameter (keep in sync with gtkdoc-mktmpl)
1318 } elsif ($declaration =~ s/^\s*((?:G_CONST_RETURN|G_GNUC_UNUSED|unsigned long|unsigned short|signed long|signed short|unsigned|signed|long|short|volatile|const)\s+)*((?:struct\b|enum\b)?\s*\w+)\s*((?:(?:const\b|restrict\b)?\s*\*?\s*(?:const\b|restrict\b)?\s*)*)(\w+)?\s*((?:\[\S*\])*)\s*[,\n]//) {
1319 my $pre = defined($1) ? $1 : "";
1321 my $ptr = defined($3) ? $3 : "";
1322 my $name = defined($4) ? $4 : "";
1323 my $array = defined($5) ? $5 : "";
1329 if ($ptr && $ptr !~ m/\*$/) { $ptr .= " "; }
1331 #print "$symbol: '$pre' '$type' '$ptr' '$name' '$array'\n";
1333 if (($name eq "") && $pre =~ m/^((un)?signed .*)\s?/ ) {
1339 my $xref = &MakeXRef ($type);
1340 my $label = "$pre$xref $ptr$name$array";
1342 #print "$symbol: '$pre' '$type' '$ptr' '$name' '$array'\n";
1344 if ($param_num == 0) {
1349 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1352 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1356 # Try to match parameters which are functions (keep in sync with gtkdoc-mktmpl)
1357 # $1 $2 $3 $4 $5 $7 $8
1358 } 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]//) {
1359 my $mod1 = defined($1) ? $1 : "";
1360 if (defined($2)) { $mod1 .= $2; }
1363 my $mod2 = defined($5) ? $5 : "";
1366 my $func_params = $8;
1368 if ($ptr1 && $ptr1 !~ m/\*$/) { $ptr1 .= " "; }
1369 $func_ptr =~ s/\s+//g;
1370 my $xref = &MakeXRef ($type);
1371 my $label = "$mod1$xref$ptr1$mod2 ($func_ptr$name) ($func_params)";
1373 #print "Type: $mod1$type$ptr1$mod2($func_ptr$name)($func_params)\n";
1374 if ($param_num == 0) {
1379 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1382 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1387 print "###Can't parse args for function $symbol: $declaration\n";
1393 $desc .= ");</programlisting>\n";
1395 $desc .= &MakeDeprecationNote($symbol);
1397 my $parameters = &OutputParamDescriptions ("FUNCTION", $symbol);
1398 my $parameters_output = 0;
1400 if (defined ($SymbolDocs{$symbol})) {
1401 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1403 # Try to insert the parameter table at the author's desired position.
1404 # Otherwise we need to tag it onto the end.
1405 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
1406 $parameters_output = 1;
1408 $desc .= $symbol_docs;
1411 if ($parameters_output == 0) {
1412 $desc .= $parameters;
1415 $desc .= OutputSymbolTraits ($symbol);
1416 $desc .= "</refsect2>\n";
1417 return ($synop, $desc);
1421 #############################################################################
1422 # Function : OutputParamDescriptions
1423 # Description : Returns the DocBook output describing the parameters of a
1424 # function, macro or signal handler.
1425 # Arguments : $symbol_type - 'FUNCTION', 'MACRO' or 'SIGNAL'. Signal
1426 # handlers have an implicit user_data parameter last.
1427 # $symbol - the name of the function/macro being described.
1428 #############################################################################
1430 sub OutputParamDescriptions {
1431 my ($symbol_type, $symbol) = @_;
1433 if (defined ($SymbolParams{$symbol})) {
1435 my $params = $SymbolParams{$symbol};
1436 my $params_desc = "";
1438 for ($j = 0; $j <= $#$params; $j += 2) {
1439 my $param_name = $$params[$j];
1440 my $param = $$params[$j + 1];
1441 if ($param_name eq "Returns") {
1442 $returns = &ExpandAbbreviations($symbol, $param);
1444 if ($param_name eq "Varargs") {
1445 $param_name = "...";
1447 $param = &ExpandAbbreviations($symbol, $param);
1448 $params_desc .= "<varlistentry><term><parameter>$param_name</parameter> :</term>\n<listitem><simpara>$param</simpara></listitem></varlistentry>\n";
1452 # Signals have an implicit user_data parameter which we describe.
1453 if ($symbol_type eq "SIGNAL") {
1454 $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";
1457 # Start a table if we need one.
1458 if ($params_desc || $returns) {
1460 <variablelist role="params">
1463 if ($params_desc ne "") {
1464 # $output .= "<varlistentry><term>Parameters:</term><listitem></listitem></varlistentry>\n";
1465 $output .= $params_desc;
1468 # Output the returns info last.
1470 $output .= "<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>$returns</simpara></listitem></varlistentry>\n";
1474 $output .= "</variablelist>";
1481 #############################################################################
1482 # Function : ParseStabilityLevel
1483 # Description : Parses a stability level and outputs a warning if it isn't
1485 # Arguments : $stability - the stability text.
1486 # $message - description of where the level is from, to use in
1487 # any error message.
1488 # Returns : The parsed stability level string.
1489 #############################################################################
1491 sub ParseStabilityLevel {
1492 my ($stability, $message) = @_;
1494 $stability =~ s/^\s*//;
1495 $stability =~ s/\s*$//;
1496 if ($stability =~ m/^stable$/i) {
1497 $stability = "Stable";
1498 } elsif ($stability =~ m/^unstable$/i) {
1499 $stability = "Unstable";
1500 } elsif ($stability =~ m/^private$/i) {
1501 $stability = "Private";
1504 WARNING: $message is $stability.
1505 It should be one of these: Stable, Unstable, or Private.
1512 #############################################################################
1513 # Function : OutputSGMLFile
1514 # Description : Outputs the final DocBook file for one section.
1515 # Arguments : $file - the name of the file.
1516 # $title - the title from the $MODULE-sections.txt file, which
1517 # will be overridden by the title in the template file.
1518 # $section_id - the SGML id to use for the toplevel tag.
1519 # $includes - comma-separates list of include files added at top
1520 # of synopsis, with '<' '>' around them (if not already enclosed in "").
1521 # $synopsis - reference to the DocBook for the Synopsis part.
1522 # $details - reference to the DocBook for the Details part.
1523 # $signal_synop - reference to the DocBook for the Signal Synopsis part
1524 # $signal_desc - reference to the DocBook for the Signal Description part
1525 # $args_synop - reference to the DocBook for the Arg Synopsis part
1526 # $args_desc - reference to the DocBook for the Arg Description part
1527 # $hierarchy - reference to the DocBook for the Object Hierarchy part
1528 # $interfaces - reference to the DocBook for the Interfaces part
1529 # $implementations - reference to the DocBook for the Known Implementations part
1530 # $prerequisites - reference to the DocBook for the Prerequisites part
1531 # $derived - reference to the DocBook for the Derived Interfaces part
1532 # $file_objects - reference to an array of objects in this file
1533 #############################################################################
1535 sub OutputSGMLFile {
1536 my ($file, $title, $section_id, $includes, $synopsis, $details, $signals_synop, $signals_desc, $args_synop, $args_desc, $hierarchy, $interfaces, $implementations, $prerequisites, $derived, $file_objects) = @_;
1538 # The edited title overrides the one from the sections file.
1539 my $new_title = $SymbolDocs{"$TMPL_DIR/$file:Title"};
1540 if (defined ($new_title) && $new_title !~ m/^\s*$/) {
1541 $title = $new_title;
1542 # print "Found title: $title\n";
1544 my $short_desc = $SymbolDocs{"$TMPL_DIR/$file:Short_Description"};
1545 if (!defined ($short_desc) || $short_desc =~ m/^\s*$/) {
1546 # $short_desc = "one line description goes here.";
1549 $short_desc = &ExpandAbbreviations("$title:Short_description",
1551 # print "Found short_desc: $short_desc";
1553 my $long_desc = $SymbolDocs{"$TMPL_DIR/$file:Long_Description"};
1554 if (!defined ($long_desc) || $long_desc =~ m/^\s*$/) {
1555 $long_desc = "<para>\nA longer description goes here.\n</para>\n";
1557 $long_desc = &ExpandAbbreviations("$title:Long_description",
1559 # print "Found long_desc: $long_desc";
1561 my $see_also = $SymbolDocs{"$TMPL_DIR/$file:See_Also"};
1562 if (!defined ($see_also) || $see_also =~ m%^\s*(<para>)?\s*(</para>)?\s*$%) {
1565 $see_also = &ExpandAbbreviations("$title:See_Also", $see_also);
1566 # print "Found see_also: $see_also";
1569 $see_also = "<refsect1>\n<title>See Also</title>\n$see_also\n</refsect1>\n";
1571 my $stability = $SymbolDocs{"$TMPL_DIR/$file:Stability_Level"};
1572 if (!defined ($stability) || $stability =~ m/^\s*$/) {
1575 $stability = &ParseStabilityLevel($stability, "Section stability level for $file");
1576 # print "Found stability: $stability";
1579 $stability = "<refsect1>\n<title>Stability Level</title>\n$stability, unless otherwise indicated\n</refsect1>\n";
1580 } elsif ($DEFAULT_STABILITY) {
1581 $stability = "<refsect1>\n<title>Stability Level</title>\n$DEFAULT_STABILITY, unless otherwise indicated\n</refsect1>\n";
1584 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
1586 my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
1589 my $include_output = "";
1591 foreach $include (split (/,/, $includes)) {
1592 if ($include =~ m/^\".+\"$/) {
1593 $include_output .= "#include ${include}\n";
1596 $include =~ s/^\s+|\s+$//gs;
1597 $include_output .= "#include <${include}>\n";
1601 my $old_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT";
1602 my $new_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT.new";
1604 open (OUTPUT, ">$new_sgml_file")
1605 || die "Can't create $new_sgml_file";
1607 my $object_anchors = "";
1608 foreach my $object (@$file_objects) {
1609 next if ($object eq $section_id);
1610 my $id = CreateValidSGMLID($object);
1611 # print "Debug: Adding anchor for $object\n";
1612 $object_anchors .= "<anchor id=\"$id\"$empty_element_end";
1615 # We used to output this, but is messes up our UpdateFileIfChanged code
1616 # since it changes every day (and it is only used in the man pages):
1617 # "<refentry id="$section_id" revision="$mday $month $year">"
1619 if (lc($OUTPUT_FORMAT) eq "xml") {
1620 print OUTPUT $doctype_header;
1624 <refentry id="$section_id">
1626 <refentrytitle role="top_of_page">$title</refentrytitle>
1627 <manvolnum>3</manvolnum>
1628 <refmiscinfo>\U$MODULE\E Library</refmiscinfo>
1632 <refname>$title</refname>
1633 <refpurpose>$short_desc</refpurpose>
1634 <!--[<xref linkend="desc" endterm="desc.title"/>]-->
1637 <refsynopsisdiv role="synopsis">
1638 <title role="synopsis.title">Synopsis</title>
1644 $${synopsis}</synopsis>
1655 <refsect1 role="desc">
1656 <title role="desc.title">Description</title>
1660 <refsect1 role="details">
1661 <title role="details.title">Details</title>
1672 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
1676 #############################################################################
1677 # Function : OutputExtraFile
1678 # Description : Copies an "extra" DocBook file into the output directory,
1679 # expanding abbreviations
1680 # Arguments : $file - the source file.
1681 #############################################################################
1682 sub OutputExtraFile {
1687 ($basename = $file) =~ s!^.*/!!;
1689 my $old_sgml_file = "$SGML_OUTPUT_DIR/$basename";
1690 my $new_sgml_file = "$SGML_OUTPUT_DIR/$basename.new";
1694 open(EXTRA_FILE, "<$file") || die "Can't open $file";
1698 $contents = <EXTRA_FILE>;
1701 open (OUTPUT, ">$new_sgml_file")
1702 || die "Can't create $new_sgml_file";
1704 print OUTPUT &ExpandAbbreviations ("$basename file", $contents);
1707 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
1709 #############################################################################
1710 # Function : OutputBook
1711 # Description : Outputs the SGML entities that need to be included into the
1712 # main SGML file for the module.
1713 # Arguments : $book_top - the declarations of the entities, which are added
1714 # at the top of the main SGML file.
1715 # $book_bottom - the references to the entities, which are
1716 # added in the main SGML file at the desired position.
1717 #############################################################################
1720 my ($book_top, $book_bottom) = @_;
1722 my $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top";
1723 my $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top.new";
1725 open (OUTPUT, ">$new_file")
1726 || die "Can't create $new_file";
1727 print OUTPUT $book_top;
1730 &UpdateFileIfChanged ($old_file, $new_file, 0);
1733 $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom";
1734 $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom.new";
1736 open (OUTPUT, ">$new_file")
1737 || die "Can't create $new_file";
1738 print OUTPUT $book_bottom;
1741 &UpdateFileIfChanged ($old_file, $new_file, 0);
1744 # If the main SGML file hasn't been created yet, we create it here.
1745 # The user can tweak it later.
1746 if ($MAIN_SGML_FILE && ! -e $MAIN_SGML_FILE) {
1747 open (OUTPUT, ">$MAIN_SGML_FILE")
1748 || die "Can't create $MAIN_SGML_FILE";
1750 if (lc($OUTPUT_FORMAT) eq "xml") {
1752 <?xml version="1.0"?>
1753 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
1754 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
1755 <book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
1759 <!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
1761 print OUTPUT $book_top;
1770 <title>$MODULE Reference Manual</title>
1772 for $MODULE [VERSION]
1773 The latest version of this documentation can be found on-line at
1774 <ulink role="online-location" url="http://[SERVER]/$MODULE/index.html">http://[SERVER]/$MODULE/</ulink>.
1779 <title>[Insert title here]</title>
1781 print OUTPUT $book_bottom;
1793 #############################################################################
1794 # Function : CreateValidSGMLID
1795 # Description : Creates a valid SGML 'id' from the given string.
1796 # NOTE: SGML ids are case-insensitive, so we have a few special
1797 # cases to avoid clashes of ids.
1798 # Arguments : $id - the string to be converted into a valid SGML id.
1799 #############################################################################
1801 sub CreateValidSGMLID {
1804 # Append ":CAPS" to all all-caps identifiers
1806 # Special case, '_' would end up as '' so we use 'gettext-macro' instead.
1807 if ($id eq "_") { return "gettext-macro"; }
1809 if ($id !~ /[a-z]/) { $id .= ":CAPS" };
1820 #############################################################################
1821 # Function : CreateValidSGML
1822 # Description : This turns any chars which are used in SGML into entities,
1823 # e.g. '<' into '<'
1824 # Arguments : $text - the text to turn into proper SGML.
1825 #############################################################################
1827 sub CreateValidSGML {
1829 $text =~ s/&/&/g; # Do this first, or the others get messed up.
1830 $text =~ s/</</g;
1831 $text =~ s/>/>/g;
1835 #############################################################################
1836 # Function : ConvertSGMLChars
1837 # Description : This is used for text in source code comment blocks, to turn
1838 # chars which are used in SGML into entities, e.g. '<' into
1839 # '<'. Depending on $SGML_MODE, this is done
1840 # unconditionally or only if the character doesn't seem to be
1841 # part of an SGML construct (tag or entity reference).
1842 # Arguments : $text - the text to turn into proper SGML.
1843 #############################################################################
1845 sub ConvertSGMLChars {
1846 my ($symbol, $text) = @_;
1849 # For the SGML mode only convert to entities outside CDATA sections.
1850 return &ModifyXMLElements ($text, $symbol,
1851 "<!\\[CDATA\\[|<programlisting[^>]*>",
1852 \&ConvertSGMLCharsEndTag,
1853 \&ConvertSGMLCharsCallback);
1855 # For the simple non-sgml mode, convert to entities everywhere.
1856 $text =~ s/&/&/g; # Do this first, or the others get messed up.
1857 $text =~ s/</</g;
1858 $text =~ s/>/>/g;
1864 sub ConvertSGMLCharsEndTag {
1865 if ($_[0] eq "<!\[CDATA\[") {
1868 return "</programlisting>";
1872 sub ConvertSGMLCharsCallback {
1873 my ($text, $symbol, $tag) = @_;
1875 if ($tag =~ m/^<programlisting/) {
1876 # We can handle <programlisting> specially here.
1877 return &ModifyXMLElements ($text, $symbol,
1879 \&ConvertSGMLCharsEndTag,
1880 \&ConvertSGMLCharsCallback2);
1881 } elsif ($tag eq "") {
1882 # If we're not in CDATA convert to entities.
1883 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
1884 $text =~ s/<(?![a-zA-Z\/!])/</g;
1885 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
1887 # Handle "#include <xxxxx>"
1888 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
1894 sub ConvertSGMLCharsCallback2 {
1895 my ($text, $symbol, $tag) = @_;
1897 # If we're not in CDATA convert to entities.
1898 # We could handle <programlisting> differently, though I'm not sure it helps.
1900 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
1901 # $text =~ s/&/&/g; # Do this first, or the others get messed up.
1902 $text =~ s/<(?![a-zA-Z\/!])/</g;
1903 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
1905 # Handle "#include <xxxxx>"
1906 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
1913 #############################################################################
1914 # Function : ExpandAbbreviations
1915 # Description : This turns the abbreviations function(), macro(), @param,
1916 # %constant, and #symbol into appropriate DocBook markup.
1917 # CDATA sections and <programlisting> parts are skipped.
1918 # Arguments : $symbol - the symbol being documented, for error messages.
1919 # $text - the text to expand.
1920 #############################################################################
1922 sub ExpandAbbreviations {
1923 my ($symbol, $text) = @_;
1925 # Convert "|[" and "]|" into the start and end of program listing examples.
1926 $text =~ s%\|\[%<informalexample><programlisting>%g;
1927 $text =~ s%\]\|%</programlisting></informalexample>%g;
1929 return &ModifyXMLElements ($text, $symbol,
1930 "<!\\[CDATA\\[|<programlisting[^>]*>",
1931 \&ExpandAbbreviationsEndTag,
1932 \&ExpandAbbreviationsCallback);
1936 # Returns the end tag corresponding to the given start tag.
1937 sub ExpandAbbreviationsEndTag {
1938 if ($_[0] eq "<!\[CDATA\[") {
1941 return "</programlisting>";
1945 # Called inside or outside each CDATA or <programlisting> section.
1946 sub ExpandAbbreviationsCallback {
1947 my ($text, $symbol, $tag) = @_;
1949 if ($tag =~ m/^<programlisting/) {
1950 # Handle any embedded CDATA sections.
1951 return &ModifyXMLElements ($text, $symbol,
1953 \&ExpandAbbreviationsEndTag,
1954 \&ExpandAbbreviationsCallback2);
1955 } elsif ($tag eq "") {
1956 # We are outside any CDATA or <programlisting> sections, so we expand
1957 # any gtk-doc abbreviations.
1959 # Convert 'function()' or 'macro()'
1960 $text =~ s/(\w+)\s*\(\)/&MakeXRef($1, &tagify($1 . "()", "function"));/eg;
1963 $text =~ s/\@(\w+((\.|->)\w+)*)/<parameter>$1<\/parameter>/g;
1965 # Convert '%constant'. Also allow negative numbers, e.g. %-1.
1966 $text =~ s/\%(-?\w+)/&MakeXRef($1, &tagify($1, "literal"));/eg;
1969 $text =~ s/#([\w\-:]+)/&MakeHashXRef($1, "type");/eg;
1975 # This is called inside a <programlisting>
1976 sub ExpandAbbreviationsCallback2 {
1977 my ($text, $symbol, $tag) = @_;
1980 # We are inside a <programlisting> but outside any CDATA sections,
1981 # so we expand any gtk-doc abbreviations.
1982 $text =~ s/#(\w+)/&MakeHashXRef($1, "");/eg;
1989 my ($symbol, $tag) = @_;;
1992 # Check for things like '#include', '#define', and skip them.
1993 if ($PreProcessorDirectives{$symbol}) {
1997 # Get rid of any special '-struct' suffix.
1998 $text =~ s/-struct$//;
2000 # If the symbol is in the form "Object::signal", then change the symbol to
2001 # "Object-signal" and use "signal" as the text.
2002 if ($symbol =~ s/::/-/) {
2006 # If the symbol is in the form "Object:property", then change the symbol to
2007 # "Object--property" and use "property" as the text.
2008 if ($symbol =~ s/:/--/) {
2013 $text = tagify ($text, $tag);
2016 return &MakeXRef($symbol, $text);
2020 #############################################################################
2021 # Function : ModifyXMLElements
2022 # Description : Looks for given XML element tags within the text, and calls
2023 # the callback on pieces of text inside & outside those elements.
2024 # Used for special handling of text inside things like CDATA
2025 # and <programlisting>.
2026 # Arguments : $text - the text.
2027 # $symbol - the symbol currently being documented (only used for
2029 # $start_tag_regexp - the regular expression to match start tags.
2030 # e.g. "<!\\[CDATA\\[|<programlisting[^>]*>" to match
2031 # CDATA sections or programlisting elements.
2032 # $end_tag_func - function which is passed the matched start tag
2033 # and should return the appropriate end tag string.
2034 # $callback - callback called with each part of the text. It is
2035 # called with a piece of text, the symbol being
2036 # documented, and the matched start tag or "" if the text
2037 # is outside the XML elements being matched.
2038 #############################################################################
2039 sub ModifyXMLElements {
2040 my ($text, $symbol, $start_tag_regexp, $end_tag_func, $callback) = @_;
2041 my ($before_tag, $start_tag, $end_tag_regexp, $end_tag);
2044 while ($text =~ m/$start_tag_regexp/s) {
2049 $result .= &$callback ($before_tag, $symbol, "");
2050 $result .= $start_tag;
2052 $end_tag_regexp = &$end_tag_func ($start_tag);
2054 if ($text =~ m/$end_tag_regexp/s) {
2059 $result .= &$callback ($before_tag, $symbol, $start_tag);
2060 $result .= $end_tag;
2062 print "WARNING: Can't find tag end: $end_tag_regexp in docs for: $symbol\n";
2063 # Just assume it is all inside the tag.
2064 $result .= &$callback ($text, $symbol, $start_tag);
2069 # Handle any remaining text outside the tags.
2070 $result .= &$callback ($text, $symbol, "");
2079 # Adds a tag around some text.
2080 # e.g tagify("Text", "literal") => "<literal>Text</literal>".
2082 my ($text, $elem) = @_;
2083 return "<" . $elem . ">" . $text . "</" . $elem . ">";
2087 #############################################################################
2088 # Function : MakeXRef
2089 # Description : This returns a cross-reference link to the given symbol.
2090 # Though it doesn't try to do this for a few standard C types
2091 # that it knows won't be in the documentation.
2092 # Arguments : $symbol - the symbol to try to create a XRef to.
2093 # $text - text text to put inside the XRef, defaults to $symbol
2094 #############################################################################
2097 my ($symbol, $text) = ($_[0], $_[1]);
2098 if (!defined($text)) {
2101 # Get rid of special '-struct' suffix.
2102 $text =~ s/-struct$//;
2105 #print "Getting type link for $symbol -> $text\n";
2107 my $symbol_id = &CreateValidSGMLID ($symbol);
2108 return "<link linkend=\"$symbol_id\">$text</link>";
2112 #############################################################################
2113 # Function : MakeIndexterms
2114 # Description : This returns a indexterm elements for the given symbol
2115 # Arguments : $symbol - the symbol to create indexterms for
2116 #############################################################################
2118 sub MakeIndexterms {
2119 my ($symbol) = $_[0];
2122 if (exists $Deprecated{$symbol}) {
2123 $terms .= "<indexterm role=\"deprecated\"><primary>$symbol</primary></indexterm>"
2125 if (exists $Since{$symbol}) {
2126 my $since = $Since{$symbol};
2130 $terms .= "<indexterm role=\"$since\"><primary>$symbol</primary></indexterm>";
2134 $terms .= "<indexterm><primary>$symbol</primary></indexterm>";
2140 #############################################################################
2141 # Function : MakeDeprecationNote
2142 # Description : This returns a deprecation warning for the given symbol.
2143 # Arguments : $symbol - the symbol to try to create a warning for.
2144 #############################################################################
2146 sub MakeDeprecationNote {
2147 my ($symbol) = $_[0];
2150 if (exists $Deprecated{$symbol}) {
2151 $desc .= "<warning>";
2153 if ($Deprecated{$symbol} =~ /^\s*([0-9\.]+)\s*:/) {
2154 $desc .= "<para><literal>$symbol</literal> has been deprecated since version $1 and should not be used in newly-written code.";
2156 $desc .= "<para><literal>$symbol</literal> is deprecated and should not be used in newly-written code.";
2158 if ($Deprecated{$symbol} ne "") {
2159 $note = &ExpandAbbreviations($symbol, $Deprecated{$symbol});
2160 $note =~ s/^\s*([0-9\.]+)\s*:\s*//;
2163 $note =~ s%\n{2,}%\n</para>\n<para>\n%g;
2164 $desc .= " " . $note;
2166 $desc .= "</para></warning>\n";
2171 #############################################################################
2172 # Function : MakeConditionDescription
2173 # Description : This returns a sumary of conditions for the given symbol.
2174 # Arguments : $symbol - the symbol to try to create the sumary.
2175 #############################################################################
2177 sub MakeConditionDescription {
2178 my ($symbol) = $_[0];
2181 if (exists $Deprecated{$symbol}) {
2186 if ($Deprecated{$symbol} =~ /^\s*(.*?)\s*$/) {
2187 $desc .= "deprecated:$1";
2189 $desc .= "deprecated";
2193 if (exists $Since{$symbol}) {
2198 if ($Since{$symbol} =~ /^\s*(.*?)\s*$/) {
2199 $desc .= "since:$1";
2205 if (exists $StabilityLevel{$symbol}) {
2209 $desc .= "stability:".$StabilityLevel{$symbol};
2213 $desc=" condition=\"".$desc."\"";
2214 #print "condition for '$symbol' = '$desc'\n";
2219 #############################################################################
2220 # Function : GetHierarchy
2221 # Description : Returns the DocBook output describing the ancestors and
2222 # immediate children of a GObject subclass. It uses the
2223 # global @Objects and @ObjectLevels arrays to walk the tree.
2224 # Arguments : $object - the GtkObject subclass.
2225 #############################################################################
2230 # Find object in the objects array.
2236 for ($i = 0; $i < @Objects; $i++) {
2238 if ($ObjectLevels[$i] <= $level) {
2241 elsif ($ObjectLevels[$i] == $level + 1) {
2242 push (@children, $Objects[$i]);
2245 elsif ($Objects[$i] eq $object) {
2248 $level = $ObjectLevels[$i];
2255 # Walk up the hierarchy, pushing ancestors onto the ancestors array.
2257 push (@ancestors, $object);
2258 # print "Level: $level\n";
2259 while ($level > 1) {
2261 if ($ObjectLevels[$j] < $level) {
2262 push (@ancestors, $Objects[$j]);
2263 $level = $ObjectLevels[$j];
2264 # print "Level: $level\n";
2268 # Output the ancestors list, indented and with links.
2269 my $hierarchy = "<synopsis>\n\n";
2271 for ($i = $#ancestors; $i >= 0; $i--) {
2273 # Don't add a link to the current widget, i.e. when i == 0.
2275 my $ancestor_id = &CreateValidSGMLID ($ancestors[$i]);
2276 $link_text = "<link linkend=\"$ancestor_id\">$ancestors[$i]</link>";
2278 $link_text = "$ancestors[$i]";
2281 $hierarchy .= " $link_text\n";
2283 # $hierarchy .= ' ' x ($level * 6 - 3) . "|\n";
2284 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
2288 for ($i = 0; $i <= $#children; $i++) {
2289 my $id = &CreateValidSGMLID ($children[$i]);
2290 my $link_text = "<link linkend=\"$id\">$children[$i]</link>";
2291 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
2293 $hierarchy .= "</synopsis>\n";
2299 #############################################################################
2300 # Function : GetInterfaces
2301 # Description : Returns the DocBook output describing the interfaces
2302 # implemented by a class. It uses the global %Interfaces hash.
2303 # Arguments : $object - the GtkObject subclass.
2304 #############################################################################
2311 # Find object in the objects array.
2312 if (exists($Interfaces{$object})) {
2313 my @ifaces = split(' ', $Interfaces{$object});
2318 for ($i = 0; $i <= $#ifaces; $i++) {
2319 my $id = &CreateValidSGMLID ($ifaces[$i]);
2320 $text .= " <link linkend=\"$id\">$ifaces[$i]</link>";
2321 if ($i < $#ifaces - 1) {
2324 elsif ($i < $#ifaces) {
2339 #############################################################################
2340 # Function : GetImplementations
2341 # Description : Returns the DocBook output describing the implementations
2342 # of an interface. It uses the global %Interfaces hash.
2343 # Arguments : $object - the GtkObject subclass.
2344 #############################################################################
2346 sub GetImplementations {
2351 foreach my $key (keys %Interfaces) {
2352 if ($Interfaces{$key} =~ /\b$object\b/) {
2353 push (@impls, $key);
2359 $object is implemented by
2361 for ($i = 0; $i <= $#impls; $i++) {
2362 my $id = &CreateValidSGMLID ($impls[$i]);
2363 $text .= " <link linkend=\"$id\">$impls[$i]</link>";
2364 if ($i < $#impls - 1) {
2367 elsif ($i < $#impls) {
2382 #############################################################################
2383 # Function : GetPrerequisites
2384 # Description : Returns the DocBook output describing the prerequisites
2385 # of an interface. It uses the global %Prerequisites hash.
2386 # Arguments : $iface - the interface.
2387 #############################################################################
2389 sub GetPrerequisites {
2394 if (exists($Prerequisites{$iface})) {
2399 my @prereqs = split(' ', $Prerequisites{$iface});
2400 for ($i = 0; $i <= $#prereqs; $i++) {
2401 my $id = &CreateValidSGMLID ($prereqs[$i]);
2402 $text .= " <link linkend=\"$id\">$prereqs[$i]</link>";
2403 if ($i < $#prereqs - 1) {
2406 elsif ($i < $#prereqs) {
2420 #############################################################################
2421 # Function : GetDerived
2422 # Description : Returns the DocBook output describing the derived interfaces
2423 # of an interface. It uses the global %Prerequisites hash.
2424 # Arguments : $iface - the interface.
2425 #############################################################################
2433 foreach my $key (keys %Prerequisites) {
2434 if ($Prerequisites{$key} =~ /\b$iface\b/) {
2435 push (@derived, $key);
2438 if ($#derived >= 0) {
2441 $iface is required by
2443 for ($i = 0; $i <= $#derived; $i++) {
2444 my $id = &CreateValidSGMLID ($derived[$i]);
2445 $text .= " <link linkend=\"$id\">$derived[$i]</link>";
2446 if ($i < $#derived - 1) {
2449 elsif ($i < $#derived) {
2464 #############################################################################
2465 # Function : GetSignals
2466 # Description : Returns the synopsis and detailed description DocBook output
2467 # for the signal handlers of a given GtkObject subclass.
2468 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
2469 #############################################################################
2477 for ($i = 0; $i <= $#SignalObjects; $i++) {
2478 if ($SignalObjects[$i] eq $object) {
2479 # print "Found signal: $SignalNames[$i]\n";
2480 my $name = $SignalNames[$i];
2481 my $symbol = "${object}::${name}";
2482 my $id = &CreateValidSGMLID ("$object-$name");
2484 my $pad = ' ' x (46 - length($name));
2485 $synop .= " "<link linkend=\"$id\">$name</link>"$pad ";
2487 $desc .= "<refsect2><title><anchor id=\"$id\"${empty_element_end}The <literal>"$name"</literal> signal</title>\n";
2488 $desc .= MakeIndexterms($symbol);
2489 $desc .= "<programlisting>";
2491 $SignalReturns[$i] =~ m/\s*(const\s+)?(\w+)\s*(\**)/;
2492 my $type_modifier = defined($1) ? $1 : "";
2495 my $xref = &MakeXRef ($type);
2497 my $ret_type_len = length ($type_modifier) + length ($pointer)
2499 my $ret_type_output = "$type_modifier$xref$pointer"
2500 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
2502 $desc .= "${ret_type_output}user_function " . &MakeReturnField("") . " (";
2504 my $sourceparams = $SourceSymbolParams{$symbol};
2505 my @params = split ("\n", $SignalPrototypes[$i]);
2508 my $type_len = length("gpointer");
2509 my $name_len = length("user_data");
2510 # do two passes, the first one is to calculate padding
2511 for ($l = 0; $l < 2; $l++) {
2512 for ($j = 0; $j <= $#params; $j++) {
2513 # allow alphanumerics, '_', '[' & ']' in param names
2514 if ($params[$j] =~ m/^\s*(\w+)\s*(\**)\s*([\w\[\]]+)\s*$/) {
2517 if (defined($sourceparams)) {
2518 $name = $$sourceparams[2 * $j];
2523 if (!defined($name)) {
2527 if (length($type) + length($pointer) > $type_len) {
2528 $type_len = length($type) + length($pointer);
2530 if (length($name) > $name_len) {
2531 $name_len = length($name);
2535 $xref = &MakeXRef ($type);
2536 $pad = ' ' x ($type_len - length($type) - length($pointer));
2537 $desc .= "$xref$pad $pointer$name,\n";
2538 $desc .= (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
2541 print "###Can't parse arg: $params[$j]\nArgs:$SignalPrototypes[$i]\n";
2545 $xref = &MakeXRef ("gpointer");
2546 $pad = ' ' x ($type_len - length("gpointer"));
2547 $desc .= "$xref$pad user_data)";
2549 my $flags = $SignalFlags[$i];
2550 my $flags_string = "";
2552 if (defined ($flags)) {
2553 if ($flags =~ m/f/) {
2554 $flags_string = "Run First";
2556 elsif ($flags =~ m/l/) {
2557 $flags_string = "Run Last";
2559 elsif ($flags =~ m/c/) {
2560 $flags_string = "Cleanup";
2562 if ($flags =~ m/r/) {
2563 if ($flags_string) { $flags_string .= " / "; }
2564 $flags_string .= "No Recursion";
2566 if ($flags =~ m/d/) {
2567 if ($flags_string) { $flags_string .= " / "; }
2568 $flags_string .= "Has Details";
2570 if ($flags =~ m/a/) {
2571 if ($flags_string) { $flags_string .= " / "; }
2572 $flags_string .= "Action";
2574 if ($flags =~ m/h/) {
2575 if ($flags_string) { $flags_string .= " / "; }
2576 $flags_string .= "No Hooks";
2582 $synop .= ": $flags_string\n";
2584 $pad = ' ' x (5 + $name_len - length("user_data"));
2585 $desc .= "$pad : $flags_string</programlisting>\n";
2590 $desc .= "</programlisting>\n";
2593 my $parameters = &OutputParamDescriptions ("SIGNAL", $symbol);
2594 my $parameters_output = 0;
2596 $AllSymbols{$symbol} = 1;
2597 if (defined ($SymbolDocs{$symbol})) {
2598 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2600 # Try to insert the parameter table at the author's desired
2601 # position. Otherwise we need to tag it onto the end.
2602 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
2603 $parameters_output = 1;
2605 $desc .= $symbol_docs;
2607 if (!IsEmptyDoc($SymbolDocs{$symbol})) {
2608 $AllDocumentedSymbols{$symbol} = 1;
2612 if ($parameters_output == 0) {
2613 $desc .= $parameters;
2616 if (exists $Since{$symbol}) {
2617 $desc .= "<para>Since $Since{$symbol}</para>";
2619 if (exists $StabilityLevel{$symbol}) {
2620 $desc .= "<para>Stability Level: $StabilityLevel{$symbol}</para>";
2622 $desc .= "</refsect2>";
2625 return ($synop, $desc);
2629 #############################################################################
2630 # Function : GetArgs
2631 # Description : Returns the synopsis and detailed description DocBook output
2632 # for the Args of a given GtkObject subclass.
2633 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
2634 #############################################################################
2640 my $child_synop = "";
2641 my $child_desc = "";
2642 my $style_synop = "";
2643 my $style_desc = "";
2646 for ($i = 0; $i <= $#ArgObjects; $i++) {
2647 if ($ArgObjects[$i] eq $object) {
2648 # print "Found arg: $ArgNames[$i]\n";
2649 my $name = $ArgNames[$i];
2650 # Remember only one colon so we don't clash with signals.
2651 my $symbol = "${object}:${name}";
2652 # I've used two dashes here for the same reason.
2653 my $id = &CreateValidSGMLID ("$object--$name");
2655 my $type = $ArgTypes[$i];
2657 my $range = $ArgRanges[$i];
2658 my $range_output = CreateValidSGML($range);
2659 my $default = $ArgDefaults[$i];
2660 my $default_output = CreateValidSGML($default);
2662 if ($type eq "GtkString") {
2665 if ($type eq "GtkSignal") {
2666 $type = "GtkSignalFunc, gpointer";
2667 $type_output = &MakeXRef ("GtkSignalFunc") . ", "
2668 . &MakeXRef ("gpointer");
2669 } elsif ($type =~ m/^(\w+)\*$/) {
2670 $type_output = &MakeXRef ($1) . "*";
2672 $type_output = &MakeXRef ($type);
2675 my $flags = $ArgFlags[$i];
2676 my $flags_string = "";
2678 if ($flags =~ m/r/) {
2679 $flags_string = "Read";
2681 if ($flags =~ m/w/) {
2682 if ($flags_string) { $flags_string .= " / "; }
2683 $flags_string .= "Write";
2685 if ($flags =~ m/x/) {
2686 if ($flags_string) { $flags_string .= " / "; }
2687 $flags_string .= "Construct";
2689 if ($flags =~ m/X/) {
2690 if ($flags_string) { $flags_string .= " / "; }
2691 $flags_string .= "Construct Only";
2694 $AllSymbols{$symbol} = 1;
2696 if (defined($SymbolDocs{$symbol}) &&
2697 !IsEmptyDoc($SymbolDocs{$symbol})) {
2698 $blurb = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2699 $AllDocumentedSymbols{$symbol} = 1;
2702 if (!($ArgBlurbs[$i] eq "")) {
2703 $AllDocumentedSymbols{$symbol} = 1;
2705 $blurb = "<para>" . &CreateValidSGML ($ArgBlurbs[$i]) . "</para>";
2708 my $pad1 = " " x (24 - length ($name));
2709 my $pad2 = " " x (20 - length ($type));
2712 if ($flags =~ m/c/) {
2713 $kind = "child property";
2715 elsif ($flags =~ m/s/) {
2716 $kind = "style property";
2722 my $arg_synop = " "<link linkend=\"$id\">$name</link>"$pad1 $type_output $pad2 : $flags_string\n";
2723 my $arg_desc = "<refsect2><title><anchor id=\"$id\"${empty_element_end}The <literal>"$name"</literal> $kind</title>\n";
2724 $arg_desc .= MakeIndexterms($symbol);
2725 $arg_desc .= "<programlisting> "$name"$pad1 $type_output $pad2 : $flags_string</programlisting>\n";
2726 $arg_desc .= $blurb;
2728 $arg_desc .= "<para>Allowed values: $range_output</para>\n";
2730 if ($default ne "") {
2731 $arg_desc .= "<para>Default value: $default_output</para>\n";
2733 if (exists $Since{$symbol}) {
2734 $arg_desc .= "<para>Since $Since{$symbol}</para>\n";
2736 if (exists $StabilityLevel{$symbol}) {
2737 $arg_desc .= "<para>Stability Level $StabilityLevel{$symbol}</para>\n";
2739 $arg_desc .= "</refsect2>\n";
2741 if ($flags =~ m/c/) {
2742 $child_synop .= $arg_synop;
2743 $child_desc .= $arg_desc;
2745 elsif ($flags =~ m/s/) {
2746 $style_synop .= $arg_synop;
2747 $style_desc .= $arg_desc;
2750 $synop .= $arg_synop;
2755 return ($synop, $child_synop, $style_synop, $desc, $child_desc, $style_desc);
2759 #############################################################################
2760 # Function : ReadSourceDocumentation
2761 # Description : This reads in the documentation embedded in comment blocks
2762 # in the source code (for Gnome).
2764 # Parameter descriptions override any in the template files.
2765 # Function descriptions are placed before any description from
2766 # the template files.
2768 # It recursively descends the source directory looking for .c
2769 # files and scans them looking for specially-formatted comment
2772 # Arguments : $source_dir - the directory to scan.
2773 #############m###############################################################
2775 sub ReadSourceDocumentation {
2776 my ($source_dir) = @_;
2777 my ($file, $dir, @suffix_list, $suffix);
2778 # print "Scanning source directory: $source_dir\n";
2780 # This array holds any subdirectories found.
2783 @suffix_list = split (/,/, $SOURCE_SUFFIXES);
2785 opendir (SRCDIR, $source_dir)
2786 || die "Can't open source directory $source_dir: $!";
2788 foreach $file (readdir (SRCDIR)) {
2789 if ($file =~ /^\./) {
2791 } elsif (-d "$source_dir/$file") {
2792 push (@subdirs, $file);
2793 } elsif (@suffix_list) {
2794 foreach $suffix (@suffix_list) {
2795 if ($file =~ m/\.\Q${suffix}\E$/) {
2796 &ScanSourceFile ("$source_dir/$file");
2799 } elsif ($file =~ m/\.[ch]$/) {
2800 &ScanSourceFile ("$source_dir/$file");
2805 # Now recursively scan the subdirectories.
2806 foreach $dir (@subdirs) {
2807 next if ($IGNORE_FILES =~ m/(\s|^)\Q${dir}\E(\s|$)/);
2808 &ReadSourceDocumentation ("$source_dir/$dir");
2813 #############################################################################
2814 # Function : ScanSourceFile
2815 # Description : Scans one source file looking for specially-formatted comment
2816 # blocks. Later &MergeSourceDocumentation is used to merge any
2817 # documentation found with the documentation already read in
2818 # from the template files.
2820 # Arguments : $file - the file to scan.
2821 #############################################################################
2823 sub ScanSourceFile {
2827 if ($file =~ m/^.*[\/\\]([^\/\\]*)$/) {
2830 print "WARNING: Can't find basename of file $file\n";
2834 # Check if the basename is in the list of files to ignore.
2835 if ($IGNORE_FILES =~ m/(\s|^)\Q${basename}\E(\s|$)/) {
2839 #print "DEBUG: Scanning $file\n";
2841 open (SRCFILE, $file)
2842 || die "Can't open $file: $!";
2843 my $in_comment_block = 0;
2845 my ($in_description, $in_return, $in_since, $in_stability, $in_deprecated);
2846 my ($description, $return_desc, $return_start, $return_style);
2847 my ($since_desc, $stability_desc, $deprecated_desc);
2849 my $ignore_broken_returns;
2852 # Look for the start of a comment block.
2853 if (!$in_comment_block) {
2854 if (m%^\s*/\*.*\*/%) {
2855 #one-line comment - not gtkdoc
2856 } elsif (m%^\s*/\*\*\s%) {
2857 # print "Found comment block start\n";
2859 $in_comment_block = 1;
2861 # Reset all the symbol data.
2863 $in_description = 0;
2872 $deprecated_desc = "";
2873 $stability_desc = "";
2874 $current_param = -1;
2875 $ignore_broken_returns = 0;
2881 # We're in a comment block. Check if we've found the end of it.
2885 WARNING: Symbol name not found at the start of the comment block.
2889 # Add the return value description onto the end of the params.
2891 push (@params, "Returns");
2892 push (@params, $return_desc);
2893 if ($return_style eq 'broken') {
2895 WARNING: Free-form return value description in $symbol.
2896 Use `Returns:' to avoid ambiguities.
2900 # Convert special SGML characters
2901 $description = &ConvertSGMLChars ($symbol, $description);
2903 for ($k = 1; $k <= $#params; $k += 2) {
2904 $params[$k] = &ConvertSGMLChars ($symbol, $params[$k]);
2907 # Handle Section docs
2908 if ($symbol =~ m/SECTION:\s*(.*)/) {
2912 #print "SECTION DOCS found in source for : '$real_symbol'\n";
2913 $ignore_broken_returns = 1;
2914 for ($k = 0; $k <= $#params; $k += 2) {
2915 #print " '".$params[$k]."'\n";
2916 $params[$k] = "\L$params[$k]";
2917 if ($params[$k] eq "short_description") {
2918 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Short_Description"}=$params[$k+1];
2919 } elsif ($params[$k] eq "see_also") {
2920 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:See_Also"}=$params[$k+1];
2921 } elsif ($params[$k] eq "title") {
2922 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Title"}=$params[$k+1];
2923 } elsif ($params[$k] eq "stability") {
2924 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Stability_Level"}=$params[$k+1];
2925 } elsif ($params[$k] eq "section_id") {
2926 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Section_Id"}=$params[$k+1];
2927 } elsif ($params[$k] eq "include") {
2928 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Include"}=$params[$k+1];
2931 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Long_Description"}=$description;
2932 #$SourceSymbolTypes{$symbol} = "SECTION";
2934 #print "SYMBOL DOCS found in source for : '$symbol' ",length($description), "\n";
2935 $SourceSymbolDocs{$symbol} = $description;
2936 $SourceSymbolParams{$symbol} = [ @params ];
2937 # FIXME $SourceSymbolTypes{$symbol} = "STRUCT,SIGNAL,ARG,FUNCTION,MACRO";
2938 #if (defined $DeclarationTypes{$symbol}) {
2939 # $SourceSymbolTypes{$symbol} = $DeclarationTypes{$symbol}
2944 $Since{$symbol} = &ConvertSGMLChars ($symbol, $since_desc);
2947 if ($stability_desc) {
2948 $stability_desc = &ParseStabilityLevel($stability_desc, "Stability level for $symbol");
2949 $StabilityLevel{$symbol} = &ConvertSGMLChars ($symbol, $stability_desc);
2952 if ($deprecated_desc) {
2953 if (exists $Deprecated{$symbol}) {
2956 # don't warn for signals and properties
2957 #if ($symbol !~ m/::?(.*)/) {
2958 if (defined $DeclarationTypes{$symbol}) {
2960 WARNING: $symbol is deprecated in the inline comments
2961 but no deprecation guards were found around the declaration.
2962 (See the --deprecated-guards option for gtkdoc-scan.)
2966 $Deprecated{$symbol} = &ConvertSGMLChars ($symbol, $deprecated_desc);
2970 $in_comment_block = 0;
2974 # Get rid of ' * ' at start of every line in the comment block.
2976 # But make sure we don't get rid of the newline at the end.
2980 # print "DEBUG: scanning :$_";
2982 # If we haven't found the symbol name yet, look for it.
2984 if (m%^\s*(SECTION:\s*\S+)%) {
2986 #print "SECTION DOCS found in source for : '$symbol'\n";
2987 $ignore_broken_returns = 1;
2988 } elsif (m%^\s*([\w:-]*\w)\s*:?%) {
2990 #print "SYMBOL DOCS found in source for : '$symbol'\n";
2995 # If we're in the return value description, add it to the end.
2997 # If we find another valid returns line, we assume that the first
2998 # one was really part of the description.
2999 if (m/^\s*(returns:|return\s+value:)/i) {
3000 if ($return_style eq 'broken') {
3001 $description .= $return_start . $return_desc;
3004 if ($return_style eq 'sane') {
3006 WARNING: Multiple Returns for $symbol
3009 $return_style = 'sane';
3010 $ignore_broken_returns = 1;
3012 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3013 $description .= $return_start . $return_desc;
3015 $return_style = 'broken';
3017 } elsif (m%^\s*since:%i) {
3021 } elsif (m%^\s*stability:%i) {
3022 $stability_desc = $';
3025 } elsif (m%^\s*deprecated:%i) {
3026 $deprecated_desc = $';
3036 if (m/^\s*(returns:|return\s+value:)/i) {
3037 if ($return_style eq 'broken') {
3038 $description .= $return_start . $return_desc;
3041 if ($return_style eq 'sane') {
3043 WARNING: Multiple Returns for $symbol
3046 $return_style = 'sane';
3047 $ignore_broken_returns = 1;
3051 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3053 $return_style = 'broken';
3057 } elsif (m%^\s*deprecated:%i) {
3058 $deprecated_desc = $';
3061 } elsif (m%^\s*stability:%i) {
3062 $stability_desc = $';
3071 if ($in_stability) {
3072 if (m/^\s*(returns:|return\s+value:)/i) {
3073 if ($return_style eq 'broken') {
3074 $description .= $return_start . $return_desc;
3077 if ($return_style eq 'sane') {
3079 WARNING: Multiple Returns for $symbol
3082 $return_style = 'sane';
3083 $ignore_broken_returns = 1;
3087 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3089 $return_style = 'broken';
3093 } elsif (m%^\s*deprecated:%i) {
3094 $deprecated_desc = $';
3097 } elsif (m%^\s*since:%i) {
3102 $stability_desc .= $_;
3107 if ($in_deprecated) {
3108 if (m/^\s*(returns:|return\s+value:)/i) {
3109 if ($return_style eq 'broken') {
3110 $description .= $return_start . $return_desc;
3113 if ($return_style eq 'sane') {
3115 WARNING: Multiple Returns for $symbol
3118 $return_style = 'sane';
3119 $ignore_broken_returns = 1;
3123 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3125 $return_style = 'broken';
3129 } elsif (m%^\s*since:%i) {
3133 } elsif (m%^\s*stability:%i) {
3134 $stability_desc = $';
3138 $deprecated_desc .= $_;
3143 # If we're in the description part, check for the 'Returns:' line.
3144 # If that isn't found, add the text to the end.
3145 if ($in_description) {
3146 # Get rid of 'Description:'
3147 s%^\s*Description:%%;
3149 if (m/^\s*(returns:|return\s+value:)/i) {
3150 if ($return_style eq 'broken') {
3151 $description .= $return_start . $return_desc;
3154 if ($return_style eq 'sane') {
3156 WARNING: Multiple Returns for $symbol
3159 $return_style = 'sane';
3160 $ignore_broken_returns = 1;
3164 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3166 $return_style = 'broken';
3170 } elsif (m%^\s*since:%i) {
3174 } elsif (m%^\s*deprecated:%i) {
3175 $deprecated_desc = $';
3178 } elsif (m%^\s*stability:%i) {
3179 $stability_desc = $';
3188 # We must be in the parameters. Check for the empty line below them.
3190 $in_description = 1;
3194 # Look for a parameter name.
3195 if (m%^\s*@(\S+)\s*:%) {
3196 my $param_name = $1;
3197 #print "Found parameter: $param_name\n";
3198 # Allow '...' as the Varargs parameter.
3199 if ($param_name eq "...") {
3200 $param_name = "Varargs";
3202 if ("\L$param_name" eq "returns") {
3203 $return_style = 'sane';
3204 $ignore_broken_returns = 1;
3206 push (@params, $param_name);
3208 $current_param += 2;
3212 # We must be in the middle of a parameter description, so add it on
3213 # to the last element in @params.
3214 if ($current_param == -1) {
3216 ERROR parsing comment block file : parameter expected -
3220 $params[$#params] .= $_;
3226 #############################################################################
3227 # Function : OutputMissingDocumentation
3228 # Description : Outputs report of documentation coverage to a file
3231 #############################################################################
3233 sub OutputMissingDocumentation {
3234 my $n_documented = 0;
3235 my $n_incomplete = 0;
3241 my $buffer_deprecated = "";
3242 my $buffer_descriptions = "";
3244 open (UNDOCUMENTED, ">$ROOT_DIR/$MODULE-undocumented.txt")
3245 || die "Can't create $ROOT_DIR/$MODULE-undocumented.txt";
3247 foreach $symbol (sort (keys (%AllSymbols))) {
3248 if ($symbol !~ /:(Title|Long_Description|Short_Description|See_Also|Stability_Level|Include)/) {
3250 if (exists ($AllDocumentedSymbols{$symbol})) {
3252 if (exists ($AllIncompleteSymbols{$symbol})) {
3254 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3256 } elsif (exists $Deprecated{$symbol}) {
3257 if (exists ($AllIncompleteSymbols{$symbol})) {
3259 $buffer_deprecated .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3261 $buffer_deprecated .= $symbol . "\n";
3264 if (exists ($AllIncompleteSymbols{$symbol})) {
3266 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
3268 $buffer .= $symbol . "\n";
3271 } elsif ($symbol =~ /:(Long_Description|Short_Description)/) {
3273 #my $len1=(exists($SymbolDocs{$symbol}))?length($SymbolDocs{$symbol}):-1;
3274 #my $len2=(exists($AllDocumentedSymbols{$symbol}))?length($AllDocumentedSymbols{$symbol}):-1;
3275 #print "%%%% $symbol : $len1,$len2\n";
3276 if (((exists ($SymbolDocs{$symbol})) && (length ($SymbolDocs{$symbol}) > 0))
3277 || ((exists ($AllDocumentedSymbols{$symbol})) && (length ($AllDocumentedSymbols{$symbol}) > 0))) {
3280 $symbol =~ m/^.*\/(.*)$/;
3281 $buffer_descriptions .= $1 . "\n";
3286 $buffer .= "\n" . $buffer_deprecated . "\n" . $buffer_descriptions;
3291 $percent = ($n_documented / $total) * 100.0;
3294 printf UNDOCUMENTED "%.0f%% symbol docs coverage.\n", $percent;
3295 print UNDOCUMENTED "$n_documented symbols documented.\n";
3296 print UNDOCUMENTED "$n_incomplete symbols incomplete.\n";
3297 print UNDOCUMENTED ($total - $n_documented) . " not documented.\n\n\n";
3299 print UNDOCUMENTED $buffer;
3301 close (UNDOCUMENTED);
3303 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);
3307 #############################################################################
3308 # Function : OutputUndeclaredSymbols
3309 # Description : Outputs symbols that are undeclared yet documented to a file
3312 #############################################################################
3314 sub OutputUndeclaredSymbols {
3315 open(UNDECLARED, ">$ROOT_DIR/$MODULE-undeclared.txt")
3316 || die "Can't create $ROOT_DIR/$MODULE-undeclared.txt";
3318 if (%UndeclaredSymbols) {
3319 print UNDECLARED (join("\n", sort keys %UndeclaredSymbols));
3320 print UNDECLARED "\n";
3321 print "See $MODULE-undeclared.txt for the list of undeclared symbols.\n"
3327 #############################################################################
3328 # Function : OutputAllSymbols
3329 # Description : Outputs list of all symbols to a file
3332 #############################################################################
3334 sub OutputAllSymbols {
3335 my $n_documented = 0;
3341 open (SYMBOLS, ">$ROOT_DIR/$MODULE-symbols.txt")
3342 || die "Can't create $ROOT_DIR/$MODULE-symbols.txt";
3344 foreach $symbol (sort (keys (%AllSymbols))) {
3345 print SYMBOLS $symbol . "\n"
3352 #############################################################################
3353 # Function : MergeSourceDocumentation
3354 # Description : This merges documentation read from a source file into the
3355 # documentation read in from a template file.
3357 # Parameter descriptions override any in the template files.
3358 # Function descriptions are placed before any description from
3359 # the template files.
3362 #############################################################################
3364 sub MergeSourceDocumentation {
3368 if (scalar %SymbolDocs) {
3369 @Symbols=keys (%SymbolDocs);
3372 @Symbols=keys (%SourceSymbolDocs);
3374 foreach $symbol (@Symbols) {
3375 $AllSymbols{$symbol} = 1;
3377 my $have_tmpl_docs = 0;
3379 ## See if the symbol is documented out-of-line
3380 my $tmpl_doc = $SymbolDocs{$symbol};
3381 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3382 $tmpl_doc =~ s/<\/?[a-z]+>//g;
3383 $tmpl_doc =~ s/\s//g;
3384 if ($tmpl_doc ne "") {
3385 $have_tmpl_docs = 1;
3388 #print "merging $symbol\n";
3390 if (exists ($SourceSymbolDocs{$symbol})) {
3391 my $src_doc = $SourceSymbolDocs{$symbol};
3392 my $tmpl_doc = $SymbolDocs{$symbol};
3393 my $type = $DeclarationTypes {$symbol};
3395 #print "... from source\n";
3397 my $item = "Parameter";
3398 if (defined ($type)) {
3399 if ($type eq 'STRUCT') {
3401 } elsif ($type eq 'ENUM') {
3403 } elsif ($type eq 'UNION') {
3410 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3411 $src_doc =~ s/^\s+//;
3412 $src_doc =~ s/\s+$//;
3414 # Don't output warnings for overridden titles as titles are
3415 # automatically generated in the -sections.txt file so are often
3417 if ($have_tmpl_docs && $symbol !~ m/:Title$/) {
3419 WARNING: Documentation in template file for $symbol being overridden by inline comments
3423 if ($src_doc ne "") {
3424 $AllDocumentedSymbols{$symbol} = 1;
3427 # Convert <!--PARAMETERS--> with any blank lines around it to
3428 # a </para> followed by <!--PARAMETERS--> followed by <para>.
3429 $src_doc =~ s%\n+\s*<!--PARAMETERS-->\s*\n+%\n</para>\n<!--PARAMETERS-->\n<para>\n%g;
3431 # If there is a blank line, finish the paragraph and start another.
3432 $src_doc = &ConvertBlankLines ($src_doc, $symbol);
3434 if ($symbol =~ m/$TMPL_DIR\/.+:Long_Description/) {
3435 # FIXME: should we check for empty $tmpl_doc ?
3436 $SymbolDocs{$symbol} = "<para>\n$src_doc</para>\n$tmpl_doc"
3437 } elsif ($symbol =~ m/$TMPL_DIR\/.+:.+/) {
3438 # For the title/summary/see also section docs we don't want to
3439 # add any <para> tags.
3440 $SymbolDocs{$symbol} = "$src_doc"
3442 $SymbolDocs{$symbol} = "<para>\n$src_doc</para>\n$tmpl_doc";
3446 if ($symbol =~ m/.*::.*/) {
3447 # For signals we prefer the param names from the source docs,
3448 # since the ones from the templates are likely to contain the
3449 # artificial argn names which are generated by gtkdoc-scangobj.
3450 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
3451 # FIXME: we need to check for empty docs here as well!
3453 # The templates contain the definitive parameter names and order,
3454 # so we will not change that. We only override the actual text.
3455 my $tmpl_params = $SymbolParams{$symbol};
3456 if (!defined ($tmpl_params)) {
3457 #print "No merge needed for $symbol\n";
3458 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
3460 my $params = $SourceSymbolParams{$symbol};
3462 for ($j = 0; $j <= $#$tmpl_params; $j += 2) {
3463 my $tmpl_param_name = $$tmpl_params[$j];
3465 # Allow '...' as the Varargs parameter.
3466 if ($tmpl_param_name eq "...") {
3467 $tmpl_param_name = "Varargs";
3470 # Try to find the param in the source comment documentation.
3473 for ($k = 0; $k <= $#$params; $k += 2) {
3474 my $param_name = $$params[$k];
3475 my $param_desc = $$params[$k + 1];
3477 # We accept changes in case, since the Gnome source docs
3478 # contain a lot of these.
3479 if ("\L$param_name" eq "\L$tmpl_param_name") {
3482 # Override the description.
3483 $$tmpl_params[$j + 1] = $param_desc ;
3485 # Set the name to "" to mark it as used.
3491 # If it looks like the parameters are there, but not
3492 # in the right place, try to explain a bit better.
3493 if ((!$found) && ($src_doc =~ m/\@$tmpl_param_name:/)) {
3495 Parameters for $symbol must start on the line immediately after the function
3501 # Now we output a warning if parameters have been described which
3503 for ($j = 0; $j <= $#$params; $j += 2) {
3504 my $param_name = $$params[$j];
3506 # the template builder cannot detect if a macro returns
3508 if(($type eq "MACRO") && ($param_name eq "Returns")) {
3512 WARNING: $item described in source code comment block but does not exist -
3513 $type: $symbol $item: $param_name.
3520 if ($have_tmpl_docs) {
3521 $AllDocumentedSymbols{$symbol} = 1;
3524 #print "... undocumented\n";
3527 # if this symbol is documented, check if docs are complete
3528 $tmpl_doc = $SymbolDocs{$symbol};
3529 $tmpl_doc = defined ($tmpl_doc) ? $tmpl_doc : "";
3530 $tmpl_doc =~ s/<\/?[a-z]+>//g;
3531 $tmpl_doc =~ s/\s//g;
3532 if ($tmpl_doc ne "") {
3533 my $tmpl_params = $SymbolParams{$symbol};
3534 if (defined ($tmpl_params)) {
3535 my $type = $DeclarationTypes {$symbol};
3537 my $item = "Parameter";
3538 if (defined ($type)) {
3539 if ($type eq 'STRUCT') {
3541 } elsif ($type eq 'ENUM') {
3543 } elsif ($type eq 'UNION') {
3551 for ($j = 0; $j <= $#$tmpl_params; $j += 2) {
3552 # Output a warning if the parameter is empty and
3553 # remember for stats.
3554 my $tmpl_param_name = $$tmpl_params[$j];
3555 my $tmpl_param_desc = $$tmpl_params[$j + 1];
3556 if ($tmpl_param_desc !~ m/\S/) {
3557 if (exists ($AllIncompleteSymbols{$symbol})) {
3558 $AllIncompleteSymbols{$symbol}.=", ".$tmpl_param_name;
3560 $AllIncompleteSymbols{$symbol}=$tmpl_param_name;
3563 #WARNING: $item description missing in source code comment block -
3564 # $type: $symbol $item: $tmpl_param_name.
3576 if ($doc =~ /^\s*<para>\s*(FIXME)?\s*<\/para>\s*$/) {
3584 # This converts blank lines to "</para><para>", but only outside CDATA and
3585 # <programlisting> tags.
3586 sub ConvertBlankLines {
3587 return &ModifyXMLElements ($_[0], $_[1],
3588 "<!\\[CDATA\\[|<programlisting[^>]*>|\\|\\[",
3589 \&ConvertBlankLinesEndTag,
3590 \&ConvertBlankLinesCallback);
3594 sub ConvertBlankLinesEndTag {
3595 if ($_[0] eq "<!\[CDATA\[") {
3597 } elsif ($_[0] eq "|[") {
3600 return "</programlisting>";
3604 sub ConvertBlankLinesCallback {
3605 my ($text, $symbol, $tag) = @_;
3607 # If we're not in CDATA or a <programlisting> we convert blank lines so
3608 # they start a new <para>.
3610 $text =~ s%\n{2,}%\n</para>\n<para>\n%g;
3617 #############################################################################
3618 # LIBRARY FUNCTIONS - These functions are used in both gtkdoc-mkdb and
3619 # gtkdoc-mktmpl and should eventually be moved to a
3621 #############################################################################
3623 #############################################################################
3624 # Function : ReadDeclarationsFile
3625 # Description : This reads in a file containing the function/macro/enum etc.
3628 # Note that in some cases there are several declarations with
3629 # the same name, e.g. for conditional macros. In this case we
3630 # set a flag in the %DeclarationConditional hash so the
3631 # declaration is not shown in the docs.
3633 # If a macro and a function have the same name, e.g. for
3634 # gtk_object_ref, the function declaration takes precedence.
3636 # Some opaque structs are just declared with 'typedef struct
3637 # _name name;' in which case the declaration may be empty.
3638 # The structure may have been found later in the header, so
3639 # that overrides the empty declaration.
3641 # Arguments : $file - the declarations file to read
3642 # $override - if declarations in this file should override
3643 # any current declaration.
3644 #############################################################################
3646 sub ReadDeclarationsFile {
3647 my ($file, $override) = @_;
3649 if ($override == 0) {
3651 %DeclarationTypes = ();
3652 %DeclarationConditional = ();
3653 %DeclarationOutput = ();
3657 || die "Can't open $file";
3658 my $declaration_type = "";
3659 my $declaration_name;
3661 my $is_deprecated = 0;
3663 if (!$declaration_type) {
3664 if (m/^<([^>]+)>/) {
3665 $declaration_type = $1;
3666 $declaration_name = "";
3667 # print "Found declaration: $declaration_type\n";
3671 if (m%^<NAME>(.*)</NAME>%) {
3672 $declaration_name = $1;
3673 } elsif (m%^<DEPRECATED/>%) {
3675 } elsif (m%^</$declaration_type>%) {
3676 # print "Found end of declaration: $declaration_name\n";
3677 # Check that the declaration has a name
3678 if ($declaration_name eq "") {
3679 print "ERROR: $declaration_type has no name $file:$.\n";
3682 # If the declaration is an empty typedef struct _XXX XXX
3683 # set the flag to indicate the struct has a typedef.
3684 if ($declaration_type eq 'STRUCT'
3685 && $declaration =~ m/^\s*$/) {
3686 # print "Struct has typedef: $declaration_name\n";
3687 $StructHasTypedef{$declaration_name} = 1;
3690 # Check if the symbol is already defined.
3691 if (defined ($Declarations{$declaration_name})
3692 && $override == 0) {
3693 # Function declarations take precedence.
3694 if ($DeclarationTypes{$declaration_name} eq 'FUNCTION') {
3696 } elsif ($declaration_type eq 'FUNCTION') {
3697 if ($is_deprecated) {
3698 $Deprecated{$declaration_name} = "";
3700 $Declarations{$declaration_name} = $declaration;
3701 $DeclarationTypes{$declaration_name} = $declaration_type;
3702 } elsif ($DeclarationTypes{$declaration_name}
3703 eq $declaration_type) {
3704 # If the existing declaration is empty, or is just a
3705 # forward declaration of a struct, override it.
3706 if ($declaration_type eq 'STRUCT') {
3707 if ($Declarations{$declaration_name} =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
3708 if ($is_deprecated) {
3709 $Deprecated{$declaration_name} = "";
3711 $Declarations{$declaration_name} = $declaration;
3712 } elsif ($declaration =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
3713 # Ignore an empty or forward declaration.
3715 print "WARNING: Structure has multiple definitions: $declaration_name\n";
3719 # set flag in %DeclarationConditional hash for
3720 # multiply defined macros/typedefs.
3721 $DeclarationConditional{$declaration_name} = 1;
3724 print "ERROR: $declaration_name has multiple definitions\n";
3727 if ($is_deprecated) {
3728 $Deprecated{$declaration_name} = "";
3730 $Declarations{$declaration_name} = $declaration;
3731 $DeclarationTypes{$declaration_name} = $declaration_type;
3734 $declaration_type = "";
3745 #############################################################################
3746 # Function : ReadSignalsFile
3747 # Description : This reads in an existing file which contains information on
3748 # all GTK signals. It creates the arrays @SignalNames and
3749 # @SignalPrototypes containing info on the signals. The first
3750 # line of the SignalPrototype is the return type of the signal
3751 # handler. The remaining lines are the parameters passed to it.
3752 # The last parameter, "gpointer user_data" is always the same
3753 # so is not included.
3754 # Arguments : $file - the file containing the signal handler prototype
3756 #############################################################################
3758 sub ReadSignalsFile {
3766 my $signal_prototype;
3768 # Reset the signal info.
3769 @SignalObjects = ();
3771 @SignalReturns = ();
3773 @SignalPrototypes = ();
3778 if (!open (INPUT, $file)) {
3779 warn "Can't open $file - skipping signals\n";
3786 $signal_object = "";
3788 $signal_returns = "";
3789 $signal_prototype = "";
3792 if (m/^<NAME>(.*)<\/NAME>/) {
3794 if ($signal_name =~ m/^(.*)::(.*)$/) {
3795 $signal_object = $1;
3796 ($signal_name = $2) =~ s/_/-/g;
3797 # print "Found signal: $signal_name\n";
3799 print "Invalid signal name: $signal_name\n";
3801 } elsif (m/^<RETURNS>(.*)<\/RETURNS>/) {
3802 $signal_returns = $1;
3803 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
3805 } elsif (m%^</SIGNAL>%) {
3806 # print "Found end of signal: ${signal_object}::${signal_name}\nReturns: ${signal_returns}\n${signal_prototype}";
3807 push (@SignalObjects, $signal_object);
3808 push (@SignalNames, $signal_name);
3809 push (@SignalReturns, $signal_returns);
3810 push (@SignalFlags, $signal_flags);
3811 push (@SignalPrototypes, $signal_prototype);
3814 $signal_prototype .= $_;
3822 #############################################################################
3823 # Function : ReadTemplateFile
3824 # Description : This reads in the manually-edited documentation file
3825 # corresponding to the file currently being created, so we can
3826 # insert the documentation at the appropriate places.
3827 # It outputs %SymbolTypes, %SymbolDocs and %SymbolParams, which
3828 # is a hash of arrays.
3829 # NOTE: This function is duplicated in gtkdoc-mkdb (but
3830 # slightly different).
3831 # Arguments : $docsfile - the template file to read in.
3832 # $skip_unused_params - 1 if the unused parameters should be
3834 #############################################################################
3836 sub ReadTemplateFile {
3837 my ($docsfile, $skip_unused_params) = @_;
3839 my $template = "$docsfile.sgml";
3840 # print "Reading $template\n";
3841 if (! -f $template) {
3842 # print "File doesn't exist: $template\n";
3846 my $current_type = ""; # Type of symbol being read.
3847 my $current_symbol = ""; # Name of symbol being read.
3848 my $symbol_doc = ""; # Description of symbol being read.
3849 my @params; # Parameter names and descriptions of current
3850 # function/macro/function typedef.
3851 my $current_param = -1; # Index of parameter currently being read.
3852 # Note that the param array contains pairs
3853 # of param name & description.
3854 my $in_unused_params = 0; # True if we are reading in the unused params.
3855 my $in_deprecated = 0;
3857 my $in_stability = 0;
3859 open (DOCS, "$template")
3860 || die "Can't open file $template: $!";
3862 if (m/^<!-- ##### ([A-Z_]+) (\S+) ##### -->/) {
3865 if ($symbol eq "Title"
3866 || $symbol eq "Short_Description"
3867 || $symbol eq "Long_Description"
3868 || $symbol eq "See_Also"
3869 || $symbol eq "Stability_Level"
3870 || $symbol eq "Include") {
3872 $symbol = $docsfile . ":" . $symbol;
3875 # print "Found symbol: $symbol\n";
3877 # Store previous symbol, but remove any trailing blank lines.
3878 if ($current_symbol ne "") {
3879 $symbol_doc =~ s/\s+$//;
3880 $SymbolTypes{$current_symbol} = $current_type;
3881 $SymbolDocs{$current_symbol} = $symbol_doc;
3883 # Check that the stability level is valid.
3884 if ($StabilityLevel{$current_symbol}) {
3885 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, "Stability level for $current_symbol");
3888 if ($current_param >= 0) {
3889 $SymbolParams{$current_symbol} = [ @params ];
3891 # Delete any existing params in case we are overriding a
3892 # previously read template.
3893 delete $SymbolParams{$current_symbol};
3896 $current_type = $type;
3897 $current_symbol = $symbol;
3898 $current_param = -1;
3899 $in_unused_params = 0;
3906 } elsif (m/^<!-- # Unused Parameters # -->/) {
3907 # print "DEBUG: Found unused parameters\n";
3908 $in_unused_params = 1;
3911 } elsif ($in_unused_params && $skip_unused_params) {
3912 # When outputting the DocBook we skip unused parameters.
3913 # print "DEBUG: Skipping unused param: $_";
3917 # Check if param found. Need to handle "..." and "format...".
3918 if (s/^\@([\w\.]+):\040?//) {
3919 my $param_name = $1;
3920 # Allow variations of 'Returns'
3921 if ($param_name =~ m/^[Rr]eturns?$/) {
3922 $param_name = "Returns";
3924 # print "Found param for symbol $current_symbol : '$param_name'= '$_'\n";
3926 if ($param_name eq "Deprecated") {
3928 $Deprecated{$current_symbol} = $_;
3929 } elsif ($param_name eq "Since") {
3931 $Since{$current_symbol} = $_;
3932 } elsif ($param_name eq "Stability") {
3934 $StabilityLevel{$current_symbol} = $_;
3936 push (@params, $param_name);
3938 $current_param += 2;
3941 if ($in_deprecated) {
3942 $Deprecated{$current_symbol} .= $_;
3943 } elsif ($in_since) {
3944 $Since{$current_symbol} .= $_;
3945 } elsif ($in_stability) {
3946 $StabilityLevel{$current_symbol} .= $_;
3947 } elsif ($current_param >= 0) {
3948 $params[$current_param] .= $_;
3956 # Remember to finish the current symbol doccs.
3957 if ($current_symbol ne "") {
3959 $symbol_doc =~ s/\s+$//;
3960 $SymbolTypes{$current_symbol} = $current_type;
3961 $SymbolDocs{$current_symbol} = $symbol_doc;
3963 # Check that the stability level is valid.
3964 if ($StabilityLevel{$current_symbol}) {
3965 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, "Stability level for $current_symbol");
3968 if ($current_param >= 0) {
3969 $SymbolParams{$current_symbol} = [ @params ];
3971 # Delete any existing params in case we are overriding a
3972 # previously read template.
3973 delete $SymbolParams{$current_symbol};
3981 #############################################################################
3982 # Function : ReadObjectHierarchy
3983 # Description : This reads in the $MODULE-hierarchy.txt file containing all
3984 # the GtkObject subclasses described in this module (and their
3986 # It places them in the @Objects array, and places their level
3987 # in the widget hierarchy in the @ObjectLevels array, at the
3988 # same index. GtkObject, the root object, has a level of 1.
3990 # FIXME: the version in gtkdoc-mkdb also generates tree_index.sgml
3991 # as it goes along, this should be split out into a separate
3995 #############################################################################
3997 sub ReadObjectHierarchy {
4001 if (! -f $OBJECT_TREE_FILE) {
4004 if (!open (INPUT, $OBJECT_TREE_FILE)) {
4005 warn "Can't open $OBJECT_TREE_FILE - skipping object tree\n";
4009 my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.sgml";
4010 my $new_tree_index = "$SGML_OUTPUT_DIR/tree_index.new";
4011 my $tree_header = $doctype_header;
4012 $tree_header =~ s/<!DOCTYPE \w+/<!DOCTYPE screen/;
4014 open (OUTPUT, ">$new_tree_index")
4015 || die "Can't create $new_tree_index";
4016 print (OUTPUT "$tree_header<screen>\n");
4018 # Only emit objects if they are supposed to be documented, or if
4019 # they have documented children. To implement this, we maintain a
4020 # stack of pending objects which will be emitted if a documented
4022 my @pending_objects = ();
4023 my @pending_levels = ();
4027 my $level = (length($`)) / 2 + 1;
4030 while (($#pending_levels >= 0) && ($pending_levels[$#pending_levels] >= $level)) {
4031 my $pobject = pop(@pending_objects);
4032 my $plevel = pop(@pending_levels);
4035 push (@pending_objects, $object);
4036 push (@pending_levels, $level);
4038 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
4039 while ($#pending_levels >= 0) {
4040 $object = shift @pending_objects;
4041 $level = shift @pending_levels;
4042 $xref = &MakeXRef ($object);
4044 print (OUTPUT ' ' x ($level * 4), "$xref\n");
4045 push (@Objects, $object);
4046 push (@ObjectLevels, $level);
4051 print (OUTPUT "</screen>\n");
4056 &UpdateFileIfChanged ($old_tree_index, $new_tree_index, 0);
4061 #############################################################################
4062 # Function : ReadInterfaces
4063 # Description : This reads in the $MODULE.interfaces file.
4066 #############################################################################
4068 sub ReadInterfaces {
4071 if (! -f $INTERFACES_FILE) {
4074 if (!open (INPUT, $INTERFACES_FILE)) {
4075 warn "Can't open $INTERFACES_FILE - skipping interfaces\n";
4081 my ($object, @ifaces) = split;
4082 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
4083 my @knownIfaces = ();
4085 # filter out private interfaces, but leave foreign interfaces
4086 foreach my $iface (@ifaces) {
4087 if (!exists($KnownSymbols{$iface}) || $KnownSymbols{$iface} == 1) {
4088 push (@knownIfaces, $iface);
4092 $Interfaces{$object} = join(' ', @knownIfaces);
4098 #############################################################################
4099 # Function : ReadPrerequisites
4100 # Description : This reads in the $MODULE.prerequisites file.
4103 #############################################################################
4105 sub ReadPrerequisites {
4106 %Prerequisites = ();
4108 if (! -f $PREREQUISITES_FILE) {
4111 if (!open (INPUT, $PREREQUISITES_FILE)) {
4112 warn "Can't open $PREREQUISITES_FILE - skipping prerequisites\n";
4118 my ($iface, @prereqs) = split;
4119 if (exists($KnownSymbols{$iface}) && $KnownSymbols{$iface} == 1) {
4120 my @knownPrereqs = ();
4122 # filter out private prerequisites, but leave foreign prerequisites
4123 foreach my $prereq (@prereqs) {
4124 if (!exists($KnownSymbols{$prereq}) || $KnownSymbols{$prereq} == 1) {
4125 push (@knownPrereqs, $prereq);
4129 $Prerequisites{$iface} = join(' ', @knownPrereqs);
4135 #############################################################################
4136 # Function : ReadArgsFile
4137 # Description : This reads in an existing file which contains information on
4138 # all GTK args. It creates the arrays @ArgObjects, @ArgNames,
4139 # @ArgTypes, @ArgFlags, @ArgNicks and @ArgBlurbs containing info
4141 # Arguments : $file - the file containing the arg information.
4142 #############################################################################
4157 # Reset the args info.
4170 if (!open (INPUT, $file)) {
4171 warn "Can't open $file - skipping args\n";
4188 if (m/^<NAME>(.*)<\/NAME>/) {
4190 if ($arg_name =~ m/^(.*)::(.*)$/) {
4192 ($arg_name = $2) =~ s/_/-/g;
4193 # print "Found arg: $arg_name\n";
4195 print "Invalid arg name: $arg_name\n";
4197 } elsif (m/^<TYPE>(.*)<\/TYPE>/) {
4199 } elsif (m/^<RANGE>(.*)<\/RANGE>/) {
4201 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
4203 } elsif (m/^<NICK>(.*)<\/NICK>/) {
4205 } elsif (m/^<BLURB>(.*)<\/BLURB>/) {
4207 if ($arg_blurb eq "(null)") {
4210 WARNING: Property ${arg_object}:${arg_name} has no documentation.
4213 } elsif (m/^<DEFAULT>(.*)<\/DEFAULT>/) {
4215 } elsif (m%^</ARG>%) {
4216 # print "Found end of arg: ${arg_object}::${arg_name}\n${arg_type} : ${arg_flags}\n";
4217 push (@ArgObjects, $arg_object);
4218 push (@ArgNames, $arg_name);
4219 push (@ArgTypes, $arg_type);
4220 push (@ArgRanges, $arg_range);
4221 push (@ArgFlags, $arg_flags);
4222 push (@ArgNicks, $arg_nick);
4223 push (@ArgBlurbs, $arg_blurb);
4224 push (@ArgDefaults, $arg_default);
4233 #############################################################################
4234 # Function : CheckIsObject
4235 # Description : Returns 1 if the given name is a GtkObject or a subclass.
4236 # It uses the global @Objects array.
4237 # Note that the @Objects array only contains classes in the
4238 # current module and their ancestors - not all GTK classes.
4239 # Arguments : $name - the name to check.
4240 #############################################################################
4246 foreach $object (@Objects) {
4247 if ($object eq $name) {
4255 #############################################################################
4256 # Function : MakeReturnField
4257 # Description : Pads a string to $RETURN_TYPE_FIELD_WIDTH.
4258 # Arguments : $str - the string to pad.
4259 #############################################################################
4261 sub MakeReturnField {
4264 return $str . (' ' x ($RETURN_TYPE_FIELD_WIDTH - length ($str)));