4 # gtk-doc - GTK DocBook documentation generator.
5 # Copyright (C) 1998 Damon Chaplin
6 # 2007,2008,2009 Stefan Kost
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #############################################################################
24 # Script : gtkdoc-mkdb
25 # Description : This creates the DocBook files from the edited templates.
26 #############################################################################
31 push @INC, '@PACKAGE_DATA_DIR@';
32 require "gtkdoc-common.pl";
36 # name of documentation module
41 my $SOURCE_SUFFIXES = "";
42 my $IGNORE_FILES = "";
46 my $EXPAND_CONTENT_FILES = "";
47 my $INLINE_MARKUP_MODE;
48 my $DEFAULT_STABILITY;
52 my $OUTPUT_ALL_SYMBOLS;
53 my $OUTPUT_SYMBOLS_WITHOUT_SINCE;
55 my %optctl = ('module' => \$MODULE,
56 'source-dir' => \@SOURCE_DIRS,
57 'source-suffixes' => \$SOURCE_SUFFIXES,
58 'ignore-files' => \$IGNORE_FILES,
59 'output-dir' => \$SGML_OUTPUT_DIR,
60 'tmpl-dir' => \$TMPL_DIR,
61 'version' => \$PRINT_VERSION,
62 'help' => \$PRINT_HELP,
63 'main-sgml-file' => \$MAIN_SGML_FILE,
64 'expand-content-files' => \$EXPAND_CONTENT_FILES,
65 'sgml-mode' => \$INLINE_MARKUP_MODE,
66 'xml-mode' => \$INLINE_MARKUP_MODE,
67 'default-stability' => \$DEFAULT_STABILITY,
68 'default-includes' => \$DEFAULT_INCLUDES,
69 'output-format' => \$OUTPUT_FORMAT,
70 'name-space' => \$NAME_SPACE,
71 'outputallsymbols' => \$OUTPUT_ALL_SYMBOLS,
72 'outputsymbolswithoutsince' => \$OUTPUT_SYMBOLS_WITHOUT_SINCE
74 GetOptions(\%optctl, "module=s", "source-dir:s", "source-suffixes:s",
75 "ignore-files:s", "output-dir:s", "tmpl-dir:s", "version", "outputallsymbols",
76 "outputsymbolswithoutsince",
77 "expand-content-files:s", "main-sgml-file:s", "extra-db-files:s", "help",
78 "sgml-mode", "xml-mode", "default-stability:s", "default-includes:s",
79 "output-format:s", "name-space:s");
90 if ($DEFAULT_STABILITY && $DEFAULT_STABILITY ne "Stable"
91 && $DEFAULT_STABILITY ne "Private" && $DEFAULT_STABILITY ne "Unstable") {
97 gtkdoc-mkdb version @VERSION@ - generate docbook files
99 --module=MODULE_NAME Name of the doc module being parsed
100 --source-dir=DIRNAME Directories which contain inline reference material
101 --source-suffixes=SUFFIXES Suffixes of source files to scan, comma-separated
102 --ignore-files=FILES Files or directories which should not be scanned
103 May be used more than once for multiple directories
104 --output-dir=DIRNAME Directory to put the generated DocBook files in
105 --tmpl-dir=DIRNAME Directory in which template files may be found
106 --main-sgml-file=FILE File containing the toplevel DocBook file.
107 --expand-content-files=FILES Extra DocBook files to expand abbreviations in.
108 --output-format=FORMAT Format to use for the generated docbook, XML or SGML.
109 --{xml,sgml}-mode Allow DocBook markup in inline documentation.
110 --default-stability=LEVEL Specify default stability Level. Valid values are
111 Stable, Unstable, or Private.
112 --default-includes=FILENAMES Specify default includes for section Synopsis
113 --name-space=NS Omit namespace in index.
114 --version Print the version of this program
115 --help Print this help
120 my ($empty_element_end, $doctype_header);
122 # autodetect output format
123 if (! defined($OUTPUT_FORMAT) || ($OUTPUT_FORMAT eq "")) {
124 if (!$MAIN_SGML_FILE) {
125 if (-e "${MODULE}-docs.xml") {
126 $OUTPUT_FORMAT = "xml";
128 $OUTPUT_FORMAT = "sgml";
131 if ($MAIN_SGML_FILE =~ m/.*\.(.*ml)$/i) {
132 $OUTPUT_FORMAT = lc($1);
137 $OUTPUT_FORMAT = lc($OUTPUT_FORMAT);
140 #print "DEBUG: output-format: [$OUTPUT_FORMAT]\n";
142 if ($OUTPUT_FORMAT eq "xml") {
143 if (!$MAIN_SGML_FILE) {
144 # backwards compatibility
145 if (-e "${MODULE}-docs.sgml") {
146 $MAIN_SGML_FILE = "${MODULE}-docs.sgml";
148 $MAIN_SGML_FILE = "${MODULE}-docs.xml";
151 $empty_element_end = "/>";
153 if (-e $MAIN_SGML_FILE) {
154 open(INPUT, "<$MAIN_SGML_FILE") || die "Can't open $MAIN_SGML_FILE";
155 $doctype_header = "";
157 if (/^\s*<(book|chapter|article)/) {
158 # check that the top-level tag or the doctype decl contain the xinclude namespace decl
159 if (($_ !~ m/http:\/\/www.w3.org\/200[13]\/XInclude/) && ($doctype_header !~ m/http:\/\/www.w3.org\/200[13]\/XInclude/m)) {
160 $doctype_header = "";
164 $doctype_header .= $_;
167 $doctype_header =~ s/<!DOCTYPE \w+/<!DOCTYPE refentry/;
168 # if there are SYSTEM ENTITIES here, we should prepend "../" to the path
169 # FIXME: not sure if we can do this now, as people already work-around the problem
170 # $doctype_header =~ s#<!ENTITY % ([a-zA-Z-]+) SYSTEM \"([^/][a-zA-Z./]+)\">#<!ENTITY % $1 SYSTEM \"../$2\">#g;
173 "<?xml version=\"1.0\"?>\n" .
174 "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.3//EN\"\n" .
175 " \"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd\"\n" .
177 " <!ENTITY % local.common.attrib \"xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'\">\n" .
181 if (!$MAIN_SGML_FILE) {
182 $MAIN_SGML_FILE = "${MODULE}-docs.sgml";
184 $empty_element_end = ">";
185 $doctype_header = "";
190 # All the files are written in subdirectories beneath here.
191 $TMPL_DIR = $TMPL_DIR ? $TMPL_DIR : "$ROOT_DIR/tmpl";
193 # This is where we put all the DocBook output.
194 $SGML_OUTPUT_DIR = $SGML_OUTPUT_DIR ? $SGML_OUTPUT_DIR : "$ROOT_DIR/$OUTPUT_FORMAT";
196 # This file contains the object hierarchy.
197 my $OBJECT_TREE_FILE = "$ROOT_DIR/$MODULE.hierarchy";
199 # This file contains the interfaces.
200 my $INTERFACES_FILE = "$ROOT_DIR/$MODULE.interfaces";
202 # This file contains the prerequisites.
203 my $PREREQUISITES_FILE = "$ROOT_DIR/$MODULE.prerequisites";
205 # This file contains signal arguments and names.
206 my $SIGNALS_FILE = "$ROOT_DIR/$MODULE.signals";
208 # The file containing Arg information.
209 my $ARGS_FILE = "$ROOT_DIR/$MODULE.args";
211 # These global arrays store information on signals. Each signal has an entry
212 # in each of these arrays at the same index, like a multi-dimensional array.
213 my @SignalObjects; # The GtkObject which emits the signal.
214 my @SignalNames; # The signal name.
215 my @SignalReturns; # The return type.
216 my @SignalFlags; # Flags for the signal
217 my @SignalPrototypes; # The rest of the prototype of the signal handler.
219 # These global arrays store information on Args. Each Arg has an entry
220 # in each of these arrays at the same index, like a multi-dimensional array.
221 my @ArgObjects; # The GtkObject which has the Arg.
222 my @ArgNames; # The Arg name.
223 my @ArgTypes; # The Arg type - gint, GtkArrowType etc.
224 my @ArgFlags; # How the Arg can be used - readable/writable etc.
225 my @ArgNicks; # The nickname of the Arg.
226 my @ArgBlurbs; # Docstring of the Arg.
227 my @ArgDefaults; # Default value of the Arg.
228 my @ArgRanges; # The range of the Arg type
229 # These global hashes store declaration info keyed on a symbol name.
231 my %DeclarationTypes;
232 my %DeclarationConditional;
233 my %DeclarationOutput;
237 my %StructHasTypedef;
239 # These global hashes store the existing documentation.
243 my %SymbolSourceFile;
244 my %SymbolSourceLine;
246 # These global hashes store documentation scanned from the source files.
247 my %SourceSymbolDocs;
248 my %SourceSymbolParams;
249 my %SourceSymbolSourceFile;
250 my %SourceSymbolSourceLine;
252 # all documentation goes in here, so we can do coverage analysis
254 my %AllIncompleteSymbols;
255 my %AllUnusedSymbols;
256 my %AllDocumentedSymbols;
258 # Undeclared yet documented symbols
259 my %UndeclaredSymbols;
261 # These global arrays store GObject, subclasses and the hierarchy.
268 # holds the symbols which are mentioned in $MODULE-sections.txt and in which
269 # section they are defined
274 # collects index entries
275 my %IndexEntriesFull;
276 my %IndexEntriesSince;
277 my %IndexEntriesDeprecated;
279 # Standard C preprocessor directives, which we ignore for '#' abbreviations.
280 my %PreProcessorDirectives;
281 $PreProcessorDirectives{"assert"} = 1;
282 $PreProcessorDirectives{"define"} = 1;
283 $PreProcessorDirectives{"elif"} = 1;
284 $PreProcessorDirectives{"else"} = 1;
285 $PreProcessorDirectives{"endif"} = 1;
286 $PreProcessorDirectives{"error"} = 1;
287 $PreProcessorDirectives{"if"} = 1;
288 $PreProcessorDirectives{"ifdef"} = 1;
289 $PreProcessorDirectives{"ifndef"} = 1;
290 $PreProcessorDirectives{"include"} = 1;
291 $PreProcessorDirectives{"line"} = 1;
292 $PreProcessorDirectives{"pragma"} = 1;
293 $PreProcessorDirectives{"unassert"} = 1;
294 $PreProcessorDirectives{"undef"} = 1;
295 $PreProcessorDirectives{"warning"} = 1;
297 # remember used annotation (to write minimal glossary)
300 # the annotations are defined at:
301 # http://live.gnome.org/GObjectIntrospection/Annotations
302 my %AnnotationDefinition = (
303 'allow-none' => "NULL is ok, both for passing and for returning.",
304 'array' => "Parameter points to an array of items.",
305 'closure' => "This parameter is a 'user_data', for callbacks; many bindings can pass NULL here.",
306 'default' => "Default parameter value (for in case the <acronym>shadows</acronym>-to function has less parameters).",
307 'element-type' => "Generics and defining elements of containers and arrays.",
308 'error-domains' => "Typed errors. Similar to throws in Java.",
309 'in' => "Parameter for input. Default is <acronym>transfer none</acronym>.",
310 'inout' => "Parameter for input and for returning results. Default is <acronym>transfer full</acronym>.",
311 'in-out' => "Parameter for input and for returning results. Default is <acronym>transfer full</acronym>.",
312 'not-error' => "A GError parameter is not to be handled like a normal GError.",
313 'out' => "Parameter for returning results. Default is <acronym>transfer full</acronym>.",
314 'transfer container' => "Free data container after the code is done.",
315 'transfer full' => "Free data after the code is done.",
316 'transfer none' => "Don't free data after the code is done.",
317 'scope call' => "The callback is valid only during the call to the method.",
318 'scope async' => "The callback is valid until first called.",
319 'scope notified' => "The callback is valid until the GDestroyNotify argument is called.",
320 'type' => "Override the parsed C type with given type"
323 # Create the root DocBook output directory if it doens't exist.
324 if (! -e $SGML_OUTPUT_DIR) {
325 mkdir ("$SGML_OUTPUT_DIR", 0777)
326 || die "Can't create directory: $SGML_OUTPUT_DIR";
329 # Function and other declaration output settings.
330 my $RETURN_TYPE_FIELD_WIDTH = 20;
331 my $SYMBOL_FIELD_WIDTH = 36;
332 my $SIGNAL_FIELD_WIDTH = 16;
333 my $PARAM_FIELD_COUNT = 2;
335 &ReadKnownSymbols ("$ROOT_DIR/$MODULE-sections.txt");
336 &ReadSignalsFile ($SIGNALS_FILE);
337 &ReadArgsFile ($ARGS_FILE);
338 &ReadObjectHierarchy;
342 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-decl.txt", 0);
343 if (-f "$ROOT_DIR/$MODULE-overrides.txt") {
344 &ReadDeclarationsFile ("$ROOT_DIR/$MODULE-overrides.txt", 1);
347 for my $dir (@SOURCE_DIRS) {
348 &ReadSourceDocumentation ($dir);
351 my $changed = &OutputSGML ("$ROOT_DIR/$MODULE-sections.txt");
353 # If any of the DocBook SGML files have changed, update the timestamp file (so
354 # it can be used for Makefile dependencies).
355 if ($changed || ! -e "$ROOT_DIR/sgml.stamp") {
357 # try to detect the common prefix
358 # GtkWidget, GTK_WIDGET, gtk_widget -> gtk
359 if ($NAME_SPACE eq "") {
366 foreach my $symbol (keys(%IndexEntriesFull)) {
367 if(($NAME_SPACE eq "") || $symbol =~ /^$NAME_SPACE/i) {
368 if (length($symbol)>$pos) {
369 $letter=substr($symbol,$pos,1);
370 # stop prefix scanning
371 if ($letter eq "_") {
375 # Should we also stop on a uppercase char, if last was lowercase
376 # GtkWidget, if we have the 'W' and had the 't' before
377 # or should we count upper and lowercase, and stop one 2nd uppercase, if we already had a lowercase
378 # GtkWidget, the 'W' would be the 2nd uppercase and with 't','k' we had lowercase chars before
379 # need to recound each time as this is per symbol
380 $prefix{uc($letter)}++;
384 if ($letter ne "" && $letter ne "_") {
387 foreach $letter (keys(%prefix)) {
388 #print "$letter: $prefix{$letter}.\n";
389 if ($prefix{$letter}>$maxsymbols) {
391 $maxsymbols=$prefix{$letter};
394 $ratio = scalar(keys(%IndexEntriesFull)) / $prefix{$maxletter};
395 #print "most symbols start with $maxletter, that is ". (100 * $ratio) ." %\n";
398 $NAME_SPACE .= $maxletter;
405 } while ($ratio > 0.9);
406 #print "most symbols start with $NAME_SPACE\n";
410 &OutputDeprecatedIndex;
412 &OutputAnnotationGlossary;
414 open (TIMESTAMP, ">$ROOT_DIR/sgml.stamp")
415 || die "Can't create $ROOT_DIR/sgml.stamp: $!";
416 print (TIMESTAMP "timestamp");
420 #############################################################################
421 # Function : OutputObjectList
422 # Description : This outputs the alphabetical list of objects, in a columned
424 # FIXME: Currently this also outputs ancestor objects
425 # which may not actually be in this module.
427 #############################################################################
429 sub OutputObjectList {
432 # FIXME: use $OUTPUT_FORMAT
433 # my $old_object_index = "$SGML_OUTPUT_DIR/object_index.$OUTPUT_FORMAT";
434 my $old_object_index = "$SGML_OUTPUT_DIR/object_index.sgml";
435 my $new_object_index = "$SGML_OUTPUT_DIR/object_index.new";
437 open (OUTPUT, ">$new_object_index")
438 || die "Can't create $new_object_index: $!";
440 if ($OUTPUT_FORMAT eq "xml") {
441 my $header = $doctype_header;
443 $header =~ s/<!DOCTYPE \w+/<!DOCTYPE informaltable/;
444 print (OUTPUT "$header");
447 print (OUTPUT <<EOF);
448 <informaltable pgwide="1" frame="none">
449 <tgroup cols="$cols">
450 <colspec colwidth="1*"${empty_element_end}
451 <colspec colwidth="1*"${empty_element_end}
452 <colspec colwidth="1*"${empty_element_end}
458 foreach $object (sort (@Objects)) {
459 my $xref = &MakeXRef ($object);
460 if ($count % $cols == 0) { print (OUTPUT "<row>\n"); }
461 print (OUTPUT "<entry>$xref</entry>\n");
462 if ($count % $cols == ($cols - 1)) { print (OUTPUT "</row>\n"); }
466 # emit an empty row, since empty tables are invalid
467 print (OUTPUT "<row><entry> </entry></row>\n");
470 if ($count % $cols > 0) {
471 print (OUTPUT "</row>\n");
475 print (OUTPUT <<EOF);
476 </tbody></tgroup></informaltable>
480 &UpdateFileIfChanged ($old_object_index, $new_object_index, 0);
484 #############################################################################
485 # Function : OutputSGML
486 # Description : This collects the output for each section of the docs, and
487 # outputs each file when the end of the section is found.
488 # Arguments : $file - the $MODULE-sections.txt file which contains all of
489 # the functions/macros/structs etc. being documented, organised
490 # into sections and subsections.
491 #############################################################################
496 #print "Reading: $file\n";
498 || die "Can't open $file: $!";
501 my $book_bottom = "";
502 my $includes = (defined $DEFAULT_INCLUDES) ? $DEFAULT_INCLUDES : "";
503 my $section_includes = "";
512 my $signals_synop = "";
513 my $signals_desc = "";
515 my $child_args_synop = "";
516 my $style_args_synop = "";
518 my $child_args_desc = "";
519 my $style_args_desc = "";
522 my $implementations = "";
523 my $prerequisites = "";
525 my @file_objects = ();
527 my %symbol_def_line = ();
529 # merge the source docs, in case there are no templates
530 &MergeSourceDocumentation;
536 } elsif (m/^<SECTION>/) {
542 %symbol_def_line = ();
544 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
548 } elsif (m/^<SUBSECTION>/) {
550 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
552 #print "Section: $title\n";
554 # We don't want warnings if object & class structs aren't used.
555 $DeclarationOutput{$title} = 1;
556 $DeclarationOutput{"${title}Class"} = 1;
557 $DeclarationOutput{"${title}Iface"} = 1;
558 $DeclarationOutput{"${title}Interface"} = 1;
560 } elsif (m/^<FILE>(.*)<\/FILE>/) {
562 if (! defined $templates{$filename}) {
563 if (&ReadTemplateFile ("$TMPL_DIR/$filename", 1)) {
564 &MergeSourceDocumentation;
565 $templates{$filename}=$.;
568 &LogWarning ($file, $., "Double <FILE>$filename</FILE> entry. ".
569 "Previous occurrence on line ".$templates{$filename}.".");
571 if (($title eq "") and (defined $SourceSymbolDocs{"$TMPL_DIR/$filename:Title"})) {
572 $title = $SourceSymbolDocs{"$TMPL_DIR/$filename:Title"};
573 # Remove trailing blanks
577 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
579 $section_includes = $1;
581 if (defined $DEFAULT_INCLUDES) {
582 &LogWarning ($file, $., "Default <INCLUDE> being overridden by command line option.");
589 } elsif (m/^<\/SECTION>/) {
590 #print "End of section: $title\n";
591 if ($num_symbols > 0) {
593 if ($OUTPUT_FORMAT eq "xml") {
594 $book_bottom .= " <xi:include href=\"xml/$filename.xml\"/>\n";
596 $book_top.="<!ENTITY $section_id SYSTEM \"sgml/$filename.sgml\">\n";
597 $book_bottom .= " &$section_id;\n";
600 if (defined ($SourceSymbolDocs{"$TMPL_DIR/$filename:Include"})) {
601 if ($section_includes) {
602 &LogWarning ($file, $., "Section <INCLUDE> being overridden by inline comments.");
604 $section_includes = $SourceSymbolDocs{"$TMPL_DIR/$filename:Include"};
606 if ($section_includes eq "") {
607 $section_includes = $includes;
610 $signals_synop =~ s/^\n*//g;
611 $signals_synop =~ s/\n+$/\n/g;
612 if ($signals_synop ne '') {
613 $signals_synop = <<EOF;
614 <refsect1 id="$section_id.signals" role="signal_proto">
615 <title role="signal_proto.title">Signals</title>
617 ${signals_synop}</synopsis>
620 $signals_desc =~ s/^\n*//g;
621 $signals_desc =~ s/\n+$/\n/g;
622 $signals_desc =~ s/(\s|\n)+$//ms;
623 $signals_desc = <<EOF;
624 <refsect1 id="$section_id.signal-details" role="signals">
625 <title role="signals.title">Signal Details</title>
631 $args_synop =~ s/^\n*//g;
632 $args_synop =~ s/\n+$/\n/g;
633 if ($args_synop ne '') {
635 <refsect1 id="$section_id.properties" role="properties">
636 <title role="properties.title">Properties</title>
638 ${args_synop}</synopsis>
641 $args_desc =~ s/^\n*//g;
642 $args_desc =~ s/\n+$/\n/g;
643 $args_desc =~ s/(\s|\n)+$//ms;
645 <refsect1 id="$section_id.property-details" role="property_details">
646 <title role="property_details.title">Property Details</title>
652 $child_args_synop =~ s/^\n*//g;
653 $child_args_synop =~ s/\n+$/\n/g;
654 if ($child_args_synop ne '') {
655 $args_synop .= <<EOF;
656 <refsect1 id="$section_id.child-properties" role="child_properties">
657 <title role="child_properties.title">Child Properties</title>
659 ${child_args_synop}</synopsis>
662 $child_args_desc =~ s/^\n*//g;
663 $child_args_desc =~ s/\n+$/\n/g;
664 $child_args_desc =~ s/(\s|\n)+$//ms;
666 <refsect1 id="$section_id.child-property-details" role="child_property_details">
667 <title role="child_property_details.title">Child Property Details</title>
673 $style_args_synop =~ s/^\n*//g;
674 $style_args_synop =~ s/\n+$/\n/g;
675 if ($style_args_synop ne '') {
676 $args_synop .= <<EOF;
677 <refsect1 id="$section_id.style-properties" role="style_properties">
678 <title role="style_properties.title">Style Properties</title>
680 ${style_args_synop}</synopsis>
683 $style_args_desc =~ s/^\n*//g;
684 $style_args_desc =~ s/\n+$/\n/g;
685 $style_args_desc =~ s/(\s|\n)+$//ms;
687 <refsect1 id="$section_id.style-property-details" role="style_properties_details">
688 <title role="style_properties_details.title">Style Property Details</title>
694 $hierarchy =~ s/^\n*//g;
695 $hierarchy =~ s/\n+$/\n/g;
696 $hierarchy =~ s/(\s|\n)+$//ms;
697 if ($hierarchy ne "") {
699 <refsect1 id="$section_id.object-hierarchy" role="object_hierarchy">
700 <title role="object_hierarchy.title">Object Hierarchy</title>
706 $interfaces =~ s/^\n*//g;
707 $interfaces =~ s/\n+$/\n/g;
708 $interfaces =~ s/(\s|\n)+$//ms;
709 if ($interfaces ne "") {
711 <refsect1 id="$section_id.implemented-interfaces" role="impl_interfaces">
712 <title role="impl_interfaces.title">Implemented Interfaces</title>
718 $implementations =~ s/^\n*//g;
719 $implementations =~ s/\n+$/\n/g;
720 $implementations =~ s/(\s|\n)+$//ms;
721 if ($implementations ne "") {
722 $implementations = <<EOF;
723 <refsect1 id="$section_id.implementations" role="implementations">
724 <title role="implementations.title">Known Implementations</title>
730 $prerequisites =~ s/^\n*//g;
731 $prerequisites =~ s/\n+$/\n/g;
732 $prerequisites =~ s/(\s|\n)+$//ms;
733 if ($prerequisites ne "") {
734 $prerequisites = <<EOF;
735 <refsect1 id="$section_id.prerequisites" role="prerequisites">
736 <title role="prerequisites.title">Prerequisites</title>
742 $derived =~ s/^\n*//g;
743 $derived =~ s/\n+$/\n/g;
744 $derived =~ s/(\s|\n)+$//ms;
745 if ($derived ne "") {
747 <refsect1 id="$section_id.derived-interfaces" role="derived_interfaces">
748 <title role="derived_interfaces.title">Known Derived Interfaces</title>
754 $synopsis =~ s/^\n*//g;
755 $synopsis =~ s/\n+$/\n/g;
756 my $file_changed = &OutputSGMLFile ($filename, $title, $section_id,
758 \$synopsis, \$details,
759 \$signals_synop, \$signals_desc,
760 \$args_synop, \$args_desc,
761 \$hierarchy, \$interfaces,
763 \$prerequisites, \$derived,
773 $section_includes = "";
777 $child_args_synop = "";
778 $style_args_synop = "";
780 $child_args_desc = "";
781 $style_args_desc = "";
784 $implementations = "";
788 } elsif (m/^(\S+)/) {
790 #print " Symbol: $symbol\n";
792 # check for duplicate entries
793 if (! defined $symbol_def_line{$symbol}) {
794 my $declaration = $Declarations{$symbol};
795 if (defined ($declaration)) {
796 # We don't want standard macros/functions of GObjects,
797 # or private declarations.
798 if ($subsection ne "Standard" && $subsection ne "Private") {
799 if (&CheckIsObject ($symbol)) {
800 push @file_objects, $symbol;
802 my ($synop, $desc) = &OutputDeclaration ($symbol,
804 my ($sig_synop, $sig_desc) = &GetSignals ($symbol);
805 my ($arg_synop, $child_arg_synop, $style_arg_synop,
806 $arg_desc, $child_arg_desc, $style_arg_desc) = &GetArgs ($symbol);
807 my $hier = &GetHierarchy ($symbol);
808 my $ifaces = &GetInterfaces ($symbol);
809 my $impls = &GetImplementations ($symbol);
810 my $prereqs = &GetPrerequisites ($symbol);
811 my $der = &GetDerived ($symbol);
814 $signals_synop .= $sig_synop;
815 $signals_desc .= $sig_desc;
816 $args_synop .= $arg_synop;
817 $child_args_synop .= $child_arg_synop;
818 $style_args_synop .= $style_arg_synop;
819 $args_desc .= $arg_desc;
820 $child_args_desc .= $child_arg_desc;
821 $style_args_desc .= $style_arg_desc;
823 $interfaces .= $ifaces;
824 $implementations .= $impls;
825 $prerequisites .= $prereqs;
829 # Note that the declaration has been output.
830 $DeclarationOutput{$symbol} = 1;
831 } elsif ($subsection ne "Standard" && $subsection ne "Private") {
832 $UndeclaredSymbols{$symbol} = 1;
833 &LogWarning ($file, $., "No declaration found for $symbol.");
836 $symbol_def_line{$symbol}=$.;
838 if ($section_id eq "") {
839 if($title eq "" && $filename eq "") {
840 &LogWarning ($file, $., "Section has no title and no file.");
842 # FIXME: one of those would be enough
843 # filename should be an internal detail for gtk-doc
846 } elsif ($filename eq "") {
849 $filename =~ s/\s/_/g;
851 $section_id = $SourceSymbolDocs{"$TMPL_DIR/$filename:Section_Id"};
852 if (defined ($section_id) && $section_id !~ m/^\s*$/) {
853 # Remove trailing blanks and use as is
854 $section_id =~ s/\s+$//;
855 } elsif (&CheckIsObject ($title)) {
856 # GObjects use their class name as the ID.
857 $section_id = &CreateValidSGMLID ($title);
859 $section_id = &CreateValidSGMLID ("$MODULE-$title");
862 $SymbolSection{$symbol}=$title;
863 $SymbolSectionId{$symbol}=$section_id;
866 &LogWarning ($file, $., "Double symbol entry for $symbol. ".
867 "Previous occurrence on line ".$symbol_def_line{$symbol}.".");
873 &OutputMissingDocumentation;
874 &OutputUndeclaredSymbols;
875 &OutputUnusedSymbols;
877 if ($OUTPUT_ALL_SYMBOLS) {
880 if ($OUTPUT_SYMBOLS_WITHOUT_SINCE) {
881 &OutputSymbolsWithoutSince;
884 for $filename (split (' ', $EXPAND_CONTENT_FILES)) {
885 my $file_changed = &OutputExtraFile ($filename);
891 &OutputBook ($book_top, $book_bottom);
896 #############################################################################
897 # Function : OutputIndex
898 # Description : This writes an indexlist that can be included into the main-
899 # document into an <index> tag.
900 #############################################################################
903 my ($basename, $apiindexref ) = @_;
904 my %apiindex = %{$apiindexref};
905 my $old_index = "$SGML_OUTPUT_DIR/$basename.xml";
906 my $new_index = "$SGML_OUTPUT_DIR/$basename.new";
907 my $lastletter = " ";
912 open (OUTPUT, ">$new_index")
913 || die "Can't create $new_index";
915 my $header = $doctype_header;
916 $header =~ s/<!DOCTYPE \w+/<!DOCTYPE indexdiv/;
918 print (OUTPUT "$header<indexdiv>\n");
920 #print "generate $basename index (".%apiindex." entries)\n";
922 # do a case insensitive sort while chopping off the prefix
924 sort { $$a{criteria} cmp $$b{criteria} }
925 map { my $x = uc($_); $x =~ s/^$NAME_SPACE\_?(.*)/$1/i; { criteria => $x, original => $_, short => $1 } }
928 $symbol = $$hash{original};
929 if (defined($$hash{short})) {
930 $short_symbol = $$hash{short};
932 $short_symbol = $symbol;
935 # generate a short symbol description
936 my $symbol_desc = "";
937 my $symbol_section = "";
938 my $symbol_section_id = "";
939 my $symbol_type = "";
940 if (defined($DeclarationTypes{$symbol})) {
941 $symbol_type = lc($DeclarationTypes{$symbol});
943 if ($symbol_type eq "") {
944 #print "trying symbol $symbol\n";
945 if ($symbol =~ m/(.*)::(.*)/) {
949 #print " trying object signal ${oname}:$osym in ".$#SignalNames." signals\n";
950 for ($i = 0; $i <= $#SignalNames; $i++) {
951 if ($SignalNames[$i] eq $osym) {
952 $symbol_type = "object signal";
953 if (defined($SymbolSection{$oname})) {
954 $symbol_section = $SymbolSection{$oname};
955 $symbol_section_id = $SymbolSectionId{$oname};
960 } elsif ($symbol =~ m/(.*):(.*)/) {
964 #print " trying object property ${oname}::$osym in ".$#ArgNames." properties\n";
965 for ($i = 0; $i <= $#ArgNames; $i++) {
966 #print " ".$ArgNames[$i]."\n";
967 if ($ArgNames[$i] eq $osym) {
968 $symbol_type = "object property";
969 if (defined($SymbolSection{$oname})) {
970 $symbol_section = $SymbolSection{$oname};
971 $symbol_section_id = $SymbolSectionId{$oname};
978 if (defined($SymbolSection{$symbol})) {
979 $symbol_section = $SymbolSection{$symbol};
980 $symbol_section_id = $SymbolSectionId{$symbol};
983 if ($symbol_type ne "") {
984 $symbol_desc=", $symbol_type";
985 if ($symbol_section ne "") {
986 $symbol_desc.=" in <link linkend=\"$symbol_section_id\">$symbol_section</link>";
987 #$symbol_desc.=" in ". &ExpandAbbreviations($symbol, "#$symbol_section");
991 my $curletter = uc(substr($short_symbol,0,1));
992 my $id = $apiindex{$symbol};
994 #print " add symbol $symbol with $id to index in section $curletter\n";
996 if ($curletter ne $lastletter) {
997 $lastletter = $curletter;
1000 print (OUTPUT "</indexdiv>\n");
1002 print (OUTPUT "<indexdiv><title>$curletter</title>\n");
1006 print (OUTPUT <<EOF);
1007 <indexentry><primaryie linkends="$id"><link linkend="$id">$symbol</link>$symbol_desc</primaryie></indexentry>
1011 if ($divopen == 1) {
1012 print (OUTPUT "</indexdiv>\n");
1014 print (OUTPUT "</indexdiv>\n");
1017 &UpdateFileIfChanged ($old_index, $new_index, 0);
1021 #############################################################################
1022 # Function : OutputIndexFull
1023 # Description : This writes the full api indexlist that can be included into the
1024 # main document into an <index> tag.
1025 #############################################################################
1027 sub OutputIndexFull {
1028 &OutputIndex ("api-index-full", \%IndexEntriesFull);
1032 #############################################################################
1033 # Function : OutputDeprecatedIndex
1034 # Description : This writes the deprecated api indexlist that can be included
1035 # into the main document into an <index> tag.
1036 #############################################################################
1038 sub OutputDeprecatedIndex {
1039 &OutputIndex ("api-index-deprecated", \%IndexEntriesDeprecated);
1043 #############################################################################
1044 # Function : OutputSinceIndexes
1045 # Description : This writes the 'since' api indexlists that can be included into
1046 # the main document into an <index> tag.
1047 #############################################################################
1049 sub OutputSinceIndexes {
1050 my @sinces = keys %{{ map { $_ => 1 } values %Since }};
1052 foreach my $version (@sinces) {
1053 #print "Since : [$version]\n";
1054 # TODO make filtered hash
1055 #my %index = grep { $Since{$_} eq $version } %IndexEntriesSince;
1056 my %index = map { $_ => $IndexEntriesSince{$_} } grep { $Since{$_} eq $version } keys %IndexEntriesSince;
1058 &OutputIndex ("api-index-$version", \%index);
1062 #############################################################################
1063 # Function : OutputAnnotationGlossary
1064 # Description : This writes a glossary of the used annotation terms into a
1065 # separate glossary file that can be included into the main
1067 #############################################################################
1069 sub OutputAnnotationGlossary {
1070 my $old_glossary = "$SGML_OUTPUT_DIR/annotation-glossary.xml";
1071 my $new_glossary = "$SGML_OUTPUT_DIR/annotation-glossary.new";
1072 my $lastletter = " ";
1075 # if there are no annotations used return
1076 return if (! keys(%AnnotationsUsed));
1078 # add acronyms that are referenced from acronym text
1080 foreach my $annotation (keys(%AnnotationsUsed)) {
1081 if(defined($AnnotationDefinition{$annotation})) {
1082 if($AnnotationDefinition{$annotation} =~ m/<acronym>([\w ]+)<\/acronym>/) {
1083 if (!exists($AnnotationsUsed{$1})) {
1084 $AnnotationsUsed{$1} = 1;
1091 open (OUTPUT, ">$new_glossary")
1092 || die "Can't create $new_glossary";
1094 my $header = $doctype_header;
1095 $header =~ s/<!DOCTYPE \w+/<!DOCTYPE glossary/;
1097 print (OUTPUT <<EOF);
1099 <glossary id="annotation-glossary">
1100 <title>Annotation Glossary</title>
1103 foreach my $annotation (keys(%AnnotationsUsed)) {
1104 if(defined($AnnotationDefinition{$annotation})) {
1105 my $def = $AnnotationDefinition{$annotation};
1106 my $curletter = uc(substr($annotation,0,1));
1108 if ($curletter ne $lastletter) {
1109 $lastletter = $curletter;
1111 if ($divopen == 1) {
1112 print (OUTPUT "</glossdiv>\n");
1114 print (OUTPUT "<glossdiv><title>$curletter</title>\n");
1117 print (OUTPUT <<EOF);
1119 <glossterm><anchor id="annotation-glossterm-$annotation"/>$annotation</glossterm>
1128 if ($divopen == 1) {
1129 print (OUTPUT "</glossdiv>\n");
1131 print (OUTPUT "</glossary>\n");
1134 &UpdateFileIfChanged ($old_glossary, $new_glossary, 0);
1137 #############################################################################
1138 # Function : ReadKnownSymbols
1139 # Description : This collects the names of non-private symbols from the
1140 # $MODULE-sections.txt file.
1141 # Arguments : $file - the $MODULE-sections.txt file which contains all of
1142 # the functions/macros/structs etc. being documented, organised
1143 # into sections and subsections.
1144 #############################################################################
1146 sub ReadKnownSymbols {
1149 my $subsection = "";
1151 #print "Reading: $file\n";
1153 || die "Can't open $file: $!";
1159 } elsif (m/^<SECTION>/) {
1162 } elsif (m/^<SUBSECTION\s*(.*)>/i) {
1165 } elsif (m/^<SUBSECTION>/) {
1168 } elsif (m/^<TITLE>(.*)<\/TITLE>/) {
1171 } elsif (m/^<FILE>(.*)<\/FILE>/) {
1172 $KnownSymbols{"$TMPL_DIR/$1:Long_Description"} = 1;
1173 $KnownSymbols{"$TMPL_DIR/$1:Short_Description"} = 1;
1176 } elsif (m/^<INCLUDE>(.*)<\/INCLUDE>/) {
1179 } elsif (m/^<\/SECTION>/) {
1182 } elsif (m/^(\S+)/) {
1185 if ($subsection ne "Standard" && $subsection ne "Private") {
1186 $KnownSymbols{$symbol} = 1;
1189 $KnownSymbols{$symbol} = 0;
1197 #############################################################################
1198 # Function : OutputDeclaration
1199 # Description : Returns the synopsis and detailed description DocBook
1200 # describing one function/macro etc.
1201 # Arguments : $symbol - the name of the function/macro begin described.
1202 # $declaration - the declaration of the function/macro.
1203 #############################################################################
1205 sub OutputDeclaration {
1206 my ($symbol, $declaration) = @_;
1208 my $type = $DeclarationTypes {$symbol};
1209 if ($type eq 'MACRO') {
1210 return &OutputMacro ($symbol, $declaration);
1211 } elsif ($type eq 'TYPEDEF') {
1212 return &OutputTypedef ($symbol, $declaration);
1213 } elsif ($type eq 'STRUCT') {
1214 return &OutputStruct ($symbol, $declaration);
1215 } elsif ($type eq 'ENUM') {
1216 return &OutputEnum ($symbol, $declaration);
1217 } elsif ($type eq 'UNION') {
1218 return &OutputUnion ($symbol, $declaration);
1219 } elsif ($type eq 'VARIABLE') {
1220 return &OutputVariable ($symbol, $declaration);
1221 } elsif ($type eq 'FUNCTION') {
1222 return &OutputFunction ($symbol, $declaration, $type);
1223 } elsif ($type eq 'USER_FUNCTION') {
1224 return &OutputFunction ($symbol, $declaration, $type);
1226 die "Unknown symbol type";
1231 #############################################################################
1232 # Function : OutputSymbolTraits
1233 # Description : Returns the Since and StabilityLevel paragraphs for a symbol.
1234 # Arguments : $symbol - the name of the function/macro begin described.
1235 #############################################################################
1237 sub OutputSymbolTraits {
1241 if (exists $Since{$symbol}) {
1242 $desc .= "<para role=\"since\">Since $Since{$symbol}</para>";
1244 if (exists $StabilityLevel{$symbol}) {
1245 $desc .= "<para role=\"stability\">Stability Level: $StabilityLevel{$symbol}</para>";
1250 #############################################################################
1251 # Function : Outpu{Symbol,Section}ExtraLinks
1252 # Description : Returns extralinks for the symbol (if enabled).
1253 # Arguments : $symbol - the name of the function/macro begin described.
1254 #############################################################################
1258 return undef unless defined $text;
1260 # Build a char to hex map
1263 $escapes{chr($_)} = sprintf("%%%02X", $_);
1266 # Default unsafe characters. RFC 2732 ^(uric - reserved)
1267 $text =~ s/([^A-Za-z0-9\-_.!~*'()])/$escapes{$1}/g;
1272 sub OutputSymbolExtraLinks {
1276 if (0) { # NEW FEATURE: needs configurability
1277 my $sstr = &uri_escape($symbol);
1278 my $mstr = &uri_escape($MODULE);
1280 <ulink role="extralinks" url="http://www.google.com/codesearch?q=$sstr">code search</ulink>
1281 <ulink role="extralinks" url="http://library.gnome.org/edit?module=$mstr&symbol=$sstr">edit documentation</ulink>
1287 sub OutputSectionExtraLinks {
1288 my ($symbol,$docsymbol) = @_;
1291 if (0) { # NEW FEATURE: needs configurability
1292 my $sstr = &uri_escape($symbol);
1293 my $mstr = &uri_escape($MODULE);
1294 my $dsstr = &uri_escape($docsymbol);
1296 <ulink role="extralinks" url="http://www.google.com/codesearch?q=$sstr">code search</ulink>
1297 <ulink role="extralinks" url="http://library.gnome.org/edit?module=$mstr&symbol=$dsstr">edit documentation</ulink>
1304 #############################################################################
1305 # Function : OutputMacro
1306 # Description : Returns the synopsis and detailed description of a macro.
1307 # Arguments : $symbol - the macro.
1308 # $declaration - the declaration of the macro.
1309 #############################################################################
1312 my ($symbol, $declaration) = @_;
1313 my $id = &CreateValidSGMLID ($symbol);
1314 my $condition = &MakeConditionDescription ($symbol);
1315 my $synop = &MakeReturnField("#define") . "<link linkend=\"$id\">$symbol</link>";
1318 my @fields = ParseMacroDeclaration($declaration, \&CreateValidSGML);
1319 my $title = $symbol . (@fields ? "()" : "");
1321 $desc = "<refsect2 id=\"$id\" role=\"macro\"$condition>\n<title>$title</title>\n";
1322 $desc .= MakeIndexterms($symbol, $id);
1324 $desc .= OutputSymbolExtraLinks($symbol);
1327 if (length ($symbol) < $SYMBOL_FIELD_WIDTH) {
1328 $synop .= (' ' x ($SYMBOL_FIELD_WIDTH - length ($symbol)));
1332 for (my $i = 1; $i <= $#fields; $i += 2) {
1333 my $field_name = $fields[$i];
1336 $synop .= "$field_name";
1339 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
1347 # Don't output the macro definition if is is a conditional macro or it
1348 # looks like a function, i.e. starts with "g_" or "_?gnome_", or it is
1349 # longer than 2 lines, otherwise we get lots of complicated macros like
1351 if (!defined ($DeclarationConditional{$symbol}) && ($symbol !~ m/^g_/)
1352 && ($symbol !~ m/^_?gnome_/) && (($declaration =~ tr/\n//) < 2)) {
1353 my $decl_out = &CreateValidSGML ($declaration);
1354 $desc .= "<programlisting>$decl_out</programlisting>\n";
1356 $desc .= "<programlisting>" . &MakeReturnField("#define") . "$symbol";
1357 if ($declaration =~ m/^\s*#\s*define\s+\w+(\([^\)]*\))/) {
1359 my $pad = ' ' x ($RETURN_TYPE_FIELD_WIDTH - length ("#define "));
1360 # Align each line so that if should all line up OK.
1361 $args =~ s/\n/\n$pad/gm;
1362 $desc .= &CreateValidSGML ($args);
1364 $desc .= "</programlisting>\n";
1367 $desc .= &MakeDeprecationNote($symbol);
1369 my $parameters = &OutputParamDescriptions ("MACRO", $symbol, @fields);
1370 my $parameters_output = 0;
1372 if (defined ($SymbolDocs{$symbol})) {
1373 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1375 # Try to insert the parameter table at the author's desired position.
1376 # Otherwise we need to tag it onto the end.
1377 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
1378 $parameters_output = 1;
1380 $desc .= $symbol_docs;
1383 if ($parameters_output == 0) {
1384 $desc .= $parameters;
1387 $desc .= OutputSymbolTraits ($symbol);
1388 $desc .= "</refsect2>\n";
1389 return ($synop, $desc);
1393 #############################################################################
1394 # Function : OutputTypedef
1395 # Description : Returns the synopsis and detailed description of a typedef.
1396 # Arguments : $symbol - the typedef.
1397 # $declaration - the declaration of the typedef,
1398 # e.g. 'typedef unsigned int guint;'
1399 #############################################################################
1402 my ($symbol, $declaration) = @_;
1403 my $id = &CreateValidSGMLID ($symbol);
1404 my $condition = &MakeConditionDescription ($symbol);
1405 my $synop = &MakeReturnField("typedef") . "<link linkend=\"$id\">$symbol</link>;\n";
1406 my $desc = "<refsect2 id=\"$id\" role=\"typedef\"$condition>\n<title>$symbol</title>\n";
1408 $desc .= MakeIndexterms($symbol, $id);
1410 $desc .= OutputSymbolExtraLinks($symbol);
1412 if (!defined ($DeclarationConditional{$symbol})) {
1413 my $decl_out = &CreateValidSGML ($declaration);
1414 $desc .= "<programlisting>$decl_out</programlisting>\n";
1417 $desc .= &MakeDeprecationNote($symbol);
1419 if (defined ($SymbolDocs{$symbol})) {
1420 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1422 $desc .= OutputSymbolTraits ($symbol);
1423 $desc .= "</refsect2>\n";
1424 return ($synop, $desc);
1428 #############################################################################
1429 # Function : OutputStruct
1430 # Description : Returns the synopsis and detailed description of a struct.
1431 # We check if it is a object struct, and if so we only output
1432 # parts of it that are noted as public fields.
1433 # We also use a different SGML ID for object structs, since the
1434 # original ID is used for the entire RefEntry.
1435 # Arguments : $symbol - the struct.
1436 # $declaration - the declaration of the struct.
1437 #############################################################################
1440 my ($symbol, $declaration) = @_;
1442 my $is_object_struct = 0;
1443 my $default_to_public = 1;
1444 if (&CheckIsObject ($symbol)) {
1445 #print "Found struct gtype: $symbol\n";
1447 $default_to_public = 0;
1453 $id = &CreateValidSGMLID ($symbol . "_struct");
1454 $condition = &MakeConditionDescription ($symbol . "_struct");
1456 $id = &CreateValidSGMLID ($symbol);
1457 $condition = &MakeConditionDescription ($symbol);
1460 # Determine if it is a simple struct or it also has a typedef.
1461 my $has_typedef = 0;
1462 if ($StructHasTypedef{$symbol} || $declaration =~ m/^\s*typedef\s+/) {
1469 # For structs with typedefs we just output the struct name.
1470 $synop = &MakeReturnField("") . "<link linkend=\"$id\">$symbol</link>;\n";
1471 $desc = "<refsect2 id=\"$id\" role=\"struct\"$condition>\n<title>$symbol</title>\n";
1473 $synop = &MakeReturnField("struct") . "<link linkend=\"$id\">$symbol</link>;\n";
1474 $desc = "<refsect2 id=\"$id\" role=\"struct\"$condition>\n<title>struct $symbol</title>\n";
1477 $desc .= MakeIndexterms($symbol, $id);
1479 $desc .= OutputSymbolExtraLinks($symbol);
1481 # Form a pretty-printed, private-data-removed form of the declaration
1484 if ($declaration =~ m/^\s*$/) {
1485 #print "Found opaque struct: $symbol\n";
1486 $decl_out = "typedef struct _$symbol $symbol;";
1487 } elsif ($declaration =~ m/^\s*struct\s+\w+\s*;\s*$/) {
1488 #print "Found opaque struct: $symbol\n";
1489 $decl_out = "struct $symbol;";
1491 my $public = $default_to_public;
1492 my $new_declaration = "";
1494 my $decl = $declaration;
1496 if ($decl =~ m/^\s*(typedef\s+)?struct\s*\w*\s*(?:\/\*.*\*\/)?\s*{(.*)}\s*\w*\s*;\s*$/s) {
1497 my $struct_contents = $2;
1499 foreach $decl_line (split (/\n/, $struct_contents)) {
1500 #print "Struct line: $decl_line\n";
1501 if ($decl_line =~ m%/\*\s*<\s*public\s*>\s*\*/%) {
1503 } elsif ($decl_line =~ m%/\*\s*<\s*(private|protected)\s*>\s*\*/%) {
1506 $new_declaration .= $decl_line . "\n";
1510 if ($new_declaration) {
1511 # Strip any blank lines off the ends.
1512 $new_declaration =~ s/^\s*\n//;
1513 $new_declaration =~ s/\n\s*$/\n/;
1516 $decl_out = "typedef struct {\n" . $new_declaration
1519 $decl_out = "struct $symbol {\n" . $new_declaration
1524 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1525 "Couldn't parse struct:\n$declaration");
1528 # If we couldn't parse the struct or it was all private, output an
1529 # empty struct declaration.
1530 if ($decl_out eq "") {
1532 $decl_out = "typedef struct _$symbol $symbol;";
1534 $decl_out = "struct $symbol;";
1539 $decl_out = &CreateValidSGML ($decl_out);
1540 $desc .= "<programlisting>$decl_out</programlisting>\n";
1542 $desc .= &MakeDeprecationNote($symbol);
1544 if (defined ($SymbolDocs{$symbol})) {
1545 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1548 # Create a table of fields and descriptions
1550 # FIXME: Inserting  's into the produced type declarations here would
1551 # improve the output in most situations ... except for function
1552 # members of structs!
1553 my @fields = ParseStructDeclaration($declaration, !$default_to_public,
1556 "<structfield id=\"".&CreateValidSGMLID("$id.$_[0]")."\">$_[0]</structfield>";
1558 my $params = $SymbolParams{$symbol};
1560 # If no parameters are filled in, we don't generate the description
1561 # table, for backwards compatibility
1564 if (defined $params) {
1565 for (my $i = 1; $i <= $#$params; $i += $PARAM_FIELD_COUNT) {
1566 if ($params->[$i] =~ /\S/) {
1574 my %field_descrs = @$params;
1575 my $missing_parameters = "";
1576 my $unused_parameters = "";
1578 $desc .= "<variablelist role=\"struct\">\n";
1580 my $field_name = shift @fields;
1581 my $text = shift @fields;
1582 my $field_descr = $field_descrs{$field_name};
1583 my $param_annotations = "";
1585 $desc .= "<varlistentry><term>$text</term>\n";
1586 if (defined $field_descr) {
1587 ($field_descr,$param_annotations) = &ExpandAnnotation($symbol, $field_descr);
1588 $field_descr = &ExpandAbbreviations($symbol, $field_descr);
1589 $field_descr .= $param_annotations;
1591 $field_descr =~ s/^(\s|\n)+//msg;
1592 $field_descr =~ s/(\s|\n)+$//msg;
1593 $desc .= "<listitem><simpara>$field_descr</simpara></listitem>\n";
1594 delete $field_descrs{$field_name};
1596 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1597 "Field description for $symbol"."::"."$field_name is missing in source code comment block.");
1598 if ($missing_parameters ne "") {
1599 $missing_parameters .= ", ".$field_name;
1601 $missing_parameters = $field_name;
1603 $desc .= "<listitem />\n";
1605 $desc .= "</varlistentry>\n";
1607 $desc .= "</variablelist>";
1608 foreach my $field_name (keys %field_descrs) {
1609 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1610 "Field description for $symbol"."::"."$field_name is not used from source code comment block.");
1611 if ($unused_parameters ne "") {
1612 $unused_parameters .= ", ".$field_name;
1614 $unused_parameters = $field_name;
1618 # remember missing/unused parameters (needed in tmpl-free build)
1619 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
1620 $AllIncompleteSymbols{$symbol}=$missing_parameters;
1622 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
1623 $AllUnusedSymbols{$symbol}=$unused_parameters;
1627 if (scalar(@fields) > 0) {
1628 if (! exists ($AllIncompleteSymbols{$symbol})) {
1629 $AllIncompleteSymbols{$symbol}="<items>";
1630 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1631 "Field descriptions for $symbol are missing in source code comment block.");
1636 $desc .= OutputSymbolTraits ($symbol);
1637 $desc .= "</refsect2>\n";
1638 return ($synop, $desc);
1642 #############################################################################
1643 # Function : OutputUnion
1644 # Description : Returns the synopsis and detailed description of a union.
1645 # Arguments : $symbol - the union.
1646 # $declaration - the declaration of the union.
1647 #############################################################################
1650 my ($symbol, $declaration) = @_;
1651 my $id = &CreateValidSGMLID ($symbol);
1652 my $condition = &MakeConditionDescription ($symbol);
1654 # Determine if it is a simple struct or it also has a typedef.
1655 my $has_typedef = 0;
1656 if ($StructHasTypedef{$symbol} || $declaration =~ m/^\s*typedef\s+/) {
1663 # For unions with typedefs we just output the union name.
1664 $synop = &MakeReturnField("") . "<link linkend=\"$id\">$symbol</link>;\n";
1665 $desc = "<refsect2 id=\"$id\" role=\"union\"$condition>\n<title>$symbol</title>\n";
1667 $synop = &MakeReturnField("union") . "<link linkend=\"$id\">$symbol</link>;\n";
1668 $desc = "<refsect2 id=\"$id\" role=\"union\"$condition>\n<title>union $symbol</title>\n";
1671 $desc .= MakeIndexterms($symbol, $id);
1673 $desc .= OutputSymbolExtraLinks($symbol);
1675 # FIXME: we do more for structs
1676 my $decl_out = &CreateValidSGML ($declaration);
1677 $desc .= "<programlisting>$decl_out</programlisting>\n";
1679 $desc .= &MakeDeprecationNote($symbol);
1681 if (defined ($SymbolDocs{$symbol})) {
1682 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1685 # Create a table of fields and descriptions
1687 # FIXME: Inserting  's into the produced type declarations here would
1688 # improve the output in most situations ... except for function
1689 # members of structs!
1690 my @fields = ParseStructDeclaration($declaration, 0,
1693 "<structfield id=\"".&CreateValidSGMLID("$id.$_[0]")."\">$_[0]</structfield>";
1695 my $params = $SymbolParams{$symbol};
1697 # If no parameters are filled in, we don't generate the description
1698 # table, for backwards compatibility
1701 if (defined $params) {
1702 for (my $i = 1; $i <= $#$params; $i += $PARAM_FIELD_COUNT) {
1703 if ($params->[$i] =~ /\S/) {
1711 my %field_descrs = @$params;
1712 my $missing_parameters = "";
1713 my $unused_parameters = "";
1715 $desc .= "<variablelist role=\"union\">\n";
1717 my $field_name = shift @fields;
1718 my $text = shift @fields;
1719 my $field_descr = $field_descrs{$field_name};
1720 my $param_annotations = "";
1722 $desc .= "<varlistentry><term>$text</term>\n";
1723 if (defined $field_descr) {
1724 ($field_descr,$param_annotations) = &ExpandAnnotation($symbol, $field_descr);
1725 $field_descr = &ExpandAbbreviations($symbol, $field_descr);
1726 $field_descr .= $param_annotations;
1728 $field_descr =~ s/^(\s|\n)+//msg;
1729 $field_descr =~ s/(\s|\n)+$//msg;
1730 $desc .= "<listitem><simpara>$field_descr</simpara></listitem>\n";
1731 delete $field_descrs{$field_name};
1733 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1734 "Field description for $symbol"."::"."$field_name is missing in source code comment block.");
1735 if ($missing_parameters ne "") {
1736 $missing_parameters .= ", ".$field_name;
1738 $missing_parameters = $field_name;
1740 $desc .= "<listitem />\n";
1742 $desc .= "</varlistentry>\n";
1744 $desc .= "</variablelist>";
1745 foreach my $field_name (keys %field_descrs) {
1746 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1747 "Field description for $symbol"."::"."$field_name is not used from source code comment block.");
1748 if ($unused_parameters ne "") {
1749 $unused_parameters .= ", ".$field_name;
1751 $unused_parameters = $field_name;
1755 # remember missing/unused parameters (needed in tmpl-free build)
1756 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
1757 $AllIncompleteSymbols{$symbol}=$missing_parameters;
1759 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
1760 $AllUnusedSymbols{$symbol}=$unused_parameters;
1764 if (scalar(@fields) > 0) {
1765 if (! exists ($AllIncompleteSymbols{$symbol})) {
1766 $AllIncompleteSymbols{$symbol}="<items>";
1767 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1768 "Field descriptions for $symbol are missing in source code comment block.");
1773 $desc .= OutputSymbolTraits ($symbol);
1774 $desc .= "</refsect2>\n";
1775 return ($synop, $desc);
1779 #############################################################################
1780 # Function : OutputEnum
1781 # Description : Returns the synopsis and detailed description of a enum.
1782 # Arguments : $symbol - the enum.
1783 # $declaration - the declaration of the enum.
1784 #############################################################################
1787 my ($symbol, $declaration) = @_;
1790 if (&CheckIsObject ($symbol)) {
1791 #print "Found enum gtype: $symbol\n";
1798 $id = &CreateValidSGMLID ($symbol . "_enum");
1799 $condition = &MakeConditionDescription ($symbol . "_enum");
1801 $id = &CreateValidSGMLID ($symbol);
1802 $condition = &MakeConditionDescription ($symbol);
1805 my $synop = &MakeReturnField("enum") . "<link linkend=\"$id\">$symbol</link>;\n";
1806 my $desc = "<refsect2 id=\"$id\" role=\"enum\"$condition>\n<title>enum $symbol</title>\n";
1808 $desc .= MakeIndexterms($symbol, $id);
1810 $desc .= OutputSymbolExtraLinks($symbol);
1812 my $decl_out = &CreateValidSGML ($declaration);
1813 $desc .= "<programlisting>$decl_out</programlisting>\n";
1815 $desc .= &MakeDeprecationNote($symbol);
1817 if (defined ($SymbolDocs{$symbol})) {
1818 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1821 # Create a table of fields and descriptions
1823 my @fields = ParseEnumDeclaration($declaration);
1824 my $params = $SymbolParams{$symbol};
1826 # If no parameters are filled in, we don't generate the description
1827 # table, for backwards compatibility
1830 if (defined $params) {
1831 for (my $i = 1; $i <= $#$params; $i += $PARAM_FIELD_COUNT) {
1832 if ($params->[$i] =~ /\S/) {
1840 my %field_descrs = @$params;
1841 my $missing_parameters = "";
1842 my $unused_parameters = "";
1844 $desc .= "<variablelist role=\"enum\">\n";
1845 for my $field_name (@fields) {
1846 my $field_descr = $field_descrs{$field_name};
1847 my $param_annotations = "";
1849 $id = &CreateValidSGMLID ($field_name);
1850 $condition = &MakeConditionDescription ($field_name);
1851 $desc .= "<varlistentry id=\"$id\" role=\"constant\"$condition>\n<term><literal>$field_name</literal></term>\n";
1852 if (defined $field_descr) {
1853 ($field_descr,$param_annotations) = &ExpandAnnotation($symbol, $field_descr);
1854 $field_descr = &ExpandAbbreviations($symbol, $field_descr);
1855 $desc .= "<listitem><simpara>$field_descr$param_annotations</simpara></listitem>\n";
1856 delete $field_descrs{$field_name};
1858 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1859 "Value description for $symbol"."::"."$field_name is missing in source code comment block.");
1860 if ($missing_parameters ne "") {
1861 $missing_parameters .= ", ".$field_name;
1863 $missing_parameters = $field_name;
1865 $desc .= "<listitem />\n";
1867 $desc .= "</varlistentry>\n";
1869 $desc .= "</variablelist>";
1870 foreach my $field_name (keys %field_descrs) {
1871 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1872 "Value description for $symbol"."::"."$field_name is not used from source code comment block.");
1873 if ($unused_parameters ne "") {
1874 $unused_parameters .= ", ".$field_name;
1876 $unused_parameters = $field_name;
1880 # remember missing/unused parameters (needed in tmpl-free build)
1881 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
1882 $AllIncompleteSymbols{$symbol}=$missing_parameters;
1884 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
1885 $AllUnusedSymbols{$symbol}=$unused_parameters;
1889 if (scalar(@fields) > 0) {
1890 if (! exists ($AllIncompleteSymbols{$symbol})) {
1891 $AllIncompleteSymbols{$symbol}="<items>";
1892 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1893 "Value descriptions for $symbol are missing in source code comment block.");
1898 $desc .= OutputSymbolTraits ($symbol);
1899 $desc .= "</refsect2>\n";
1900 return ($synop, $desc);
1904 #############################################################################
1905 # Function : OutputVariable
1906 # Description : Returns the synopsis and detailed description of a variable.
1907 # Arguments : $symbol - the extern'ed variable.
1908 # $declaration - the declaration of the variable.
1909 #############################################################################
1911 sub OutputVariable {
1912 my ($symbol, $declaration) = @_;
1913 my $id = &CreateValidSGMLID ($symbol);
1914 my $condition = &MakeConditionDescription ($symbol);
1917 if ($declaration =~ m/^\s*extern\s+((const\s+|signed\s+|unsigned\s+)*\w+)(\s+\*+|\*+|\s)(\s*)([A-Za-z]\w*)\s*;/) {
1918 my $mod = defined ($1) ? $1 : "";
1919 my $ptr = defined ($3) ? $3 : "";
1920 my $space = defined ($4) ? $4 : "";
1921 $synop = &MakeReturnField("extern") . "$mod$ptr$space<link linkend=\"$id\">$symbol</link>;\n";
1924 $synop = &MakeReturnField("extern") . "<link linkend=\"$id\">$symbol</link>;\n";
1927 my $desc = "<refsect2 id=\"$id\" role=\"variable\"$condition>\n<title>$symbol</title>\n";
1929 $desc .= MakeIndexterms($symbol, $id);
1931 $desc .= OutputSymbolExtraLinks($symbol);
1933 my $decl_out = &CreateValidSGML ($declaration);
1934 $desc .= "<programlisting>$decl_out</programlisting>\n";
1936 $desc .= &MakeDeprecationNote($symbol);
1938 if (defined ($SymbolDocs{$symbol})) {
1939 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1941 $desc .= OutputSymbolTraits ($symbol);
1942 $desc .= "</refsect2>\n";
1943 return ($synop, $desc);
1947 #############################################################################
1948 # Function : OutputFunction
1949 # Description : Returns the synopsis and detailed description of a function.
1950 # Arguments : $symbol - the function.
1951 # $declaration - the declaration of the function.
1952 #############################################################################
1954 sub OutputFunction {
1955 my ($symbol, $declaration, $symbol_type) = @_;
1956 my $id = &CreateValidSGMLID ($symbol);
1957 my $condition = &MakeConditionDescription ($symbol);
1959 # Take out the return type $1 $2 $3
1960 $declaration =~ s/<RETURNS>\s*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|enum\s+)*)(\w+)(\s*\**\s*(?:const|G_CONST_RETURN)?\s*\**\s*(?:restrict)?\s*)<\/RETURNS>\n//;
1961 my $type_modifier = defined($1) ? $1 : "";
1964 # Trim trailing spaces as we are going to pad to $RETURN_TYPE_FIELD_WIDTH below anyway
1965 $pointer =~ s/\s+$//;
1966 my $xref = &MakeXRef ($type, &tagify($type, "returnvalue"));
1968 #if ($symbol_type eq 'USER_FUNCTION') {
1969 # $start = "typedef ";
1972 # We output const rather than G_CONST_RETURN.
1973 $type_modifier =~ s/G_CONST_RETURN/const/g;
1974 $pointer =~ s/G_CONST_RETURN/const/g;
1975 $pointer =~ s/^\s+/ /g;
1977 my $ret_type_len = length ($start) + length ($type_modifier)+ length ($type)
1978 + length ($pointer);
1979 my $ret_type_output;
1981 if ($ret_type_len < $RETURN_TYPE_FIELD_WIDTH) {
1982 $ret_type_output = "$start$type_modifier$xref$pointer"
1983 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
1986 #$ret_type_output = "$start$type_modifier$xref$pointer\n" . (' ' x $RETURN_TYPE_FIELD_WIDTH);
1988 $ret_type_output = "$start$type_modifier$xref$pointer ";
1989 $symbol_len = $ret_type_len + 1 - $RETURN_TYPE_FIELD_WIDTH;
1991 #@TRACE@("$symbol ret type output: [$ret_type_output], $ret_type_len");
1993 $symbol_len += length ($symbol);
1994 my $char1 = my $char2 = my $char3 = "";
1995 if ($symbol_type eq 'USER_FUNCTION') {
2002 my ($symbol_output, $symbol_desc_output);
2003 if ($symbol_len < $SYMBOL_FIELD_WIDTH) {
2004 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3"
2005 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
2006 $symbol_desc_output = "$char1$char2$symbol$char3"
2007 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
2009 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3\n"
2010 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
2011 $symbol_desc_output = "$char1$char2$symbol$char3\n"
2012 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
2015 my $synop = $ret_type_output . $symbol_output . '(';
2016 my $desc = "<refsect2 id=\"$id\" role=\"function\"$condition>\n<title>${symbol} ()</title>\n";
2018 $desc .= MakeIndexterms($symbol, $id);
2020 $desc .= OutputSymbolExtraLinks($symbol);
2022 $desc .= "<programlisting>${ret_type_output}$symbol_desc_output(";
2024 my @fields = ParseFunctionDeclaration($declaration, \&MakeXRef,
2026 &tagify($_[0],"parameter");
2029 for (my $i = 1; $i <= $#fields; $i += 2) {
2030 my $field_name = $fields[$i];
2032 if ($field_name eq "Varargs") {
2033 $field_name = "...";
2037 $synop .= "$field_name";
2038 $desc .= "$field_name";
2041 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
2044 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
2051 $desc .= ");</programlisting>\n";
2053 $desc .= &MakeDeprecationNote($symbol);
2055 my $parameters = &OutputParamDescriptions ("FUNCTION", $symbol, @fields);
2056 my $parameters_output = 0;
2058 if (defined ($SymbolDocs{$symbol})) {
2059 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2061 # Try to insert the parameter table at the author's desired position.
2062 # Otherwise we need to tag it onto the end.
2063 # FIXME: document that in the user manual and make it useable for other
2065 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
2066 $parameters_output = 1;
2068 $desc .= $symbol_docs;
2071 if ($parameters_output == 0) {
2072 $desc .= $parameters;
2075 $desc .= OutputSymbolTraits ($symbol);
2076 $desc .= "</refsect2>\n";
2077 return ($synop, $desc);
2081 #############################################################################
2082 # Function : OutputParamDescriptions
2083 # Description : Returns the DocBook output describing the parameters of a
2084 # function, macro or signal handler.
2085 # Arguments : $symbol_type - 'FUNCTION', 'MACRO' or 'SIGNAL'. Signal
2086 # handlers have an implicit user_data parameter last.
2087 # $symbol - the name of the function/macro being described.
2088 # @fields - parsed fields from the declaration, used to determine
2089 # undocumented/unused entries
2090 #############################################################################
2092 sub OutputParamDescriptions {
2093 my ($symbol_type, $symbol, @fields) = @_;
2095 my $params = $SymbolParams{$symbol};
2097 my %field_descrs = ();
2100 %field_descrs = @fields;
2101 delete $field_descrs{"void"};
2102 delete $field_descrs{"Returns"};
2105 if (defined $params) {
2107 my $params_desc = "";
2108 my $missing_parameters = "";
2109 my $unused_parameters = "";
2112 for ($j = 0; $j <= $#$params; $j += $PARAM_FIELD_COUNT) {
2113 my $param_name = $$params[$j];
2114 my $param_desc = $$params[$j + 1];
2115 my $param_annotations = "";
2117 ($param_desc,$param_annotations) = & ExpandAnnotation($symbol, $param_desc);
2118 $param_desc = &ExpandAbbreviations($symbol, $param_desc);
2119 $param_desc .= $param_annotations;
2121 $param_desc =~ s/^(\s|\n)+//msg;
2122 $param_desc =~ s/(\s|\n)+$//msg;
2123 if ($param_name eq "Returns") {
2124 $returns = "$param_desc";
2125 } elsif ($param_name eq "void") {
2126 #print "!!!! void in params for $symbol?\n";
2129 if (!defined $field_descrs{$param_name}) {
2130 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2131 "Parameter description for $symbol"."::"."$param_name is not used from source code comment block.");
2132 if ($unused_parameters ne "") {
2133 $unused_parameters .= ", ".$param_name;
2135 $unused_parameters = $param_name;
2138 delete $field_descrs{$param_name};
2141 if ($param_name eq "Varargs") {
2142 $param_name = "...";
2144 if($param_desc ne "") {
2145 $params_desc .= "<varlistentry><term><parameter>$param_name</parameter> :</term>\n<listitem><simpara>$param_desc</simpara></listitem></varlistentry>\n";
2150 foreach my $param_name (keys %field_descrs) {
2151 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2152 "Parameter description for $symbol"."::"."$param_name is missing in source code comment block.");
2153 if ($missing_parameters ne "") {
2154 $missing_parameters .= ", ".$param_name;
2156 $missing_parameters = $param_name;
2160 # Signals have an implicit user_data parameter which we describe.
2161 if ($symbol_type eq "SIGNAL") {
2162 $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";
2165 # Start a table if we need one.
2166 if ($params_desc || $returns) {
2167 $output .= "<variablelist role=\"params\">\n";
2168 if ($params_desc ne "") {
2169 #$output .= "<varlistentry><term>Parameters:</term><listitem></listitem></varlistentry>\n";
2170 $output .= $params_desc;
2173 # Output the returns info last
2175 $output .= "<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>$returns</simpara></listitem></varlistentry>\n";
2179 $output .= "</variablelist>";
2182 # remember missing/unused parameters (needed in tmpl-free build)
2183 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
2184 $AllIncompleteSymbols{$symbol}=$missing_parameters;
2186 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
2187 $AllUnusedSymbols{$symbol}=$unused_parameters;
2190 if (($num_params == 0) && @fields && (scalar(keys(%field_descrs)) > 0)) {
2191 if (! exists ($AllIncompleteSymbols{$symbol})) {
2192 $AllIncompleteSymbols{$symbol}="<parameters>";
2200 #############################################################################
2201 # Function : ParseStabilityLevel
2202 # Description : Parses a stability level and outputs a warning if it isn't
2204 # Arguments : $stability - the stability text.
2205 # $file, $line - context for error message
2206 # $message - description of where the level is from, to use in
2207 # any error message.
2208 # Returns : The parsed stability level string.
2209 #############################################################################
2211 sub ParseStabilityLevel {
2212 my ($stability, $file, $line, $message) = @_;
2214 $stability =~ s/^\s*//;
2215 $stability =~ s/\s*$//;
2216 if ($stability =~ m/^stable$/i) {
2217 $stability = "Stable";
2218 } elsif ($stability =~ m/^unstable$/i) {
2219 $stability = "Unstable";
2220 } elsif ($stability =~ m/^private$/i) {
2221 $stability = "Private";
2223 &LogWarning ($file, $line, "$message is $stability.".
2224 "It should be one of these: Stable, Unstable, or Private.");
2230 #############################################################################
2231 # Function : OutputSGMLFile
2232 # Description : Outputs the final DocBook file for one section.
2233 # Arguments : $file - the name of the file.
2234 # $title - the title from the $MODULE-sections.txt file, which
2235 # will be overridden by the title in the template file.
2236 # $section_id - the SGML id to use for the toplevel tag.
2237 # $includes - comma-separates list of include files added at top
2238 # of synopsis, with '<' '>' around them (if not already enclosed in "").
2239 # $synopsis - reference to the DocBook for the Synopsis part.
2240 # $details - reference to the DocBook for the Details part.
2241 # $signal_synop - reference to the DocBook for the Signal Synopsis part
2242 # $signal_desc - reference to the DocBook for the Signal Description part
2243 # $args_synop - reference to the DocBook for the Arg Synopsis part
2244 # $args_desc - reference to the DocBook for the Arg Description part
2245 # $hierarchy - reference to the DocBook for the Object Hierarchy part
2246 # $interfaces - reference to the DocBook for the Interfaces part
2247 # $implementations - reference to the DocBook for the Known Implementations part
2248 # $prerequisites - reference to the DocBook for the Prerequisites part
2249 # $derived - reference to the DocBook for the Derived Interfaces part
2250 # $file_objects - reference to an array of objects in this file
2251 #############################################################################
2253 sub OutputSGMLFile {
2254 my ($file, $title, $section_id, $includes, $synopsis, $details, $signals_synop, $signals_desc, $args_synop, $args_desc, $hierarchy, $interfaces, $implementations, $prerequisites, $derived, $file_objects) = @_;
2256 #print "Output sgml for file $file with title '$title'\n";
2258 # The edited title overrides the one from the sections file.
2259 my $new_title = $SymbolDocs{"$TMPL_DIR/$file:Title"};
2260 if (defined ($new_title) && $new_title !~ m/^\s*$/) {
2261 $title = $new_title;
2262 #print "Found title: $title\n";
2264 my $short_desc = $SymbolDocs{"$TMPL_DIR/$file:Short_Description"};
2265 if (!defined ($short_desc) || $short_desc =~ m/^\s*$/) {
2268 $short_desc = &ExpandAbbreviations("$title:Short_description",
2270 #print "Found short_desc: $short_desc";
2272 my $long_desc = $SymbolDocs{"$TMPL_DIR/$file:Long_Description"};
2273 if (!defined ($long_desc) || $long_desc =~ m/^\s*$/) {
2276 $long_desc = &ExpandAbbreviations("$title:Long_description",
2278 #print "Found long_desc: $long_desc";
2280 my $see_also = $SymbolDocs{"$TMPL_DIR/$file:See_Also"};
2281 if (!defined ($see_also) || $see_also =~ m%^\s*(<para>)?\s*(</para>)?\s*$%) {
2284 $see_also = &ExpandAbbreviations("$title:See_Also", $see_also);
2285 #print "Found see_also: $see_also";
2288 $see_also = "<refsect1 id=\"$section_id.see-also\">\n<title>See Also</title>\n$see_also\n</refsect1>\n";
2290 my $stability = $SymbolDocs{"$TMPL_DIR/$file:Stability_Level"};
2291 if (!defined ($stability) || $stability =~ m/^\s*$/) {
2294 $stability = &ParseStabilityLevel($stability, $file, $., "Section stability level");
2295 #print "Found stability: $stability";
2298 $stability = "<refsect1 id=\"$section_id.stability-level\">\n<title>Stability Level</title>\n$stability, unless otherwise indicated\n</refsect1>\n";
2299 } elsif ($DEFAULT_STABILITY) {
2300 $stability = "<refsect1 id=\"$section_id.stability-level\">\n<title>Stability Level</title>\n$DEFAULT_STABILITY, unless otherwise indicated\n</refsect1>\n";
2303 my $image = $SymbolDocs{"$TMPL_DIR/$file:Image"};
2304 if (!defined ($image) || $image =~ m/^\s*$/) {
2312 if ($image =~ /jpe?g$/i) {
2313 $format = "format='JPEG'";
2314 } elsif ($image =~ /png$/i) {
2315 $format = "format='PNG'";
2316 } elsif ($image =~ /svg$/i) {
2317 $format = "format='SVG'";
2322 $image = " <inlinegraphic fileref='$image' $format/>\n"
2325 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
2327 my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
2330 my $include_output = "";
2332 foreach $include (split (/,/, $includes)) {
2333 if ($include =~ m/^\".+\"$/) {
2334 $include_output .= "#include ${include}\n";
2337 $include =~ s/^\s+|\s+$//gs;
2338 $include_output .= "#include <${include}>\n";
2341 if ($include_output ne '') {
2342 $include_output = "\n$include_output\n";
2345 my $extralinks = OutputSectionExtraLinks($title,"Section:$file");
2347 my $old_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT";
2348 my $new_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT.new";
2350 open (OUTPUT, ">$new_sgml_file")
2351 || die "Can't create $new_sgml_file: $!";
2353 my $object_anchors = "";
2354 foreach my $object (@$file_objects) {
2355 next if ($object eq $section_id);
2356 my $id = CreateValidSGMLID($object);
2357 #print "Debug: Adding anchor for $object\n";
2358 $object_anchors .= "<anchor id=\"$id\"$empty_element_end";
2361 # We used to output this, but is messes up our UpdateFileIfChanged code
2362 # since it changes every day (and it is only used in the man pages):
2363 # "<refentry id="$section_id" revision="$mday $month $year">"
2365 if ($OUTPUT_FORMAT eq "xml") {
2366 print OUTPUT $doctype_header;
2370 <refentry id="$section_id">
2372 <refentrytitle role="top_of_page" id="$section_id.top_of_page">$title</refentrytitle>
2373 <manvolnum>3</manvolnum>
2376 $image</refmiscinfo>
2379 <refname>$title</refname>
2380 <refpurpose>$short_desc</refpurpose>
2383 <refsynopsisdiv id="$section_id.synopsis" role="synopsis">
2384 <title role="synopsis.title">Synopsis</title>
2386 <synopsis>$include_output$${synopsis}</synopsis>
2388 $$hierarchy$$prerequisites$$derived$$interfaces$$implementations$$args_synop$$signals_synop
2389 <refsect1 id="$section_id.description" role="desc">
2390 <title role="desc.title">Description</title>
2391 $extralinks$long_desc
2393 <refsect1 id="$section_id.details" role="details">
2394 <title role="details.title">Details</title>
2397 $$args_desc$$signals_desc$see_also
2402 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
2406 #############################################################################
2407 # Function : OutputExtraFile
2408 # Description : Copies an "extra" DocBook file into the output directory,
2409 # expanding abbreviations
2410 # Arguments : $file - the source file.
2411 #############################################################################
2412 sub OutputExtraFile {
2417 ($basename = $file) =~ s!^.*/!!;
2419 my $old_sgml_file = "$SGML_OUTPUT_DIR/$basename";
2420 my $new_sgml_file = "$SGML_OUTPUT_DIR/$basename.new";
2424 open(EXTRA_FILE, "<$file") || die "Can't open $file";
2428 $contents = <EXTRA_FILE>;
2431 open (OUTPUT, ">$new_sgml_file")
2432 || die "Can't create $new_sgml_file: $!";
2434 print OUTPUT &ExpandAbbreviations ("$basename file", $contents);
2437 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
2439 #############################################################################
2440 # Function : OutputBook
2441 # Description : Outputs the SGML entities that need to be included into the
2442 # main SGML file for the module.
2443 # Arguments : $book_top - the declarations of the entities, which are added
2444 # at the top of the main SGML file.
2445 # $book_bottom - the references to the entities, which are
2446 # added in the main SGML file at the desired position.
2447 #############################################################################
2450 my ($book_top, $book_bottom) = @_;
2452 my $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top";
2453 my $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top.new";
2455 open (OUTPUT, ">$new_file")
2456 || die "Can't create $new_file: $!";
2457 print OUTPUT $book_top;
2460 &UpdateFileIfChanged ($old_file, $new_file, 0);
2463 $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom";
2464 $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom.new";
2466 open (OUTPUT, ">$new_file")
2467 || die "Can't create $new_file: $!";
2468 print OUTPUT $book_bottom;
2471 &UpdateFileIfChanged ($old_file, $new_file, 0);
2474 # If the main SGML/XML file hasn't been created yet, we create it here.
2475 # The user can tweak it later.
2476 if ($MAIN_SGML_FILE && ! -e $MAIN_SGML_FILE) {
2477 open (OUTPUT, ">$MAIN_SGML_FILE")
2478 || die "Can't create $MAIN_SGML_FILE: $!";
2480 if ($OUTPUT_FORMAT eq "xml") {
2482 <?xml version="1.0"?>
2483 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
2484 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
2486 <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
2492 <!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
2501 <title>$MODULE Reference Manual</title>
2503 for $MODULE [VERSION].
2504 The latest version of this documentation can be found on-line at
2505 <ulink role="online-location" url="http://[SERVER]/$MODULE/index.html">http://[SERVER]/$MODULE/</ulink>.
2510 <title>[Insert title here]</title>
2514 if (-e $OBJECT_TREE_FILE) {
2516 <chapter id="object-tree">
2517 <title>Object Hierarchy</title>
2518 <xi:include href="xml/tree_index.sgml"/>
2524 <index id="api-index-full">
2525 <title>API Index</title>
2526 <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
2528 <index id="deprecated-api-index" role="deprecated">
2529 <title>Index of deprecated API</title>
2530 <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
2533 <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
2542 #############################################################################
2543 # Function : CreateValidSGML
2544 # Description : This turns any chars which are used in SGML into entities,
2545 # e.g. '<' into '<'
2546 # Arguments : $text - the text to turn into proper SGML.
2547 #############################################################################
2549 sub CreateValidSGML {
2551 $text =~ s/&/&/g; # Do this first, or the others get messed up.
2552 $text =~ s/</</g;
2553 $text =~ s/>/>/g;
2554 # browers render single tabs inconsistently
2555 $text =~ s/([^\s])\t([^\s])/$1 $2/g;
2559 #############################################################################
2560 # Function : ConvertSGMLChars
2561 # Description : This is used for text in source code comment blocks, to turn
2562 # chars which are used in SGML into entities, e.g. '<' into
2563 # '<'. Depending on $INLINE_MARKUP_MODE, this is done
2564 # unconditionally or only if the character doesn't seem to be
2565 # part of an SGML construct (tag or entity reference).
2566 # Arguments : $text - the text to turn into proper SGML.
2567 #############################################################################
2569 sub ConvertSGMLChars {
2570 my ($symbol, $text) = @_;
2572 if ($INLINE_MARKUP_MODE) {
2573 # For the XML/SGML mode only convert to entities outside CDATA sections.
2574 return &ModifyXMLElements ($text, $symbol,
2575 "<!\\[CDATA\\[|<programlisting[^>]*>",
2576 \&ConvertSGMLCharsEndTag,
2577 \&ConvertSGMLCharsCallback);
2579 # For the simple non-sgml mode, convert to entities everywhere.
2580 $text =~ s/&/&/g; # Do this first, or the others get messed up.
2581 $text =~ s/</</g;
2582 $text =~ s/>/>/g;
2588 sub ConvertSGMLCharsEndTag {
2589 if ($_[0] eq "<!\[CDATA\[") {
2592 return "</programlisting>";
2596 sub ConvertSGMLCharsCallback {
2597 my ($text, $symbol, $tag) = @_;
2599 if ($tag =~ m/^<programlisting/) {
2600 # We can handle <programlisting> specially here.
2601 return &ModifyXMLElements ($text, $symbol,
2603 \&ConvertSGMLCharsEndTag,
2604 \&ConvertSGMLCharsCallback2);
2605 } elsif ($tag eq "") {
2606 # If we're not in CDATA convert to entities.
2607 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
2608 $text =~ s/<(?![a-zA-Z\/!])/</g;
2609 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
2611 # Handle "#include <xxxxx>"
2612 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
2618 sub ConvertSGMLCharsCallback2 {
2619 my ($text, $symbol, $tag) = @_;
2621 # If we're not in CDATA convert to entities.
2622 # We could handle <programlisting> differently, though I'm not sure it helps.
2624 # replace only if its not a tag
2625 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
2626 $text =~ s/<(?![a-zA-Z\/!])/</g;
2627 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
2629 # Handle "#include <xxxxx>"
2630 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
2636 #############################################################################
2637 # Function : ExpandAnnotation
2638 # Description : This turns annotations into acronym tags.
2639 # Arguments : $symbol - the symbol being documented, for error messages.
2640 # $text - the text to expand.
2641 #############################################################################
2642 sub ExpandAnnotation {
2643 my ($symbol, $param_desc) = @_;
2644 my $param_annotations = "";
2646 # look for annotations at the start of the comment part
2647 if ($param_desc =~ m%^\s*\((.*?)\):%) {
2652 @annotations = split(/\)\s*\(/,$1);
2653 foreach $annotation (@annotations) {
2654 # need to search for the longest key-match in %AnnotationDefinition
2656 my $match_annotation="";
2658 foreach $annotationdef (keys %AnnotationDefinition) {
2659 if ($annotation =~ m/^$annotationdef/) {
2660 if (length($annotationdef)>$match_length) {
2661 $match_length=length($annotationdef);
2662 $match_annotation=$annotationdef;
2666 my $annotation_extra = "";
2667 if ($match_annotation ne "") {
2668 if ($annotation =~ m%$match_annotation\s+(.*)%) {
2669 $annotation_extra = " $1";
2671 $AnnotationsUsed{$match_annotation} = 1;
2672 $param_annotations .= "[<acronym>$match_annotation</acronym>$annotation_extra]";
2675 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2676 "unknown annotation \"$annotation\" in documentation for $symbol.");
2677 $param_annotations .= "[$annotation]";
2681 $param_desc =~ m/^(.*?)\.*\s*$/s;
2682 $param_desc = "$1. ";
2684 if ($param_annotations ne "") {
2685 $param_annotations = "<emphasis role=\"annotation\">$param_annotations</emphasis>";
2687 return ($param_desc, $param_annotations);
2690 #############################################################################
2691 # Function : ExpandAbbreviations
2692 # Description : This turns the abbreviations function(), macro(), @param,
2693 # %constant, and #symbol into appropriate DocBook markup.
2694 # CDATA sections and <programlisting> parts are skipped.
2695 # Arguments : $symbol - the symbol being documented, for error messages.
2696 # $text - the text to expand.
2697 #############################################################################
2699 sub ExpandAbbreviations {
2700 my ($symbol, $text) = @_;
2702 # Convert "|[" and "]|" into the start and end of program listing examples.
2703 # FIXME: we like to have a way to specify parameters e.g. language="c"
2704 $text =~ s%\|\[%<informalexample><programlisting>%g;
2705 $text =~ s%\]\|%</programlisting></informalexample>%g;
2706 # TODO: check for a xml comment after |[ and pick the language attribute from
2709 # keep CDATA unmodified, preserve ulink tags (ideally we preseve all tags
2711 return &ModifyXMLElements ($text, $symbol,
2712 "<!\\[CDATA\\[|<ulink[^>]*>|<programlisting[^>]*>|<!DOCTYPE",
2713 \&ExpandAbbreviationsEndTag,
2714 \&ExpandAbbreviationsCallback);
2718 # Returns the end tag corresponding to the given start tag.
2719 sub ExpandAbbreviationsEndTag {
2720 my ($start_tag) = @_;
2722 if ($start_tag eq "<!\[CDATA\[") {
2724 } elsif ($start_tag eq "<!DOCTYPE") {
2726 } elsif ($start_tag =~ m/<(\w+)/) {
2731 # Called inside or outside each CDATA or <programlisting> section.
2732 sub ExpandAbbreviationsCallback {
2733 my ($text, $symbol, $tag) = @_;
2735 if ($tag =~ m/^<programlisting/) {
2736 # Handle any embedded CDATA sections.
2737 return &ModifyXMLElements ($text, $symbol,
2739 \&ExpandAbbreviationsEndTag,
2740 \&ExpandAbbreviationsCallback2);
2741 } elsif ($tag eq "") {
2742 # We are outside any CDATA or <programlisting> sections, so we expand
2743 # any gtk-doc abbreviations.
2745 # Convert '@param()'
2746 # FIXME: we could make those also links ($symbol.$2), but that would be less
2747 # useful as the link target is a few lines up or down
2748 $text =~ s/(\A|[^\\])\@(\w+((\.|->)\w+)*)\s*\(\)/$1<parameter>$2()<\/parameter>/g;
2750 # Convert 'function()' or 'macro()'.
2751 # if there is abc_*_def() we don't want to make a link to _def()
2752 # FIXME: also handle abc(def(....)) : but that would need to be done recursively :/
2753 $text =~ s/([^\*.\w])(\w+)\s*\(\)/$1.&MakeXRef($2, &tagify($2 . "()", "function"));/eg;
2754 # handle #Object.func()
2755 $text =~ s/(\A|[^\\])#([\w\-:\.]+[\w]+)\s*\(\)/$1.&MakeXRef($2, &tagify($2 . "()", "function"));/eg;
2757 # Convert '@param', but not '\@param'.
2758 $text =~ s/(\A|[^\\])\@(\w+((\.|->)\w+)*)/$1<parameter>$2<\/parameter>/g;
2759 $text =~ s/\\\@/\@/g;
2761 # Convert '%constant', but not '\%constant'.
2762 # Also allow negative numbers, e.g. %-1.
2763 $text =~ s/(\A|[^\\])\%(-?\w+)/$1.&MakeXRef($2, &tagify($2, "literal"));/eg;
2764 $text =~ s/\\\%/\%/g;
2766 # Convert '#symbol', but not '\#symbol'.
2767 $text =~ s/(\A|[^\\])#([\w\-:\.]+[\w]+)/$1.&MakeHashXRef($2, "type");/eg;
2771 # FIXME: should we skip urls that are already tagged? (e.g. <literal>http://...</literal>)
2772 # this is apparently also called for markup and not just for plain text
2774 #$text =~ s%(http|https|ftp)://(.*?)((?:\s|,|\)|\]|\<|\.\s))%<ulink url="$1://$2">$2</ulink>$3%g;
2776 # TODO: optionally check all words from $text against internal symbols and
2777 # warn if those could be xreffed, but miss a %,# or ()
2783 # This is called inside a <programlisting>
2784 sub ExpandAbbreviationsCallback2 {
2785 my ($text, $symbol, $tag) = @_;
2788 # We are inside a <programlisting> but outside any CDATA sections,
2789 # so we expand any gtk-doc abbreviations.
2790 # FIXME: why is this different from &ExpandAbbreviationsCallback(),
2791 # why not just call it
2792 $text =~ s/#(\w+)/&MakeHashXRef($1, "");/eg;
2799 my ($symbol, $tag) = @_;;
2802 # Check for things like '#include', '#define', and skip them.
2803 if ($PreProcessorDirectives{$symbol}) {
2807 # Get rid of any special '-struct' suffix.
2808 $text =~ s/-struct$//;
2810 # If the symbol is in the form "Object::signal", then change the symbol to
2811 # "Object-signal" and use "signal" as the text.
2812 if ($symbol =~ s/::/-/) {
2816 # If the symbol is in the form "Object:property", then change the symbol to
2817 # "Object--property" and use "property" as the text.
2818 if ($symbol =~ s/:/--/) {
2823 $text = tagify ($text, $tag);
2826 return &MakeXRef($symbol, $text);
2830 #############################################################################
2831 # Function : ModifyXMLElements
2832 # Description : Looks for given XML element tags within the text, and calls
2833 # the callback on pieces of text inside & outside those elements.
2834 # Used for special handling of text inside things like CDATA
2835 # and <programlisting>.
2836 # Arguments : $text - the text.
2837 # $symbol - the symbol currently being documented (only used for
2839 # $start_tag_regexp - the regular expression to match start tags.
2840 # e.g. "<!\\[CDATA\\[|<programlisting[^>]*>" to match
2841 # CDATA sections or programlisting elements.
2842 # $end_tag_func - function which is passed the matched start tag
2843 # and should return the appropriate end tag string.
2844 # $callback - callback called with each part of the text. It is
2845 # called with a piece of text, the symbol being
2846 # documented, and the matched start tag or "" if the text
2847 # is outside the XML elements being matched.
2848 #############################################################################
2849 sub ModifyXMLElements {
2850 my ($text, $symbol, $start_tag_regexp, $end_tag_func, $callback) = @_;
2851 my ($before_tag, $start_tag, $end_tag_regexp, $end_tag);
2854 while ($text =~ m/$start_tag_regexp/s) {
2855 $before_tag = $`; # Prematch for last successful match string
2856 $start_tag = $&; # Last successful match
2857 $text = $'; # Postmatch for last successful match string
2859 $result .= &$callback ($before_tag, $symbol, "");
2860 $result .= $start_tag;
2862 # get the mathing end-tag for current tag
2863 $end_tag_regexp = &$end_tag_func ($start_tag);
2865 if ($text =~ m/$end_tag_regexp/s) {
2870 $result .= &$callback ($before_tag, $symbol, $start_tag);
2871 $result .= $end_tag;
2873 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2874 "Can't find tag end: $end_tag_regexp in docs for: $symbol.");
2875 # Just assume it is all inside the tag.
2876 $result .= &$callback ($text, $symbol, $start_tag);
2881 # Handle any remaining text outside the tags.
2882 $result .= &$callback ($text, $symbol, "");
2891 # Adds a tag around some text.
2892 # e.g tagify("Text", "literal") => "<literal>Text</literal>".
2894 my ($text, $elem) = @_;
2895 return "<" . $elem . ">" . $text . "</" . $elem . ">";
2899 #############################################################################
2900 # Function : MakeXRef
2901 # Description : This returns a cross-reference link to the given symbol.
2902 # Though it doesn't try to do this for a few standard C types
2903 # that it knows won't be in the documentation.
2904 # Arguments : $symbol - the symbol to try to create a XRef to.
2905 # $text - text text to put inside the XRef, defaults to $symbol
2906 #############################################################################
2909 my ($symbol, $text) = ($_[0], $_[1]);
2911 $symbol =~ s/^\s+//;
2912 $symbol =~ s/\s+$//;
2914 if (!defined($text)) {
2917 # Get rid of special '-struct' suffix.
2918 $text =~ s/-struct$//;
2921 if ($symbol =~ m/ /) {
2925 #print "Getting type link for $symbol -> $text\n";
2927 my $symbol_id = &CreateValidSGMLID ($symbol);
2928 return "<link linkend=\"$symbol_id\">$text</link>";
2932 #############################################################################
2933 # Function : MakeIndexterms
2934 # Description : This returns a indexterm elements for the given symbol
2935 # Arguments : $symbol - the symbol to create indexterms for
2936 #############################################################################
2938 sub MakeIndexterms {
2939 my ($symbol, $id) = @_;
2943 # make the index useful, by ommiting the namespace when sorting
2944 if ($NAME_SPACE ne "") {
2945 if ($symbol =~ m/^$NAME_SPACE\_?(.*)/i) {
2946 $sortas=" sortas=\"$1\"";
2950 if (exists $Deprecated{$symbol}) {
2951 $terms .= "<indexterm zone=\"$id\" role=\"deprecated\"><primary$sortas>$symbol</primary></indexterm>";
2952 $IndexEntriesDeprecated{$symbol}=$id;
2953 $IndexEntriesFull{$symbol}=$id;
2955 if (exists $Since{$symbol}) {
2956 my $since = $Since{$symbol};
2960 $terms .= "<indexterm zone=\"$id\" role=\"$since\"><primary$sortas>$symbol</primary></indexterm>";
2962 $IndexEntriesSince{$symbol}=$id;
2963 $IndexEntriesFull{$symbol}=$id;
2966 $terms .= "<indexterm zone=\"$id\"><primary$sortas>$symbol</primary></indexterm>";
2967 $IndexEntriesFull{$symbol}=$id;
2973 #############################################################################
2974 # Function : MakeDeprecationNote
2975 # Description : This returns a deprecation warning for the given symbol.
2976 # Arguments : $symbol - the symbol to try to create a warning for.
2977 #############################################################################
2979 sub MakeDeprecationNote {
2980 my ($symbol) = $_[0];
2983 if (exists $Deprecated{$symbol}) {
2984 $desc .= "<warning>";
2986 if ($Deprecated{$symbol} =~ /^\s*([0-9\.]+)\s*:/) {
2987 $desc .= "<para><literal>$symbol</literal> has been deprecated since version $1 and should not be used in newly-written code.";
2989 $desc .= "<para><literal>$symbol</literal> is deprecated and should not be used in newly-written code.";
2991 if ($Deprecated{$symbol} ne "") {
2992 $note = &ExpandAbbreviations($symbol, $Deprecated{$symbol});
2993 $note =~ s/^\s*([0-9\.]+)\s*:\s*//;
2996 $note =~ s%\n{2,}%\n</para>\n<para>\n%g;
2997 $desc .= " " . $note;
2999 $desc .= "</para></warning>\n";
3004 #############################################################################
3005 # Function : MakeConditionDescription
3006 # Description : This returns a sumary of conditions for the given symbol.
3007 # Arguments : $symbol - the symbol to try to create the sumary.
3008 #############################################################################
3010 sub MakeConditionDescription {
3011 my ($symbol) = $_[0];
3014 if (exists $Deprecated{$symbol}) {
3019 if ($Deprecated{$symbol} =~ /^\s*(.*?)\s*$/) {
3020 $desc .= "deprecated:$1";
3022 $desc .= "deprecated";
3026 if (exists $Since{$symbol}) {
3031 if ($Since{$symbol} =~ /^\s*(.*?)\s*$/) {
3032 $desc .= "since:$1";
3038 if (exists $StabilityLevel{$symbol}) {
3042 $desc .= "stability:".$StabilityLevel{$symbol};
3046 $desc=" condition=\"".$desc."\"";
3047 #print "condition for '$symbol' = '$desc'\n";
3052 #############################################################################
3053 # Function : GetHierarchy
3054 # Description : Returns the DocBook output describing the ancestors and
3055 # immediate children of a GObject subclass. It uses the
3056 # global @Objects and @ObjectLevels arrays to walk the tree.
3057 # Arguments : $object - the GtkObject subclass.
3058 #############################################################################
3063 # Find object in the objects array.
3069 for ($i = 0; $i < @Objects; $i++) {
3071 if ($ObjectLevels[$i] <= $level) {
3074 elsif ($ObjectLevels[$i] == $level + 1) {
3075 push (@children, $Objects[$i]);
3078 elsif ($Objects[$i] eq $object) {
3081 $level = $ObjectLevels[$i];
3088 # Walk up the hierarchy, pushing ancestors onto the ancestors array.
3090 push (@ancestors, $object);
3091 #print "Level: $level\n";
3092 while ($level > 1) {
3094 if ($ObjectLevels[$j] < $level) {
3095 push (@ancestors, $Objects[$j]);
3096 $level = $ObjectLevels[$j];
3097 #print "Level: $level\n";
3101 # Output the ancestors list, indented and with links.
3102 my $hierarchy = "<synopsis>\n";
3104 for ($i = $#ancestors; $i >= 0; $i--) {
3106 # Don't add a link to the current object, i.e. when i == 0.
3108 my $ancestor_id = &CreateValidSGMLID ($ancestors[$i]);
3109 $link_text = "<link linkend=\"$ancestor_id\">$ancestors[$i]</link>";
3111 $link_text = "$ancestors[$i]";
3114 $hierarchy .= " $link_text\n";
3116 # $hierarchy .= ' ' x ($level * 6 - 3) . "|\n";
3117 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
3121 for ($i = 0; $i <= $#children; $i++) {
3122 my $id = &CreateValidSGMLID ($children[$i]);
3123 my $link_text = "<link linkend=\"$id\">$children[$i]</link>";
3124 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
3126 $hierarchy .= "</synopsis>\n";
3132 #############################################################################
3133 # Function : GetInterfaces
3134 # Description : Returns the DocBook output describing the interfaces
3135 # implemented by a class. It uses the global %Interfaces hash.
3136 # Arguments : $object - the GtkObject subclass.
3137 #############################################################################
3144 # Find object in the objects array.
3145 if (exists($Interfaces{$object})) {
3146 my @ifaces = split(' ', $Interfaces{$object});
3151 for ($i = 0; $i <= $#ifaces; $i++) {
3152 my $id = &CreateValidSGMLID ($ifaces[$i]);
3153 $text .= " <link linkend=\"$id\">$ifaces[$i]</link>";
3154 if ($i < $#ifaces - 1) {
3157 elsif ($i < $#ifaces) {
3172 #############################################################################
3173 # Function : GetImplementations
3174 # Description : Returns the DocBook output describing the implementations
3175 # of an interface. It uses the global %Interfaces hash.
3176 # Arguments : $object - the GtkObject subclass.
3177 #############################################################################
3179 sub GetImplementations {
3184 foreach my $key (keys %Interfaces) {
3185 if ($Interfaces{$key} =~ /\b$object\b/) {
3186 push (@impls, $key);
3190 @impls = sort @impls;
3193 $object is implemented by
3195 for ($i = 0; $i <= $#impls; $i++) {
3196 my $id = &CreateValidSGMLID ($impls[$i]);
3197 $text .= " <link linkend=\"$id\">$impls[$i]</link>";
3198 if ($i < $#impls - 1) {
3201 elsif ($i < $#impls) {
3216 #############################################################################
3217 # Function : GetPrerequisites
3218 # Description : Returns the DocBook output describing the prerequisites
3219 # of an interface. It uses the global %Prerequisites hash.
3220 # Arguments : $iface - the interface.
3221 #############################################################################
3223 sub GetPrerequisites {
3228 if (exists($Prerequisites{$iface})) {
3233 my @prereqs = split(' ', $Prerequisites{$iface});
3234 for ($i = 0; $i <= $#prereqs; $i++) {
3235 my $id = &CreateValidSGMLID ($prereqs[$i]);
3236 $text .= " <link linkend=\"$id\">$prereqs[$i]</link>";
3237 if ($i < $#prereqs - 1) {
3240 elsif ($i < $#prereqs) {
3254 #############################################################################
3255 # Function : GetDerived
3256 # Description : Returns the DocBook output describing the derived interfaces
3257 # of an interface. It uses the global %Prerequisites hash.
3258 # Arguments : $iface - the interface.
3259 #############################################################################
3267 foreach my $key (keys %Prerequisites) {
3268 if ($Prerequisites{$key} =~ /\b$iface\b/) {
3269 push (@derived, $key);
3272 if ($#derived >= 0) {
3273 @derived = sort @derived;
3276 $iface is required by
3278 for ($i = 0; $i <= $#derived; $i++) {
3279 my $id = &CreateValidSGMLID ($derived[$i]);
3280 $text .= " <link linkend=\"$id\">$derived[$i]</link>";
3281 if ($i < $#derived - 1) {
3284 elsif ($i < $#derived) {
3299 #############################################################################
3300 # Function : GetSignals
3301 # Description : Returns the synopsis and detailed description DocBook output
3302 # for the signal handlers of a given GtkObject subclass.
3303 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
3304 #############################################################################
3312 for ($i = 0; $i <= $#SignalObjects; $i++) {
3313 if ($SignalObjects[$i] eq $object) {
3314 #print "Found signal: $SignalNames[$i]\n";
3315 my $name = $SignalNames[$i];
3316 my $symbol = "${object}::${name}";
3317 my $id = &CreateValidSGMLID ("$object-$name");
3319 my $pad = ' ' x (46 - length($name));
3320 $synop .= " "<link linkend=\"$id\">$name</link>"$pad ";
3322 $desc .= "<refsect2 id=\"$id\" role=\"signal\"><title>The <literal>"$name"</literal> signal</title>\n";
3323 $desc .= MakeIndexterms($symbol, $id);
3325 $desc .= OutputSymbolExtraLinks($symbol);
3327 $desc .= "<programlisting>";
3329 $SignalReturns[$i] =~ m/\s*(const\s+)?(\w+)\s*(\**)/;
3330 my $type_modifier = defined($1) ? $1 : "";
3333 my $xref = &MakeXRef ($type, &tagify($type, "returnvalue"));
3335 my $ret_type_len = length ($type_modifier) + length ($pointer)
3337 my $ret_type_output = "$type_modifier$xref$pointer"
3338 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
3340 $desc .= "${ret_type_output}user_function " . &MakeReturnField("") . " (";
3342 my $sourceparams = $SourceSymbolParams{$symbol};
3343 my @params = split ("\n", $SignalPrototypes[$i]);
3346 my $type_len = length("gpointer");
3347 my $name_len = length("user_data");
3348 # do two passes, the first one is to calculate padding
3349 for ($l = 0; $l < 2; $l++) {
3350 for ($j = 0; $j <= $#params; $j++) {
3351 # allow alphanumerics, '_', '[' & ']' in param names
3352 if ($params[$j] =~ m/^\s*(\w+)\s*(\**)\s*([\w\[\]]+)\s*$/) {
3355 if (defined($sourceparams)) {
3356 $name = $$sourceparams[$PARAM_FIELD_COUNT * $j];
3361 if (!defined($name)) {
3365 if (length($type) + length($pointer) > $type_len) {
3366 $type_len = length($type) + length($pointer);
3368 if (length($name) > $name_len) {
3369 $name_len = length($name);
3373 $xref = &MakeXRef ($type, &tagify($type, "type"));
3374 $pad = ' ' x ($type_len - length($type) - length($pointer));
3375 $desc .= "$xref$pad $pointer$name,\n";
3376 $desc .= (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
3379 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
3380 "Can't parse arg: $params[$j]\nArgs:$SignalPrototypes[$i]");
3384 $xref = &MakeXRef ("gpointer", &tagify("gpointer", "type"));
3385 $pad = ' ' x ($type_len - length("gpointer"));
3386 $desc .= "$xref$pad user_data)";
3388 my $flags = $SignalFlags[$i];
3389 my $flags_string = "";
3391 if (defined ($flags)) {
3392 if ($flags =~ m/f/) {
3393 $flags_string = "<link linkend=\"G-SIGNAL-RUN-FIRST:CAPS\"><literal>Run First</literal></link>";
3395 elsif ($flags =~ m/l/) {
3396 $flags_string = "<link linkend=\"G-SIGNAL-RUN-LAST:CAPS\"><literal>Run Last</literal></link>";
3398 elsif ($flags =~ m/c/) {
3399 $flags_string = "<link linkend=\"G-SIGNAL-RUN-CLEANUP:CAPS\"><literal>Cleanup</literal></link>";
3400 $flags_string = "Cleanup";
3402 if ($flags =~ m/r/) {
3403 if ($flags_string) { $flags_string .= " / "; }
3404 $flags_string = "<link linkend=\"G-SIGNAL-NO-RECURSE:CAPS\"><literal>No Recursion</literal></link>";
3406 if ($flags =~ m/d/) {
3407 if ($flags_string) { $flags_string .= " / "; }
3408 $flags_string = "<link linkend=\"G-SIGNAL-DETAILED:CAPS\"><literal>Has Details</literal></link>";
3410 if ($flags =~ m/a/) {
3411 if ($flags_string) { $flags_string .= " / "; }
3412 $flags_string = "<link linkend=\"G-SIGNAL-ACTION:CAPS\"><literal>Action</literal></link>";
3414 if ($flags =~ m/h/) {
3415 if ($flags_string) { $flags_string .= " / "; }
3416 $flags_string = "<link linkend=\"G-SIGNAL-NO-HOOKS:CAPS\"><literal>No Hooks</literal></link>";
3422 $synop .= ": $flags_string\n";
3424 $pad = ' ' x (5 + $name_len - length("user_data"));
3425 $desc .= "$pad : $flags_string</programlisting>\n";
3430 $desc .= "</programlisting>\n";
3433 $desc .= &MakeDeprecationNote($symbol);
3435 my $parameters = &OutputParamDescriptions ("SIGNAL", $symbol);
3436 my $parameters_output = 0;
3438 $AllSymbols{$symbol} = 1;
3439 if (defined ($SymbolDocs{$symbol})) {
3440 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
3442 # Try to insert the parameter table at the author's desired
3443 # position. Otherwise we need to tag it onto the end.
3444 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
3445 $parameters_output = 1;
3447 $desc .= $symbol_docs;
3449 if (!IsEmptyDoc($SymbolDocs{$symbol})) {
3450 $AllDocumentedSymbols{$symbol} = 1;
3454 if ($parameters_output == 0) {
3455 $desc .= $parameters;
3457 $desc .= OutputSymbolTraits ($symbol);
3458 $desc .= "</refsect2>";
3461 return ($synop, $desc);
3465 #############################################################################
3466 # Function : GetArgs
3467 # Description : Returns the synopsis and detailed description DocBook output
3468 # for the Args of a given GtkObject subclass.
3469 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
3470 #############################################################################
3476 my $child_synop = "";
3477 my $child_desc = "";
3478 my $style_synop = "";
3479 my $style_desc = "";
3482 for ($i = 0; $i <= $#ArgObjects; $i++) {
3483 if ($ArgObjects[$i] eq $object) {
3484 #print "Found arg: $ArgNames[$i]\n";
3485 my $name = $ArgNames[$i];
3486 my $flags = $ArgFlags[$i];
3487 my $flags_string = "";
3491 if ($flags =~ m/c/) {
3492 $kind = "child property";
3495 elsif ($flags =~ m/s/) {
3496 $kind = "style property";
3503 # Remember only one colon so we don't clash with signals.
3504 my $symbol = "${object}:${name}";
3505 # use two dashes and ev. an extra separator here for the same reason.
3506 my $id = &CreateValidSGMLID ("$object--$id_sep$name");
3508 my $type = $ArgTypes[$i];
3510 my $range = $ArgRanges[$i];
3511 my $range_output = CreateValidSGML ($range);
3512 my $default = $ArgDefaults[$i];
3513 my $default_output = CreateValidSGML ($default);
3515 if ($type eq "GtkString") {
3518 if ($type eq "GtkSignal") {
3519 $type = "GtkSignalFunc, gpointer";
3520 $type_output = &MakeXRef ("GtkSignalFunc") . ", "
3521 . &MakeXRef ("gpointer");
3522 } elsif ($type =~ m/^(\w+)\*$/) {
3523 $type_output = &MakeXRef ($1, &tagify($1, "type")) . "*";
3525 $type_output = &MakeXRef ($type, &tagify($type, "type"));
3528 if ($flags =~ m/r/) {
3529 $flags_string = "Read";
3531 if ($flags =~ m/w/) {
3532 if ($flags_string) { $flags_string .= " / "; }
3533 $flags_string .= "Write";
3535 if ($flags =~ m/x/) {
3536 if ($flags_string) { $flags_string .= " / "; }
3537 $flags_string .= "Construct";
3539 if ($flags =~ m/X/) {
3540 if ($flags_string) { $flags_string .= " / "; }
3541 $flags_string .= "Construct Only";
3544 $AllSymbols{$symbol} = 1;
3546 if (defined($SymbolDocs{$symbol}) &&
3547 !IsEmptyDoc($SymbolDocs{$symbol})) {
3548 $blurb = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
3549 #print ".. [$SymbolDocs{$symbol}][$blurb]\n";
3550 $AllDocumentedSymbols{$symbol} = 1;
3553 if (!($ArgBlurbs[$i] eq "")) {
3554 $AllDocumentedSymbols{$symbol} = 1;
3556 # FIXME: print a warning?
3557 #print ".. no description\n";
3559 $blurb = "<para>" . &CreateValidSGML ($ArgBlurbs[$i]) . "</para>";
3562 my $pad1 = " " x (24 - length ($name));
3563 my $pad2 = " " x (20 - length ($type));
3565 my $arg_synop = " "<link linkend=\"$id\">$name</link>"$pad1 $type_output $pad2 : $flags_string\n";
3566 my $arg_desc = "<refsect2 id=\"$id\" role=\"property\"><title>The <literal>"$name"</literal> $kind</title>\n";
3567 $arg_desc .= MakeIndexterms($symbol, $id);
3569 $arg_desc .= OutputSymbolExtraLinks($symbol);
3571 $arg_desc .= "<programlisting> "$name"$pad1 $type_output $pad2 : $flags_string</programlisting>\n";
3572 $arg_desc .= &MakeDeprecationNote($symbol);
3573 $arg_desc .= $blurb;
3575 $arg_desc .= "<para>Allowed values: $range_output</para>\n";
3577 if ($default ne "") {
3578 $arg_desc .= "<para>Default value: $default_output</para>\n";
3580 $arg_desc .= OutputSymbolTraits ($symbol);
3581 $arg_desc .= "</refsect2>\n";
3583 if ($flags =~ m/c/) {
3584 $child_synop .= $arg_synop;
3585 $child_desc .= $arg_desc;
3587 elsif ($flags =~ m/s/) {
3588 $style_synop .= $arg_synop;
3589 $style_desc .= $arg_desc;
3592 $synop .= $arg_synop;
3597 return ($synop, $child_synop, $style_synop, $desc, $child_desc, $style_desc);
3601 #############################################################################
3602 # Function : ReadSourceDocumentation
3603 # Description : This reads in the documentation embedded in comment blocks
3604 # in the source code (for Gnome).
3606 # Parameter descriptions override any in the template files.
3607 # Function descriptions are placed before any description from
3608 # the template files.
3610 # It recursively descends the source directory looking for .c
3611 # files and scans them looking for specially-formatted comment
3614 # Arguments : $source_dir - the directory to scan.
3615 #############m###############################################################
3617 sub ReadSourceDocumentation {
3618 my ($source_dir) = @_;
3619 my ($file, $dir, @suffix_list, $suffix);
3621 # prepend entries from @SOURCE_DIR
3622 for my $dir (@SOURCE_DIRS) {
3623 # Check if the filename is in the ignore list.
3624 if ($source_dir =~ m%^\Q$dir\E/(.*)$% and $IGNORE_FILES =~ m/(\s|^)\Q$1\E(\s|$)/) {
3625 @TRACE@("Skipping source directory: $source_dir");
3630 @TRACE@("Scanning source directory: $source_dir");
3632 # This array holds any subdirectories found.
3635 @suffix_list = split (/,/, $SOURCE_SUFFIXES);
3637 opendir (SRCDIR, $source_dir)
3638 || die "Can't open source directory $source_dir: $!";
3640 foreach $file (readdir (SRCDIR)) {
3641 if ($file =~ /^\./) {
3643 } elsif (-d "$source_dir/$file") {
3644 push (@subdirs, $file);
3645 } elsif (@suffix_list) {
3646 foreach $suffix (@suffix_list) {
3647 if ($file =~ m/\.\Q${suffix}\E$/) {
3648 &ScanSourceFile ("$source_dir/$file");
3651 } elsif ($file =~ m/\.[ch]$/) {
3652 &ScanSourceFile ("$source_dir/$file");
3657 # Now recursively scan the subdirectories.
3658 foreach $dir (@subdirs) {
3659 &ReadSourceDocumentation ("$source_dir/$dir");
3664 #############################################################################
3665 # Function : ScanSourceFile
3666 # Description : Scans one source file looking for specially-formatted comment
3667 # blocks. Later &MergeSourceDocumentation is used to merge any
3668 # documentation found with the documentation already read in
3669 # from the template files.
3671 # Arguments : $file - the file to scan.
3672 #############################################################################
3674 sub ScanSourceFile {
3678 # prepend entries from @SOURCE_DIR
3679 for my $dir (@SOURCE_DIRS) {
3680 # Check if the filename is in the ignore list.
3681 if ($file =~ m%^\Q$dir\E/(.*)$% and $IGNORE_FILES =~ m/(\s|^)\Q$1\E(\s|$)/) {
3682 @TRACE@("Skipping source file: $file");
3687 if ($file =~ m/^.*[\/\\]([^\/\\]*)$/) {
3690 &LogWarning ($file, 1, "Can't find basename for this filename.");
3694 # Check if the basename is in the list of files to ignore.
3695 if ($IGNORE_FILES =~ m/(\s|^)\Q${basename}\E(\s|$)/) {
3696 @TRACE@("Skipping source file: $file");
3700 @TRACE@("Scanning source file: $file");
3702 open (SRCFILE, $file)
3703 || die "Can't open $file: $!";
3704 my $in_comment_block = 0;
3706 my ($in_description, $in_return, $in_since, $in_stability, $in_deprecated);
3707 my ($description, $return_desc, $return_start, $return_style);
3708 my ($since_desc, $stability_desc, $deprecated_desc);
3710 my $ignore_broken_returns;
3713 # Look for the start of a comment block.
3714 if (!$in_comment_block) {
3715 if (m%^\s*/\*.*\*/%) {
3716 #one-line comment - not gtkdoc
3717 } elsif (m%^\s*/\*\*\s%) {
3718 #print "Found comment block start\n";
3720 $in_comment_block = 1;
3722 # Reset all the symbol data.
3724 $in_description = 0;
3733 $deprecated_desc = "";
3734 $stability_desc = "";
3735 $current_param = -1;
3736 $ignore_broken_returns = 0;
3742 # We're in a comment block. Check if we've found the end of it.
3745 # maybe its not even meant to be a gtk-doc comment?
3746 &LogWarning ($file, $., "Symbol name not found at the start of the comment block.");
3748 # Add the return value description onto the end of the params.
3750 push (@params, "Returns");
3751 push (@params, $return_desc);
3752 if ($return_style eq 'broken') {
3753 &LogWarning ($file, $., "Free-form return value description in $symbol. Use `Returns:' to avoid ambiguities.");
3756 # Convert special SGML characters
3757 $description = &ConvertSGMLChars ($symbol, $description);
3759 for ($k = 1; $k <= $#params; $k += $PARAM_FIELD_COUNT) {
3760 $params[$k] = &ConvertSGMLChars ($symbol, $params[$k]);
3763 # Handle Section docs
3764 if ($symbol =~ m/SECTION:\s*(.*)/) {
3768 if (scalar %KnownSymbols) {
3769 if ((! defined($KnownSymbols{"$TMPL_DIR/$real_symbol:Long_Description"})) || $KnownSymbols{"$TMPL_DIR/$real_symbol:Long_Description"} != 1) {
3770 &LogWarning ($file, $., "Section $real_symbol is not defined in the $MODULE-section.txt file.");
3774 #print "SECTION DOCS found in source for : '$real_symbol'\n";
3775 $ignore_broken_returns = 1;
3776 for ($k = 0; $k <= $#params; $k += $PARAM_FIELD_COUNT) {
3777 #print " '".$params[$k]."'\n";
3778 $params[$k] = "\L$params[$k]";
3780 if ($params[$k] eq "short_description") {
3781 $key = "$TMPL_DIR/$real_symbol:Short_Description";
3782 } elsif ($params[$k] eq "see_also") {
3783 $key = "$TMPL_DIR/$real_symbol:See_Also";
3784 } elsif ($params[$k] eq "title") {
3785 $key = "$TMPL_DIR/$real_symbol:Title";
3786 } elsif ($params[$k] eq "stability") {
3787 $key = "$TMPL_DIR/$real_symbol:Stability_Level";
3788 } elsif ($params[$k] eq "section_id") {
3789 $key = "$TMPL_DIR/$real_symbol:Section_Id";
3790 } elsif ($params[$k] eq "include") {
3791 $key = "$TMPL_DIR/$real_symbol:Include";
3792 } elsif ($params[$k] eq "image") {
3793 $key = "$TMPL_DIR/$real_symbol:Image";
3795 if (defined($key)) {
3796 $SourceSymbolDocs{$key}=$params[$k+1];
3797 $SourceSymbolSourceFile{$key} = $file;
3798 $SourceSymbolSourceLine{$key} = $.;
3801 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Long_Description"}=$description;
3802 $SourceSymbolSourceFile{"$TMPL_DIR/$real_symbol:Long_Description"} = $file;
3803 $SourceSymbolSourceLine{"$TMPL_DIR/$real_symbol:Long_Description"} = $.;
3804 #$SourceSymbolTypes{$symbol} = "SECTION";
3806 #print "SYMBOL DOCS found in source for : '$symbol' ",length($description), "\n";
3807 $SourceSymbolDocs{$symbol} = $description;
3808 $SourceSymbolParams{$symbol} = [ @params ];
3809 # FIXME $SourceSymbolTypes{$symbol} = "STRUCT,SIGNAL,ARG,FUNCTION,MACRO";
3810 #if (defined $DeclarationTypes{$symbol}) {
3811 # $SourceSymbolTypes{$symbol} = $DeclarationTypes{$symbol}
3813 $SourceSymbolSourceFile{$symbol} = $file;
3814 $SourceSymbolSourceLine{$symbol} = $.;
3818 ($since_desc, my @extra_lines) = split ("\n", $since_desc);
3819 $since_desc =~ s/^\s+//;
3820 $since_desc =~ s/\s+$//;
3821 #print "Since($symbol) : [$since_desc]\n";
3822 $Since{$symbol} = &ConvertSGMLChars ($symbol, $since_desc);
3823 if(scalar @extra_lines) {
3824 &LogWarning ($file, $., "multi-line since docs found");
3828 if ($stability_desc) {
3829 $stability_desc = &ParseStabilityLevel($stability_desc, $file, $., "Stability level for $symbol");
3830 $StabilityLevel{$symbol} = &ConvertSGMLChars ($symbol, $stability_desc);
3833 if ($deprecated_desc) {
3834 if (exists $Deprecated{$symbol}) {
3837 # don't warn for signals and properties
3838 #if ($symbol !~ m/::?(.*)/) {
3839 if (defined $DeclarationTypes{$symbol}) {
3840 &LogWarning ($file, $.,
3841 "$symbol is deprecated in the inline comments, but no deprecation guards were found around the declaration.".
3842 " (See the --deprecated-guards option for gtkdoc-scan.)");
3845 $Deprecated{$symbol} = &ConvertSGMLChars ($symbol, $deprecated_desc);
3849 $in_comment_block = 0;
3853 # Get rid of ' * ' at start of every line in the comment block.
3855 # But make sure we don't get rid of the newline at the end.
3859 #print "DEBUG: scanning :$_";
3861 # If we haven't found the symbol name yet, look for it.
3863 if (m%^\s*(SECTION:\s*\S+)%) {
3865 #print "SECTION DOCS found in source for : '$symbol'\n";
3866 $ignore_broken_returns = 1;
3867 } elsif (m%^\s*([\w:-]*\w)\s*:?\s*(\([a-z ]+\)\s*)*$%) {
3869 #print "SYMBOL DOCS found in source for : '$symbol'\n";
3874 # If we're in the return value description, add it to the end.
3876 # If we find another valid returns line, we assume that the first
3877 # one was really part of the description.
3878 if (m/^\s*(returns:|return\s+value:)/i) {
3879 if ($return_style eq 'broken') {
3880 $description .= $return_start . $return_desc;
3883 if ($return_style eq 'sane') {
3884 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3886 $return_style = 'sane';
3887 $ignore_broken_returns = 1;
3889 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3890 $description .= $return_start . $return_desc;
3892 $return_style = 'broken';
3894 } elsif (m%^\s*since:%i) {
3898 } elsif (m%^\s*stability:%i) {
3899 $stability_desc = $';
3902 } elsif (m%^\s*deprecated:%i) {
3903 $deprecated_desc = $';
3913 if (m/^\s*(returns:|return\s+value:)/i) {
3914 if ($return_style eq 'broken') {
3915 $description .= $return_start . $return_desc;
3918 if ($return_style eq 'sane') {
3919 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3921 $return_style = 'sane';
3922 $ignore_broken_returns = 1;
3926 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3928 $return_style = 'broken';
3932 } elsif (m%^\s*deprecated:%i) {
3933 $deprecated_desc = $';
3936 } elsif (m%^\s*stability:%i) {
3937 $stability_desc = $';
3946 if ($in_stability) {
3947 if (m/^\s*(returns:|return\s+value:)/i) {
3948 if ($return_style eq 'broken') {
3949 $description .= $return_start . $return_desc;
3952 if ($return_style eq 'sane') {
3953 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3955 $return_style = 'sane';
3956 $ignore_broken_returns = 1;
3960 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3962 $return_style = 'broken';
3966 } elsif (m%^\s*deprecated:%i) {
3967 $deprecated_desc = $';
3970 } elsif (m%^\s*since:%i) {
3975 $stability_desc .= $_;
3980 if ($in_deprecated) {
3981 if (m/^\s*(returns:|return\s+value:)/i) {
3982 if ($return_style eq 'broken') {
3983 $description .= $return_start . $return_desc;
3986 if ($return_style eq 'sane') {
3987 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3989 $return_style = 'sane';
3990 $ignore_broken_returns = 1;
3994 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3996 $return_style = 'broken';
4000 } elsif (m%^\s*since:%i) {
4004 } elsif (m%^\s*stability:%i) {
4005 $stability_desc = $';
4009 $deprecated_desc .= $_;
4014 # If we're in the description part, check for the 'Returns:' line.
4015 # If that isn't found, add the text to the end.
4016 if ($in_description) {
4017 # Get rid of 'Description:'
4018 s%^\s*Description:%%;
4020 if (m/^\s*(returns:|return\s+value:)/i) {
4021 if ($return_style eq 'broken') {
4022 $description .= $return_start . $return_desc;
4025 if ($return_style eq 'sane') {
4026 &LogWarning ($file, $., "Multiple Returns for $symbol.");
4028 $return_style = 'sane';
4029 $ignore_broken_returns = 1;
4033 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
4035 $return_style = 'broken';
4039 } elsif (m%^\s*since:%i) {
4043 } elsif (m%^\s*deprecated:%i) {
4044 $deprecated_desc = $';
4047 } elsif (m%^\s*stability:%i) {
4048 $stability_desc = $';
4057 # We must be in the parameters. Check for the empty line below them.
4059 $in_description = 1;
4063 # Look for a parameter name.
4064 if (m%^\s*@(\S+)\s*:\s*%) {
4065 my $param_name = $1;
4066 my $param_desc = $';
4068 #print "Found parameter: $param_name\n";
4069 # Allow '...' as the Varargs parameter.
4070 if ($param_name eq "...") {
4071 $param_name = "Varargs";
4073 if ("\L$param_name" eq "returns") {
4074 $return_style = 'sane';
4075 $ignore_broken_returns = 1;
4077 push (@params, $param_name);
4078 push (@params, $param_desc);
4079 $current_param += $PARAM_FIELD_COUNT;
4083 # We must be in the middle of a parameter description, so add it on
4084 # to the last element in @params.
4085 if ($current_param == -1) {
4086 &LogWarning ($file, $., "Parsing comment block file : parameter expected.");
4088 $params[$#params] .= $_;
4094 #############################################################################
4095 # Function : OutputMissingDocumentation
4096 # Description : Outputs report of documentation coverage to a file
4099 #############################################################################
4101 sub OutputMissingDocumentation {
4102 my $old_undocumented_file = "$ROOT_DIR/$MODULE-undocumented.txt";
4103 my $new_undocumented_file = "$ROOT_DIR/$MODULE-undocumented.new";
4105 my $n_documented = 0;
4106 my $n_incomplete = 0;
4112 my $buffer_deprecated = "";
4113 my $buffer_descriptions = "";
4115 open(UNDOCUMENTED, ">$new_undocumented_file")
4116 || die "Can't create $new_undocumented_file";
4118 foreach $symbol (sort (keys (%AllSymbols))) {
4119 # FIXME: should we print LogWarnings for undocumented stuff?
4121 #my $ssfile = &GetSymbolSourceFile($symbol);
4122 #my $ssline = &GetSymbolSourceLine($symbol);
4123 #my $location = "defined at " . (defined($ssfile)?$ssfile:"?") . ":" . (defined($ssline)?$ssline:"0") . "\n";
4125 if ($symbol !~ /:(Title|Long_Description|Short_Description|See_Also|Stability_Level|Include|Section_Id|Image)/) {
4127 if (exists ($AllDocumentedSymbols{$symbol})) {
4129 if (exists ($AllIncompleteSymbols{$symbol})) {
4131 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4132 #$buffer .= "\t0: ".$location;
4134 } elsif (exists $Deprecated{$symbol}) {
4135 if (exists ($AllIncompleteSymbols{$symbol})) {
4137 $buffer_deprecated .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4138 #$buffer .= "\t1a: ".$location;
4140 $buffer_deprecated .= $symbol . "\n";
4141 #$buffer .= "\t1b: ".$location;
4144 if (exists ($AllIncompleteSymbols{$symbol})) {
4146 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4147 #$buffer .= "\t2a: ".$location;
4149 $buffer .= $symbol . "\n";
4150 #$buffer .= "\t2b: ".$location;
4153 } elsif ($symbol =~ /:(Long_Description|Short_Description)/) {
4155 #my $len1=(exists($SymbolDocs{$symbol}))?length($SymbolDocs{$symbol}):-1;
4156 #my $len2=(exists($AllDocumentedSymbols{$symbol}))?length($AllDocumentedSymbols{$symbol}):-1;
4157 #print "%%%% $symbol : $len1,$len2\n";
4158 if (((exists ($SymbolDocs{$symbol})) && (length ($SymbolDocs{$symbol}) > 0))
4159 || ((exists ($AllDocumentedSymbols{$symbol})) && (length ($AllDocumentedSymbols{$symbol}) > 0))) {
4162 # cut off the leading namespace ($TMPL_DIR)
4163 $symbol =~ m/^.*\/(.*)$/;
4164 $buffer_descriptions .= $1 . "\n";
4169 $buffer .= "\n" . $buffer_deprecated . "\n" . $buffer_descriptions;
4174 $percent = ($n_documented / $total) * 100.0;
4177 printf UNDOCUMENTED "%.0f%% symbol docs coverage.\n", $percent;
4178 print UNDOCUMENTED "$n_documented symbols documented.\n";
4179 print UNDOCUMENTED "$n_incomplete symbols incomplete.\n";
4180 print UNDOCUMENTED ($total - $n_documented) . " not documented.\n\n\n";
4182 print UNDOCUMENTED $buffer;
4183 close (UNDOCUMENTED);
4185 return &UpdateFileIfChanged ($old_undocumented_file, $new_undocumented_file, 0);
4187 printf "%.0f%% symbol docs coverage", $percent;
4188 print "($n_documented symbols documented, $n_incomplete symbols incomplete, " . ($total - $n_documented) . " not documented)\n";
4189 print "See $MODULE-undocumented.txt for a list of missing docs.\nThe doc coverage percentage doesn't include intro sections.\n";
4193 #############################################################################
4194 # Function : OutputUndeclaredSymbols
4195 # Description : Outputs symbols that are listed in the section file, but not
4196 # declaration is found in the sources
4199 #############################################################################
4201 sub OutputUndeclaredSymbols {
4202 my $old_undeclared_file = "$ROOT_DIR/$MODULE-undeclared.txt";
4203 my $new_undeclared_file = "$ROOT_DIR/$MODULE-undeclared.new";
4205 open(UNDECLARED, ">$new_undeclared_file")
4206 || die "Can't create $new_undeclared_file";
4208 if (%UndeclaredSymbols) {
4209 print UNDECLARED (join("\n", sort keys %UndeclaredSymbols));
4210 print UNDECLARED "\n";
4211 print "See $MODULE-undeclared.txt for the list of undeclared symbols.\n"
4215 return &UpdateFileIfChanged ($old_undeclared_file, $new_undeclared_file, 0);
4218 #############################################################################
4219 # Function : OutputUnusedSymbols
4220 # Description : Outputs symbols that are documented in comments, but not
4221 # declared in the sources
4224 #############################################################################
4226 sub OutputUnusedSymbols {
4228 my $old_unused_file = "$ROOT_DIR/$MODULE-unused.txt";
4229 my $new_unused_file = "$ROOT_DIR/$MODULE-unused.new";
4231 open (UNUSED, ">$new_unused_file")
4232 || die "Can't open $new_unused_file";
4234 foreach $symbol (sort keys (%Declarations)) {
4235 if (!defined ($DeclarationOutput{$symbol})) {
4236 print (UNUSED "$symbol\n");
4240 foreach $symbol (sort (keys (%AllUnusedSymbols))) {
4241 print (UNUSED "$symbol(" . $AllUnusedSymbols{$symbol} . ")\n");
4245 if ($num_unused != 0) {
4246 &LogWarning ($old_unused_file, 1, "$num_unused unused declarations.".
4247 "They should be added to $MODULE-sections.txt in the appropriate place.");
4250 return &UpdateFileIfChanged ($old_unused_file, $new_unused_file, 0);
4254 #############################################################################
4255 # Function : OutputAllSymbols
4256 # Description : Outputs list of all symbols to a file
4259 #############################################################################
4261 sub OutputAllSymbols {
4262 my $n_documented = 0;
4268 open (SYMBOLS, ">$ROOT_DIR/$MODULE-symbols.txt")
4269 || die "Can't create $ROOT_DIR/$MODULE-symbols.txt: $!";
4271 foreach $symbol (sort (keys (%AllSymbols))) {
4272 print SYMBOLS $symbol . "\n";
4278 #############################################################################
4279 # Function : OutputSymbolsWithoutSince
4280 # Description : Outputs list of all symbols without a since tag to a file
4283 #############################################################################
4285 sub OutputSymbolsWithoutSince {
4286 my $n_documented = 0;
4292 open (SYMBOLS, ">$ROOT_DIR/$MODULE-nosince.txt")
4293 || die "Can't create $ROOT_DIR/$MODULE-nosince.txt: $!";
4295 foreach $symbol (sort (keys (%SourceSymbolDocs))) {
4296 if (!defined $Since{$symbol}) {
4297 print SYMBOLS $symbol . "\n";
4305 #############################################################################
4306 # Function : MergeSourceDocumentation
4307 # Description : This merges documentation read from a source file into the
4308 # documentation read in from a template file.
4310 # Parameter descriptions override any in the template files.
4311 # Function descriptions are placed before any description from
4312 # the template files.
4315 #############################################################################
4317 sub MergeSourceDocumentation {
4321 if (scalar %SymbolDocs) {
4322 @Symbols=keys (%SymbolDocs);
4323 #print "num existing entries: ".(scalar @Symbols)."\n";
4324 #print " ",$Symbols[0], " ",$Symbols[1],"\n";
4327 # filter scanned declarations, with what we suppress from -sections.txt
4329 foreach $symbol (keys (%Declarations)) {
4330 if (defined($KnownSymbols{$symbol}) && $KnownSymbols{$symbol} == 1) {
4334 # , add the rest from -sections.txt
4335 foreach $symbol (keys (%KnownSymbols)) {
4336 if ($KnownSymbols{$symbol} == 1) {
4340 # and add whats found in the source
4341 foreach $symbol (keys (%SourceSymbolDocs)) {
4344 @Symbols = keys (%tmp);
4345 #print "num source entries: ".(scalar @Symbols)."\n";
4347 foreach $symbol (@Symbols) {
4348 $AllSymbols{$symbol} = 1;
4350 my $have_tmpl_docs = 0;
4352 ## see if the symbol is documented in template
4353 my $tmpl_doc = defined ($SymbolDocs{$symbol}) ? $SymbolDocs{$symbol} : "";
4354 my $check_tmpl_doc =$tmpl_doc;
4355 # remove all xml-tags and whitespaces
4356 $check_tmpl_doc =~ s/<.*?>//g;
4357 $check_tmpl_doc =~ s/\s//g;
4359 if ($check_tmpl_doc ne "") {
4360 $have_tmpl_docs = 1;
4361 #print "## [$check_tmpl_doc]\n";
4363 # if the docs have just an empty para, don't merge that.
4364 $check_tmpl_doc = $tmpl_doc;
4365 $check_tmpl_doc =~ s/(\s|\n)//msg;
4366 if ($check_tmpl_doc eq "<para></para>") {
4371 if (exists ($SourceSymbolDocs{$symbol})) {
4372 my $type = $DeclarationTypes {$symbol};
4374 #print "merging [$symbol] from source\n";
4376 my $item = "Parameter";
4377 if (defined ($type)) {
4378 if ($type eq 'STRUCT') {
4380 } elsif ($type eq 'ENUM') {
4382 } elsif ($type eq 'UNION') {
4389 my $src_doc = $SourceSymbolDocs{$symbol};
4390 # remove leading and training whitespaces
4391 $src_doc =~ s/^\s+//;
4392 $src_doc =~ s/\s+$//;
4394 # Don't output warnings for overridden titles as titles are
4395 # automatically generated in the -sections.txt file, and thus they
4396 # are often overridden.
4397 if ($have_tmpl_docs && $symbol !~ m/:Title$/) {
4398 # check if content is different
4399 if ($tmpl_doc ne $src_doc) {
4400 #print "[$tmpl_doc] [$src_doc]\n";
4401 &LogWarning ($SourceSymbolSourceFile{$symbol}, $SourceSymbolSourceLine{$symbol},
4402 "Documentation in template ".$SymbolSourceFile{$symbol}.":".$SymbolSourceLine{$symbol}." for $symbol being overridden by inline comments.");
4406 if ($src_doc ne "") {
4407 $AllDocumentedSymbols{$symbol} = 1;
4410 # Convert <!--PARAMETERS--> with any blank lines around it to
4411 # a </para> followed by <!--PARAMETERS--> followed by <para>.
4412 $src_doc =~ s%\n+\s*<!--PARAMETERS-->\s*\n+%\n</para>\n<!--PARAMETERS-->\n<para>\n%g;
4414 # Do not add <para> to nothing, it breaks missing docs checks.
4415 my $src_doc_para = "";
4416 if ($src_doc ne "") {
4417 # Expand markdown (and do paragraphs)
4418 $src_doc_para = &ConvertMarkDown ($src_doc, $symbol);
4420 # FIXME: this is questionable, as we can't make assumtions on the content really
4421 #$src_doc_para =~ s%^<para>\n(<refsect[1-9])%$1%gms;
4422 #$src_doc_para =~ s%^<para>\n<para>%<para>%gms;
4423 #$src_doc_para =~ s%(</refsect[1-9]>)\n</para>$%$1%gms;
4424 #print "$symbol : [$src_doc][$src_doc_para]\n";
4427 if ($symbol =~ m/$TMPL_DIR\/.+:Long_Description/) {
4428 $SymbolDocs{$symbol} = "$src_doc_para$tmpl_doc";
4429 } elsif ($symbol =~ m/$TMPL_DIR\/.+:.+/) {
4430 # For the title/summary/see also section docs we don't want to
4431 # add any <para> tags.
4432 $SymbolDocs{$symbol} = "$src_doc"
4434 $SymbolDocs{$symbol} = "$src_doc_para$tmpl_doc";
4438 if ($symbol =~ m/.*::.*/) {
4439 # For signals we prefer the param names from the source docs,
4440 # since the ones from the templates are likely to contain the
4441 # artificial argn names which are generated by gtkdoc-scangobj.
4442 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
4443 # FIXME: we need to check for empty docs here as well!
4445 # The templates contain the definitive parameter names and order,
4446 # so we will not change that. We only override the actual text.
4447 my $tmpl_params = $SymbolParams{$symbol};
4448 if (!defined ($tmpl_params)) {
4449 #print "No merge needed for $symbol\n";
4450 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
4451 # FIXME: we still like to get the number of params and merge
4452 # 1) we would noticed that params have been removed/renamed
4453 # 2) we would catch undocumented params
4454 # params are not (yet) exported in -decl.txt so that we
4455 # could easily grab them :/
4457 my $params = $SourceSymbolParams{$symbol};
4459 #print "Merge needed for $symbol, tmpl_params: ",$#$tmpl_params,", source_params: ",$#$params," \n";
4460 for ($j = 0; $j <= $#$tmpl_params; $j += $PARAM_FIELD_COUNT) {
4461 my $tmpl_param_name = $$tmpl_params[$j];
4463 # Allow '...' as the Varargs parameter.
4464 if ($tmpl_param_name eq "...") {
4465 $tmpl_param_name = "Varargs";
4468 # Try to find the param in the source comment documentation.
4471 #print " try merge param $tmpl_param_name\n";
4472 for ($k = 0; $k <= $#$params; $k += $PARAM_FIELD_COUNT) {
4473 my $param_name = $$params[$k];
4474 my $param_desc = $$params[$k + 1];
4476 #print " test param $param_name\n";
4477 # We accept changes in case, since the Gnome source
4478 # docs contain a lot of these.
4479 if ("\L$param_name" eq "\L$tmpl_param_name") {
4482 # Override the description.
4483 $$tmpl_params[$j + 1] = $param_desc;
4485 # Set the name to "" to mark it as used.
4491 # If it looks like the parameters are there, but not
4492 # in the right place, try to explain a bit better.
4493 if ((!$found) && ($src_doc =~ m/\@$tmpl_param_name:/)) {
4494 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4495 "Parameters for $symbol must start on the line immediately after the function or macro name.");
4499 # Now we output a warning if parameters have been described which
4501 for ($j = 0; $j <= $#$params; $j += $PARAM_FIELD_COUNT) {
4502 my $param_name = $$params[$j];
4504 # the template builder cannot detect if a macro returns
4506 if(($type eq "MACRO") && ($param_name eq "Returns")) {
4507 # FIXME: do we need to add it then to tmpl_params[] ?
4508 my $num=$#$tmpl_params;
4509 #print " adding Returns: to macro docs for $symbol.\n";
4510 $$tmpl_params[$num+1]="Returns";
4511 $$tmpl_params[$num+2]=$$params[$j+1];
4514 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4515 "$item described in source code comment block but does not exist. $type: $symbol $item: $param_name.");
4521 if ($have_tmpl_docs) {
4522 $AllDocumentedSymbols{$symbol} = 1;
4523 #print "merging [$symbol] from template\n";
4526 #print "[$symbol] undocumented\n";
4530 # if this symbol is documented, check if docs are complete
4531 $check_tmpl_doc = defined ($SymbolDocs{$symbol}) ? $SymbolDocs{$symbol} : "";
4532 # remove all xml-tags and whitespaces
4533 $check_tmpl_doc =~ s/<.*?>//g;
4534 $check_tmpl_doc =~ s/\s//g;
4535 if ($check_tmpl_doc ne "") {
4536 my $tmpl_params = $SymbolParams{$symbol};
4537 if (defined ($tmpl_params)) {
4538 my $type = $DeclarationTypes {$symbol};
4540 my $item = "Parameter";
4541 if (defined ($type)) {
4542 if ($type eq 'STRUCT') {
4544 } elsif ($type eq 'ENUM') {
4546 } elsif ($type eq 'UNION') {
4553 #print "Check param docs for $symbol, tmpl_params: ",$#$tmpl_params," entries, type=$type\n";
4555 if ($#$tmpl_params > 0) {
4557 for ($j = 0; $j <= $#$tmpl_params; $j += $PARAM_FIELD_COUNT) {
4558 # Output a warning if the parameter is empty and
4559 # remember for stats.
4560 my $tmpl_param_name = $$tmpl_params[$j];
4561 my $tmpl_param_desc = $$tmpl_params[$j + 1];
4562 if ($tmpl_param_name ne "void" && $tmpl_param_desc !~ m/\S/) {
4563 if (exists ($AllIncompleteSymbols{$symbol})) {
4564 $AllIncompleteSymbols{$symbol}.=", ".$tmpl_param_name;
4566 $AllIncompleteSymbols{$symbol}=$tmpl_param_name;
4568 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4569 "$item description for $symbol"."::"."$tmpl_param_name is missing in source code comment block.");
4574 if ($#$tmpl_params == 0) {
4575 $AllIncompleteSymbols{$symbol}="<items>";
4576 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4577 "$item descriptions for $symbol are missing in source code comment block.");
4579 # $#$tmpl_params==-1 means we don't know about parameters
4580 # this unfortunately does not tell if there should be some
4585 #print "num doc entries: ".(scalar %SymbolDocs)."\n";
4588 #############################################################################
4589 # Function : IsEmptyDoc
4590 # Description : Check if a doc-string is empty. Its also regarded as empty if
4591 # it only consist of whitespace or e.g. FIXME.
4592 # Arguments : the doc-string
4593 #############################################################################
4597 if ($doc =~ /^\s*$/) {
4601 if ($doc =~ /^\s*<para>\s*(FIXME)?\s*<\/para>\s*$/) {
4609 #############################################################################
4610 # Function : ConvertMarkDown
4611 # Description : Converts mark down syntax to the respective docbook, but only
4612 # outside CDATA and <programlisting> tags.
4613 # http://de.wikipedia.org/wiki/Markdown
4614 # Code snippets have been takesn from
4615 # http://daringfireball.net/projects/markdown/
4616 # Copyright (c) 2004 John Gruber
4617 # Arguments : the doc-string, the symbol name
4618 #############################################################################
4620 sub ConvertMarkDown {
4621 my ($text, $symbol) = @_;
4627 $text = &ModifyXMLElements ($text, $symbol,
4628 "<!\\[CDATA\\[|<programlisting[^>]*>|\\|\\[",
4629 \&ConvertMarkDownEndTag,
4630 \&ConvertMarkDownCallback);
4631 # encapsulate and terminate
4632 $text = "<para>\n$text\n</para>";
4633 if ($md_in_refsect2==1) {
4634 $text = "$text</refsect2>"
4639 sub ConvertMarkDownEndTag {
4640 if ($_[0] eq "<!\[CDATA\[") {
4642 } elsif ($_[0] eq "|[") {
4645 return "</programlisting>";
4649 sub ConvertMarkDownCallback {
4650 my ($text, $symbol, $tag) = @_;
4652 # If we're not in CDATA or a <programlisting> we convert blank lines so
4653 # they start a new <para>.
4656 my $end_of_section="";
4659 $end_of_para = "$end_of_para</para>";
4660 $end_of_section = "$end_of_section</para>";
4661 if ($md_in_refsect2==1) {
4662 $end_of_section= "$end_of_section</refsect2>";
4665 # Setext-style headers:
4672 if($text =~ s%^\n(.+)[ \t]*\n=+[ \t]*\n\n%$end_of_section<refsect2><title>$1</title><para>\n%gm) {
4676 # atx-style headers:
4679 # ## Header 2 with closing hashes ##
4683 if($text =~ s%^\n\#[ \t]*(.+?)[ \t]*\#\n+%$end_of_section<refsect2><title>$1</title><para>\n%gm) {
4687 # Simple (unnested) lists:
4690 # - item 2 with loooong
4695 $text.="\n"; # we need a new line to avoid too complicated matching rules below
4696 if ($text =~ s%(?<=\n)-\s+(.+?)(?=(?:\n-\s+)|(?:\n\n)|(?:\n$))%<listitem><para>$1</para></listitem>%gs) {
4697 $text =~ s%(?<!</listitem>)(\n<listitem>)%\n<itemizedlist>$1%g;
4698 $text =~ s%(</listitem>\n)(?!<listitem>)%$1</itemizedlist>\n%g;
4702 # Make Paragraphs on blank lines
4703 $text =~ s%\n{2,}%\n$end_of_para\n<para>\n%g;
4710 #############################################################################
4711 # LIBRARY FUNCTIONS - These functions are used in both gtkdoc-mkdb and
4712 # gtkdoc-mktmpl and should eventually be moved to a
4714 #############################################################################
4716 #############################################################################
4717 # Function : ReadDeclarationsFile
4718 # Description : This reads in a file containing the function/macro/enum etc.
4721 # Note that in some cases there are several declarations with
4722 # the same name, e.g. for conditional macros. In this case we
4723 # set a flag in the %DeclarationConditional hash so the
4724 # declaration is not shown in the docs.
4726 # If a macro and a function have the same name, e.g. for
4727 # gtk_object_ref, the function declaration takes precedence.
4729 # Some opaque structs are just declared with 'typedef struct
4730 # _name name;' in which case the declaration may be empty.
4731 # The structure may have been found later in the header, so
4732 # that overrides the empty declaration.
4734 # Arguments : $file - the declarations file to read
4735 # $override - if declarations in this file should override
4736 # any current declaration.
4737 #############################################################################
4739 sub ReadDeclarationsFile {
4740 my ($file, $override) = @_;
4742 if ($override == 0) {
4744 %DeclarationTypes = ();
4745 %DeclarationConditional = ();
4746 %DeclarationOutput = ();
4750 || die "Can't open $file: $!";
4751 my $declaration_type = "";
4752 my $declaration_name;
4754 my $is_deprecated = 0;
4756 if (!$declaration_type) {
4757 if (m/^<([^>]+)>/) {
4758 $declaration_type = $1;
4759 $declaration_name = "";
4760 #print "Found declaration: $declaration_type\n";
4764 if (m%^<NAME>(.*)</NAME>%) {
4765 $declaration_name = $1;
4766 } elsif (m%^<DEPRECATED/>%) {
4768 } elsif (m%^</$declaration_type>%) {
4769 #print "Found end of declaration: $declaration_name\n";
4770 # Check that the declaration has a name
4771 if ($declaration_name eq "") {
4772 print "ERROR: $declaration_type has no name $file:$.\n";
4775 # If the declaration is an empty typedef struct _XXX XXX
4776 # set the flag to indicate the struct has a typedef.
4777 if ($declaration_type eq 'STRUCT'
4778 && $declaration =~ m/^\s*$/) {
4779 #print "Struct has typedef: $declaration_name\n";
4780 $StructHasTypedef{$declaration_name} = 1;
4783 # Check if the symbol is already defined.
4784 if (defined ($Declarations{$declaration_name})
4785 && $override == 0) {
4786 # Function declarations take precedence.
4787 if ($DeclarationTypes{$declaration_name} eq 'FUNCTION') {
4789 } elsif ($declaration_type eq 'FUNCTION') {
4790 if ($is_deprecated) {
4791 $Deprecated{$declaration_name} = "";
4793 $Declarations{$declaration_name} = $declaration;
4794 $DeclarationTypes{$declaration_name} = $declaration_type;
4795 } elsif ($DeclarationTypes{$declaration_name}
4796 eq $declaration_type) {
4797 # If the existing declaration is empty, or is just a
4798 # forward declaration of a struct, override it.
4799 if ($declaration_type eq 'STRUCT') {
4800 if ($Declarations{$declaration_name} =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
4801 if ($is_deprecated) {
4802 $Deprecated{$declaration_name} = "";
4804 $Declarations{$declaration_name} = $declaration;
4805 } elsif ($declaration =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
4806 # Ignore an empty or forward declaration.
4808 &LogWarning ($file, $., "Structure $declaration_name has multiple definitions.");
4811 # set flag in %DeclarationConditional hash for
4812 # multiply defined macros/typedefs.
4813 $DeclarationConditional{$declaration_name} = 1;
4816 &LogWarning ($file, $., "$declaration_name has multiple definitions.");
4819 if ($is_deprecated) {
4820 $Deprecated{$declaration_name} = "";
4822 $Declarations{$declaration_name} = $declaration;
4823 $DeclarationTypes{$declaration_name} = $declaration_type;
4826 $declaration_type = "";
4837 #############################################################################
4838 # Function : ReadSignalsFile
4839 # Description : This reads in an existing file which contains information on
4840 # all GTK signals. It creates the arrays @SignalNames and
4841 # @SignalPrototypes containing info on the signals. The first
4842 # line of the SignalPrototype is the return type of the signal
4843 # handler. The remaining lines are the parameters passed to it.
4844 # The last parameter, "gpointer user_data" is always the same
4845 # so is not included.
4846 # Arguments : $file - the file containing the signal handler prototype
4848 #############################################################################
4850 sub ReadSignalsFile {
4858 my $signal_prototype;
4860 # Reset the signal info.
4861 @SignalObjects = ();
4863 @SignalReturns = ();
4865 @SignalPrototypes = ();
4870 if (!open (INPUT, $file)) {
4871 warn "Can't open $file - skipping signals\n";
4878 $signal_object = "";
4880 $signal_returns = "";
4881 $signal_prototype = "";
4884 if (m/^<NAME>(.*)<\/NAME>/) {
4886 if ($signal_name =~ m/^(.*)::(.*)$/) {
4887 $signal_object = $1;
4888 ($signal_name = $2) =~ s/_/-/g;
4889 #print "Found signal: $signal_name\n";
4891 &LogWarning ($file, $., "Invalid signal name: $signal_name.");
4893 } elsif (m/^<RETURNS>(.*)<\/RETURNS>/) {
4894 $signal_returns = $1;
4895 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
4897 } elsif (m%^</SIGNAL>%) {
4898 #print "Found end of signal: ${signal_object}::${signal_name}\nReturns: ${signal_returns}\n${signal_prototype}";
4899 push (@SignalObjects, $signal_object);
4900 push (@SignalNames, $signal_name);
4901 push (@SignalReturns, $signal_returns);
4902 push (@SignalFlags, $signal_flags);
4903 push (@SignalPrototypes, $signal_prototype);
4906 $signal_prototype .= $_;
4914 #############################################################################
4915 # Function : ReadTemplateFile
4916 # Description : This reads in the manually-edited documentation file
4917 # corresponding to the file currently being created, so we can
4918 # insert the documentation at the appropriate places.
4919 # It outputs %SymbolTypes, %SymbolDocs and %SymbolParams, which
4920 # is a hash of arrays.
4921 # NOTE: This function is duplicated in gtkdoc-mktmpl (but
4922 # slightly different).
4923 # Arguments : $docsfile - the template file to read in.
4924 # $skip_unused_params - 1 if the unused parameters should be
4926 #############################################################################
4928 sub ReadTemplateFile {
4929 my ($docsfile, $skip_unused_params) = @_;
4931 my $template = "$docsfile.sgml";
4932 if (! -f $template) {
4933 #print "File doesn't exist: $template\n";
4936 #print "Reading $template\n";
4938 # start with empty hashes, we merge the source comment for each file
4944 my $current_type = ""; # Type of symbol being read.
4945 my $current_symbol = ""; # Name of symbol being read.
4946 my $symbol_doc = ""; # Description of symbol being read.
4947 my @params; # Parameter names and descriptions of current
4948 # function/macro/function typedef.
4949 my $current_param = -1; # Index of parameter currently being read.
4950 # Note that the param array contains pairs
4951 # of param name & description.
4952 my $in_unused_params = 0; # True if we are reading in the unused params.
4953 my $in_deprecated = 0;
4955 my $in_stability = 0;
4957 open (DOCS, "$template")
4958 || die "Can't open $template: $!";
4960 if (m/^<!-- ##### ([A-Z_]+) (\S+) ##### -->/) {
4963 if ($symbol eq "Title"
4964 || $symbol eq "Short_Description"
4965 || $symbol eq "Long_Description"
4966 || $symbol eq "See_Also"
4967 || $symbol eq "Stability_Level"
4968 || $symbol eq "Include"
4969 || $symbol eq "Image") {
4971 $symbol = $docsfile . ":" . $symbol;
4974 #print "Found symbol: $symbol\n";
4975 # Remember file and line for the symbol
4976 $SymbolSourceFile{$symbol} = $template;
4977 $SymbolSourceLine{$symbol} = $.;
4979 # Store previous symbol, but remove any trailing blank lines.
4980 if ($current_symbol ne "") {
4981 $symbol_doc =~ s/\s+$//;
4982 $SymbolTypes{$current_symbol} = $current_type;
4983 $SymbolDocs{$current_symbol} = $symbol_doc;
4985 # Check that the stability level is valid.
4986 if ($StabilityLevel{$current_symbol}) {
4987 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, $template, $., "Stability level for $current_symbol");
4990 if ($current_param >= 0) {
4991 $SymbolParams{$current_symbol} = [ @params ];
4993 # Delete any existing params in case we are overriding a
4994 # previously read template.
4995 delete $SymbolParams{$current_symbol};
4998 $current_type = $type;
4999 $current_symbol = $symbol;
5000 $current_param = -1;
5001 $in_unused_params = 0;
5008 } elsif (m/^<!-- # Unused Parameters # -->/) {
5009 #print "DEBUG: Found unused parameters\n";
5010 $in_unused_params = 1;
5013 } elsif ($in_unused_params && $skip_unused_params) {
5014 # When outputting the DocBook we skip unused parameters.
5015 #print "DEBUG: Skipping unused param: $_";
5019 # Check if param found. Need to handle "..." and "format...".
5020 if (s/^\@([\w\.]+):\040?//) {
5021 my $param_name = $1;
5022 my $param_desc = $_;
5023 # Allow variations of 'Returns'
5024 if ($param_name =~ m/^[Rr]eturns?$/) {
5025 $param_name = "Returns";
5028 # strip trailing whitespaces and blank lines
5031 #print "Found param for symbol $current_symbol : '$param_name'= '$_'";
5033 if ($param_name eq "Deprecated") {
5035 $Deprecated{$current_symbol} = $_;
5036 } elsif ($param_name eq "Since") {
5039 $Since{$current_symbol} = $_;
5040 } elsif ($param_name eq "Stability") {
5042 $StabilityLevel{$current_symbol} = $_;
5044 push (@params, $param_name);
5045 push (@params, $param_desc);
5046 $current_param += $PARAM_FIELD_COUNT;
5049 # strip trailing whitespaces and blank lines
5054 if ($in_deprecated) {
5055 $Deprecated{$current_symbol} .= $_;
5056 } elsif ($in_since) {
5057 &LogWarning ($template, $., "multi-line since docs found");
5058 #$Since{$current_symbol} .= $_;
5059 } elsif ($in_stability) {
5060 $StabilityLevel{$current_symbol} .= $_;
5061 } elsif ($current_param >= 0) {
5062 $params[$current_param] .= $_;
5071 # Remember to finish the current symbol doccs.
5072 if ($current_symbol ne "") {
5074 $symbol_doc =~ s/\s+$//;
5075 $SymbolTypes{$current_symbol} = $current_type;
5076 $SymbolDocs{$current_symbol} = $symbol_doc;
5078 # Check that the stability level is valid.
5079 if ($StabilityLevel{$current_symbol}) {
5080 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, $template, $., "Stability level for $current_symbol");
5083 if ($current_param >= 0) {
5084 $SymbolParams{$current_symbol} = [ @params ];
5086 # Delete any existing params in case we are overriding a
5087 # previously read template.
5088 delete $SymbolParams{$current_symbol};
5097 #############################################################################
5098 # Function : ReadObjectHierarchy
5099 # Description : This reads in the $MODULE-hierarchy.txt file containing all
5100 # the GtkObject subclasses described in this module (and their
5102 # It places them in the @Objects array, and places their level
5103 # in the object hierarchy in the @ObjectLevels array, at the
5104 # same index. GtkObject, the root object, has a level of 1.
5106 # FIXME: the version in gtkdoc-mkdb also generates tree_index.sgml
5107 # as it goes along, this should be split out into a separate
5111 #############################################################################
5113 sub ReadObjectHierarchy {
5117 if (! -f $OBJECT_TREE_FILE) {
5120 if (!open (INPUT, $OBJECT_TREE_FILE)) {
5121 warn "Can't open $OBJECT_TREE_FILE - skipping object tree\n";
5125 # FIXME: use $OUTPUT_FORMAT
5126 # my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.$OUTPUT_FORMAT";
5127 my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.sgml";
5128 my $new_tree_index = "$SGML_OUTPUT_DIR/tree_index.new";
5130 open (OUTPUT, ">$new_tree_index")
5131 || die "Can't create $new_tree_index: $!";
5133 if ($OUTPUT_FORMAT eq "xml") {
5134 my $tree_header = $doctype_header;
5136 $tree_header =~ s/<!DOCTYPE \w+/<!DOCTYPE screen/;
5137 print (OUTPUT "$tree_header");
5139 print (OUTPUT "<screen>\n");
5141 # Only emit objects if they are supposed to be documented, or if
5142 # they have documented children. To implement this, we maintain a
5143 # stack of pending objects which will be emitted if a documented
5145 my @pending_objects = ();
5146 my @pending_levels = ();
5150 my $level = (length($`)) / 2 + 1;
5153 while (($#pending_levels >= 0) && ($pending_levels[$#pending_levels] >= $level)) {
5154 my $pobject = pop(@pending_objects);
5155 my $plevel = pop(@pending_levels);
5158 push (@pending_objects, $object);
5159 push (@pending_levels, $level);
5161 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
5162 while ($#pending_levels >= 0) {
5163 $object = shift @pending_objects;
5164 $level = shift @pending_levels;
5165 $xref = &MakeXRef ($object);
5167 print (OUTPUT ' ' x ($level * 4), "$xref\n");
5168 push (@Objects, $object);
5169 push (@ObjectLevels, $level);
5173 # LogWarning ($OBJECT_TREE_FILE, $., "unknown type $object");
5177 print (OUTPUT "</screen>\n");
5182 &UpdateFileIfChanged ($old_tree_index, $new_tree_index, 0);
5187 #############################################################################
5188 # Function : ReadInterfaces
5189 # Description : This reads in the $MODULE.interfaces file.
5192 #############################################################################
5194 sub ReadInterfaces {
5197 if (! -f $INTERFACES_FILE) {
5200 if (!open (INPUT, $INTERFACES_FILE)) {
5201 warn "Can't open $INTERFACES_FILE - skipping interfaces\n";
5207 my ($object, @ifaces) = split;
5208 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
5209 my @knownIfaces = ();
5211 # filter out private interfaces, but leave foreign interfaces
5212 foreach my $iface (@ifaces) {
5213 if (!exists($KnownSymbols{$iface}) || $KnownSymbols{$iface} == 1) {
5214 push (@knownIfaces, $iface);
5218 $Interfaces{$object} = join(' ', @knownIfaces);
5224 #############################################################################
5225 # Function : ReadPrerequisites
5226 # Description : This reads in the $MODULE.prerequisites file.
5229 #############################################################################
5231 sub ReadPrerequisites {
5232 %Prerequisites = ();
5234 if (! -f $PREREQUISITES_FILE) {
5237 if (!open (INPUT, $PREREQUISITES_FILE)) {
5238 warn "Can't open $PREREQUISITES_FILE - skipping prerequisites\n";
5244 my ($iface, @prereqs) = split;
5245 if (exists($KnownSymbols{$iface}) && $KnownSymbols{$iface} == 1) {
5246 my @knownPrereqs = ();
5248 # filter out private prerequisites, but leave foreign prerequisites
5249 foreach my $prereq (@prereqs) {
5250 if (!exists($KnownSymbols{$prereq}) || $KnownSymbols{$prereq} == 1) {
5251 push (@knownPrereqs, $prereq);
5255 $Prerequisites{$iface} = join(' ', @knownPrereqs);
5261 #############################################################################
5262 # Function : ReadArgsFile
5263 # Description : This reads in an existing file which contains information on
5264 # all GTK args. It creates the arrays @ArgObjects, @ArgNames,
5265 # @ArgTypes, @ArgFlags, @ArgNicks and @ArgBlurbs containing info
5267 # Arguments : $file - the file containing the arg information.
5268 #############################################################################
5283 # Reset the args info.
5296 if (!open (INPUT, $file)) {
5297 warn "Can't open $file - skipping args\n";
5314 if (m/^<NAME>(.*)<\/NAME>/) {
5316 if ($arg_name =~ m/^(.*)::(.*)$/) {
5318 ($arg_name = $2) =~ s/_/-/g;
5319 #print "Found arg: $arg_name\n";
5321 &LogWarning ($file, $., "Invalid argument name: $arg_name");
5323 } elsif (m/^<TYPE>(.*)<\/TYPE>/) {
5325 } elsif (m/^<RANGE>(.*)<\/RANGE>/) {
5327 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
5329 } elsif (m/^<NICK>(.*)<\/NICK>/) {
5331 } elsif (m/^<BLURB>(.*)<\/BLURB>/) {
5333 if ($arg_blurb eq "(null)") {
5335 &LogWarning ($file, $., "Property ${arg_object}:${arg_name} has no documentation.");
5337 } elsif (m/^<DEFAULT>(.*)<\/DEFAULT>/) {
5339 } elsif (m%^</ARG>%) {
5340 #print "Found end of arg: ${arg_object}::${arg_name}\n${arg_type} : ${arg_flags}\n";
5341 push (@ArgObjects, $arg_object);
5342 push (@ArgNames, $arg_name);
5343 push (@ArgTypes, $arg_type);
5344 push (@ArgRanges, $arg_range);
5345 push (@ArgFlags, $arg_flags);
5346 push (@ArgNicks, $arg_nick);
5347 push (@ArgBlurbs, $arg_blurb);
5348 push (@ArgDefaults, $arg_default);
5357 #############################################################################
5358 # Function : CheckIsObject
5359 # Description : Returns 1 if the given name is a GObject or a subclass.
5360 # It uses the global @Objects array.
5361 # Note that the @Objects array only contains classes in the
5362 # current module and their ancestors - not all GObject classes.
5363 # Arguments : $name - the name to check.
5364 #############################################################################
5370 foreach $object (@Objects) {
5371 if ($object eq $name) {
5379 #############################################################################
5380 # Function : MakeReturnField
5381 # Description : Pads a string to $RETURN_TYPE_FIELD_WIDTH.
5382 # Arguments : $str - the string to pad.
5383 #############################################################################
5385 sub MakeReturnField {
5388 return $str . (' ' x ($RETURN_TYPE_FIELD_WIDTH - length ($str)));
5391 #############################################################################
5392 # Function : GetSymbolSourceFile
5393 # Description : Get the filename where the symbol docs where taken from.
5394 # Arguments : $symbol - the symbol name
5395 #############################################################################
5397 sub GetSymbolSourceFile {
5400 if (defined($SourceSymbolSourceFile{$symbol})) {
5401 return $SourceSymbolSourceFile{$symbol};
5402 } elsif (defined($SymbolSourceFile{$symbol})) {
5403 return $SymbolSourceFile{$symbol};
5409 #############################################################################
5410 # Function : GetSymbolSourceLine
5411 # Description : Get the file line where the symbol docs where taken from.
5412 # Arguments : $symbol - the symbol name
5413 #############################################################################
5415 sub GetSymbolSourceLine {
5418 if (defined($SourceSymbolSourceLine{$symbol})) {
5419 return $SourceSymbolSourceLine{$symbol};
5420 } elsif (defined($SymbolSourceLine{$symbol})) {
5421 return $SymbolSourceLine{$symbol};