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 object struct: $symbol\n";
1446 $is_object_struct = 1;
1447 $default_to_public = 0;
1452 if ($is_object_struct) {
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) = @_;
1788 my $id = &CreateValidSGMLID ($symbol);
1789 my $condition = &MakeConditionDescription ($symbol);
1790 my $synop = &MakeReturnField("enum") . "<link linkend=\"$id\">$symbol</link>;\n";
1791 my $desc = "<refsect2 id=\"$id\" role=\"enum\"$condition>\n<title>enum $symbol</title>\n";
1793 $desc .= MakeIndexterms($symbol, $id);
1795 $desc .= OutputSymbolExtraLinks($symbol);
1797 my $decl_out = &CreateValidSGML ($declaration);
1798 $desc .= "<programlisting>$decl_out</programlisting>\n";
1800 $desc .= &MakeDeprecationNote($symbol);
1802 if (defined ($SymbolDocs{$symbol})) {
1803 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1806 # Create a table of fields and descriptions
1808 my @fields = ParseEnumDeclaration($declaration);
1809 my $params = $SymbolParams{$symbol};
1811 # If no parameters are filled in, we don't generate the description
1812 # table, for backwards compatibility
1815 if (defined $params) {
1816 for (my $i = 1; $i <= $#$params; $i += $PARAM_FIELD_COUNT) {
1817 if ($params->[$i] =~ /\S/) {
1825 my %field_descrs = @$params;
1826 my $missing_parameters = "";
1827 my $unused_parameters = "";
1829 $desc .= "<variablelist role=\"enum\">\n";
1830 for my $field_name (@fields) {
1831 my $field_descr = $field_descrs{$field_name};
1832 my $param_annotations = "";
1834 $id = &CreateValidSGMLID ($field_name);
1835 $condition = &MakeConditionDescription ($field_name);
1836 $desc .= "<varlistentry id=\"$id\" role=\"constant\"$condition>\n<term><literal>$field_name</literal></term>\n";
1837 if (defined $field_descr) {
1838 ($field_descr,$param_annotations) = &ExpandAnnotation($symbol, $field_descr);
1839 $field_descr = &ExpandAbbreviations($symbol, $field_descr);
1840 $desc .= "<listitem><simpara>$field_descr$param_annotations</simpara></listitem>\n";
1841 delete $field_descrs{$field_name};
1843 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1844 "Value description for $symbol"."::"."$field_name is missing in source code comment block.");
1845 if ($missing_parameters ne "") {
1846 $missing_parameters .= ", ".$field_name;
1848 $missing_parameters = $field_name;
1850 $desc .= "<listitem />\n";
1852 $desc .= "</varlistentry>\n";
1854 $desc .= "</variablelist>";
1855 foreach my $field_name (keys %field_descrs) {
1856 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1857 "Value description for $symbol"."::"."$field_name is not used from source code comment block.");
1858 if ($unused_parameters ne "") {
1859 $unused_parameters .= ", ".$field_name;
1861 $unused_parameters = $field_name;
1865 # remember missing/unused parameters (needed in tmpl-free build)
1866 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
1867 $AllIncompleteSymbols{$symbol}=$missing_parameters;
1869 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
1870 $AllUnusedSymbols{$symbol}=$unused_parameters;
1874 if (scalar(@fields) > 0) {
1875 if (! exists ($AllIncompleteSymbols{$symbol})) {
1876 $AllIncompleteSymbols{$symbol}="<items>";
1877 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
1878 "Value descriptions for $symbol are missing in source code comment block.");
1883 $desc .= OutputSymbolTraits ($symbol);
1884 $desc .= "</refsect2>\n";
1885 return ($synop, $desc);
1889 #############################################################################
1890 # Function : OutputVariable
1891 # Description : Returns the synopsis and detailed description of a variable.
1892 # Arguments : $symbol - the extern'ed variable.
1893 # $declaration - the declaration of the variable.
1894 #############################################################################
1896 sub OutputVariable {
1897 my ($symbol, $declaration) = @_;
1898 my $id = &CreateValidSGMLID ($symbol);
1899 my $condition = &MakeConditionDescription ($symbol);
1902 if ($declaration =~ m/^\s*extern\s+((const\s+|signed\s+|unsigned\s+)*\w+)(\s+\*+|\*+|\s)(\s*)([A-Za-z]\w*)\s*;/) {
1903 my $mod = defined ($1) ? $1 : "";
1904 my $ptr = defined ($3) ? $3 : "";
1905 my $space = defined ($4) ? $4 : "";
1906 $synop = &MakeReturnField("extern") . "$mod$ptr$space<link linkend=\"$id\">$symbol</link>;\n";
1909 $synop = &MakeReturnField("extern") . "<link linkend=\"$id\">$symbol</link>;\n";
1912 my $desc = "<refsect2 id=\"$id\" role=\"variable\"$condition>\n<title>$symbol</title>\n";
1914 $desc .= MakeIndexterms($symbol, $id);
1916 $desc .= OutputSymbolExtraLinks($symbol);
1918 my $decl_out = &CreateValidSGML ($declaration);
1919 $desc .= "<programlisting>$decl_out</programlisting>\n";
1921 $desc .= &MakeDeprecationNote($symbol);
1923 if (defined ($SymbolDocs{$symbol})) {
1924 $desc .= &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
1926 $desc .= OutputSymbolTraits ($symbol);
1927 $desc .= "</refsect2>\n";
1928 return ($synop, $desc);
1932 #############################################################################
1933 # Function : OutputFunction
1934 # Description : Returns the synopsis and detailed description of a function.
1935 # Arguments : $symbol - the function.
1936 # $declaration - the declaration of the function.
1937 #############################################################################
1939 sub OutputFunction {
1940 my ($symbol, $declaration, $symbol_type) = @_;
1941 my $id = &CreateValidSGMLID ($symbol);
1942 my $condition = &MakeConditionDescription ($symbol);
1944 # Take out the return type $1 $3 $4
1945 $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//;
1946 my $type_modifier = defined($1) ? $1 : "";
1949 #print "$symbol pointer is $pointer\n";
1950 my $xref = &MakeXRef ($type, &tagify($type, "returnvalue"));
1952 #if ($symbol_type eq 'USER_FUNCTION') {
1953 # $start = "typedef ";
1956 # We output const rather than G_CONST_RETURN.
1957 $type_modifier =~ s/G_CONST_RETURN/const/g;
1958 $pointer =~ s/G_CONST_RETURN/const/g;
1959 $pointer =~ s/^\s+/ /g;
1961 my $ret_type_len = length ($start) + length ($type_modifier)
1962 + length ($pointer) + length ($type);
1963 my $ret_type_output;
1965 if ($ret_type_len < $RETURN_TYPE_FIELD_WIDTH) {
1966 $ret_type_output = "$start$type_modifier$xref$pointer"
1967 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
1970 #$ret_type_output = "$start$type_modifier$xref$pointer\n" . (' ' x $RETURN_TYPE_FIELD_WIDTH);
1972 $ret_type_output = "$start$type_modifier$xref$pointer ";
1973 $symbol_len = $ret_type_len + 1 - $RETURN_TYPE_FIELD_WIDTH;
1976 $symbol_len += length ($symbol);
1977 my $char1 = my $char2 = my $char3 = "";
1978 if ($symbol_type eq 'USER_FUNCTION') {
1985 my ($symbol_output, $symbol_desc_output);
1986 if ($symbol_len < $SYMBOL_FIELD_WIDTH) {
1987 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3"
1988 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1989 $symbol_desc_output = "$char1$char2$symbol$char3"
1990 . (' ' x ($SYMBOL_FIELD_WIDTH - $symbol_len));
1992 $symbol_output = "$char1<link linkend=\"$id\">$char2$symbol</link>$char3\n"
1993 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1994 $symbol_desc_output = "$char1$char2$symbol$char3\n"
1995 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
1998 my $synop = $ret_type_output . $symbol_output . '(';
1999 my $desc = "<refsect2 id=\"$id\" role=\"function\"$condition>\n<title>${symbol} ()</title>\n";
2001 $desc .= MakeIndexterms($symbol, $id);
2003 $desc .= OutputSymbolExtraLinks($symbol);
2005 $desc .= "<programlisting>${ret_type_output}$symbol_desc_output(";
2007 my @fields = ParseFunctionDeclaration($declaration, \&MakeXRef,
2009 &tagify($_[0],"parameter");
2012 for (my $i = 1; $i <= $#fields; $i += 2) {
2013 my $field_name = $fields[$i];
2015 if ($field_name eq "Varargs") {
2016 $field_name = "...";
2020 $synop .= "$field_name";
2021 $desc .= "$field_name";
2024 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
2027 . (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH))
2034 $desc .= ");</programlisting>\n";
2036 $desc .= &MakeDeprecationNote($symbol);
2038 my $parameters = &OutputParamDescriptions ("FUNCTION", $symbol, @fields);
2039 my $parameters_output = 0;
2041 if (defined ($SymbolDocs{$symbol})) {
2042 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
2044 # Try to insert the parameter table at the author's desired position.
2045 # Otherwise we need to tag it onto the end.
2046 # FIXME: document that in the user manual and make it useable for other
2048 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
2049 $parameters_output = 1;
2051 $desc .= $symbol_docs;
2054 if ($parameters_output == 0) {
2055 $desc .= $parameters;
2058 $desc .= OutputSymbolTraits ($symbol);
2059 $desc .= "</refsect2>\n";
2060 return ($synop, $desc);
2064 #############################################################################
2065 # Function : OutputParamDescriptions
2066 # Description : Returns the DocBook output describing the parameters of a
2067 # function, macro or signal handler.
2068 # Arguments : $symbol_type - 'FUNCTION', 'MACRO' or 'SIGNAL'. Signal
2069 # handlers have an implicit user_data parameter last.
2070 # $symbol - the name of the function/macro being described.
2071 # @fields - parsed fields from the declaration, used to determine
2072 # undocumented/unused entries
2073 #############################################################################
2075 sub OutputParamDescriptions {
2076 my ($symbol_type, $symbol, @fields) = @_;
2078 my $params = $SymbolParams{$symbol};
2080 my %field_descrs = ();
2083 %field_descrs = @fields;
2084 delete $field_descrs{"void"};
2085 delete $field_descrs{"Returns"};
2088 if (defined $params) {
2090 my $params_desc = "";
2091 my $missing_parameters = "";
2092 my $unused_parameters = "";
2095 for ($j = 0; $j <= $#$params; $j += $PARAM_FIELD_COUNT) {
2096 my $param_name = $$params[$j];
2097 my $param_desc = $$params[$j + 1];
2098 my $param_annotations = "";
2100 ($param_desc,$param_annotations) = & ExpandAnnotation($symbol, $param_desc);
2101 $param_desc = &ExpandAbbreviations($symbol, $param_desc);
2102 $param_desc .= $param_annotations;
2104 $param_desc =~ s/^(\s|\n)+//msg;
2105 $param_desc =~ s/(\s|\n)+$//msg;
2106 if ($param_name eq "Returns") {
2107 $returns = "$param_desc";
2108 } elsif ($param_name eq "void") {
2109 #print "!!!! void in params for $symbol?\n";
2112 if (!defined $field_descrs{$param_name}) {
2113 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2114 "Parameter description for $symbol"."::"."$param_name is not used from source code comment block.");
2115 if ($unused_parameters ne "") {
2116 $unused_parameters .= ", ".$param_name;
2118 $unused_parameters = $param_name;
2121 delete $field_descrs{$param_name};
2124 if ($param_name eq "Varargs") {
2125 $param_name = "...";
2127 if($param_desc ne "") {
2128 $params_desc .= "<varlistentry><term><parameter>$param_name</parameter> :</term>\n<listitem><simpara>$param_desc</simpara></listitem></varlistentry>\n";
2133 foreach my $param_name (keys %field_descrs) {
2134 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2135 "Parameter description for $symbol"."::"."$param_name is missing in source code comment block.");
2136 if ($missing_parameters ne "") {
2137 $missing_parameters .= ", ".$param_name;
2139 $missing_parameters = $param_name;
2143 # Signals have an implicit user_data parameter which we describe.
2144 if ($symbol_type eq "SIGNAL") {
2145 $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";
2148 # Start a table if we need one.
2149 if ($params_desc || $returns) {
2150 $output .= "<variablelist role=\"params\">\n";
2151 if ($params_desc ne "") {
2152 #$output .= "<varlistentry><term>Parameters:</term><listitem></listitem></varlistentry>\n";
2153 $output .= $params_desc;
2156 # Output the returns info last
2158 $output .= "<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>$returns</simpara></listitem></varlistentry>\n";
2162 $output .= "</variablelist>";
2165 # remember missing/unused parameters (needed in tmpl-free build)
2166 if (($missing_parameters ne "") and (! exists ($AllIncompleteSymbols{$symbol}))) {
2167 $AllIncompleteSymbols{$symbol}=$missing_parameters;
2169 if (($unused_parameters ne "") and (! exists ($AllUnusedSymbols{$symbol}))) {
2170 $AllUnusedSymbols{$symbol}=$unused_parameters;
2173 if (($num_params == 0) && @fields && (scalar(keys(%field_descrs)) > 0)) {
2174 if (! exists ($AllIncompleteSymbols{$symbol})) {
2175 $AllIncompleteSymbols{$symbol}="<parameters>";
2183 #############################################################################
2184 # Function : ParseStabilityLevel
2185 # Description : Parses a stability level and outputs a warning if it isn't
2187 # Arguments : $stability - the stability text.
2188 # $file, $line - context for error message
2189 # $message - description of where the level is from, to use in
2190 # any error message.
2191 # Returns : The parsed stability level string.
2192 #############################################################################
2194 sub ParseStabilityLevel {
2195 my ($stability, $file, $line, $message) = @_;
2197 $stability =~ s/^\s*//;
2198 $stability =~ s/\s*$//;
2199 if ($stability =~ m/^stable$/i) {
2200 $stability = "Stable";
2201 } elsif ($stability =~ m/^unstable$/i) {
2202 $stability = "Unstable";
2203 } elsif ($stability =~ m/^private$/i) {
2204 $stability = "Private";
2206 &LogWarning ($file, $line, "$message is $stability.".
2207 "It should be one of these: Stable, Unstable, or Private.");
2213 #############################################################################
2214 # Function : OutputSGMLFile
2215 # Description : Outputs the final DocBook file for one section.
2216 # Arguments : $file - the name of the file.
2217 # $title - the title from the $MODULE-sections.txt file, which
2218 # will be overridden by the title in the template file.
2219 # $section_id - the SGML id to use for the toplevel tag.
2220 # $includes - comma-separates list of include files added at top
2221 # of synopsis, with '<' '>' around them (if not already enclosed in "").
2222 # $synopsis - reference to the DocBook for the Synopsis part.
2223 # $details - reference to the DocBook for the Details part.
2224 # $signal_synop - reference to the DocBook for the Signal Synopsis part
2225 # $signal_desc - reference to the DocBook for the Signal Description part
2226 # $args_synop - reference to the DocBook for the Arg Synopsis part
2227 # $args_desc - reference to the DocBook for the Arg Description part
2228 # $hierarchy - reference to the DocBook for the Object Hierarchy part
2229 # $interfaces - reference to the DocBook for the Interfaces part
2230 # $implementations - reference to the DocBook for the Known Implementations part
2231 # $prerequisites - reference to the DocBook for the Prerequisites part
2232 # $derived - reference to the DocBook for the Derived Interfaces part
2233 # $file_objects - reference to an array of objects in this file
2234 #############################################################################
2236 sub OutputSGMLFile {
2237 my ($file, $title, $section_id, $includes, $synopsis, $details, $signals_synop, $signals_desc, $args_synop, $args_desc, $hierarchy, $interfaces, $implementations, $prerequisites, $derived, $file_objects) = @_;
2239 #print "Output sgml for file $file with title '$title'\n";
2241 # The edited title overrides the one from the sections file.
2242 my $new_title = $SymbolDocs{"$TMPL_DIR/$file:Title"};
2243 if (defined ($new_title) && $new_title !~ m/^\s*$/) {
2244 $title = $new_title;
2245 #print "Found title: $title\n";
2247 my $short_desc = $SymbolDocs{"$TMPL_DIR/$file:Short_Description"};
2248 if (!defined ($short_desc) || $short_desc =~ m/^\s*$/) {
2251 $short_desc = &ExpandAbbreviations("$title:Short_description",
2253 #print "Found short_desc: $short_desc";
2255 my $long_desc = $SymbolDocs{"$TMPL_DIR/$file:Long_Description"};
2256 if (!defined ($long_desc) || $long_desc =~ m/^\s*$/) {
2259 $long_desc = &ExpandAbbreviations("$title:Long_description",
2261 #print "Found long_desc: $long_desc";
2263 my $see_also = $SymbolDocs{"$TMPL_DIR/$file:See_Also"};
2264 if (!defined ($see_also) || $see_also =~ m%^\s*(<para>)?\s*(</para>)?\s*$%) {
2267 $see_also = &ExpandAbbreviations("$title:See_Also", $see_also);
2268 #print "Found see_also: $see_also";
2271 $see_also = "<refsect1 id=\"$section_id.see-also\">\n<title>See Also</title>\n$see_also\n</refsect1>\n";
2273 my $stability = $SymbolDocs{"$TMPL_DIR/$file:Stability_Level"};
2274 if (!defined ($stability) || $stability =~ m/^\s*$/) {
2277 $stability = &ParseStabilityLevel($stability, $file, $., "Section stability level");
2278 #print "Found stability: $stability";
2281 $stability = "<refsect1 id=\"$section_id.stability-level\">\n<title>Stability Level</title>\n$stability, unless otherwise indicated\n</refsect1>\n";
2282 } elsif ($DEFAULT_STABILITY) {
2283 $stability = "<refsect1 id=\"$section_id.stability-level\">\n<title>Stability Level</title>\n$DEFAULT_STABILITY, unless otherwise indicated\n</refsect1>\n";
2286 my $image = $SymbolDocs{"$TMPL_DIR/$file:Image"};
2287 if (!defined ($image) || $image =~ m/^\s*$/) {
2295 if ($image =~ /jpe?g$/i) {
2296 $format = "format='JPEG'";
2297 } elsif ($image =~ /png$/i) {
2298 $format = "format='PNG'";
2299 } elsif ($image =~ /svg$/i) {
2300 $format = "format='SVG'";
2305 $image = " <inlinegraphic fileref='$image' $format/>\n"
2308 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
2310 my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];
2313 my $include_output = "";
2315 foreach $include (split (/,/, $includes)) {
2316 if ($include =~ m/^\".+\"$/) {
2317 $include_output .= "#include ${include}\n";
2320 $include =~ s/^\s+|\s+$//gs;
2321 $include_output .= "#include <${include}>\n";
2324 if ($include_output ne '') {
2325 $include_output = "\n$include_output\n";
2328 my $extralinks = OutputSectionExtraLinks($title,"Section:$file");
2330 my $old_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT";
2331 my $new_sgml_file = "$SGML_OUTPUT_DIR/$file.$OUTPUT_FORMAT.new";
2333 open (OUTPUT, ">$new_sgml_file")
2334 || die "Can't create $new_sgml_file: $!";
2336 my $object_anchors = "";
2337 foreach my $object (@$file_objects) {
2338 next if ($object eq $section_id);
2339 my $id = CreateValidSGMLID($object);
2340 #print "Debug: Adding anchor for $object\n";
2341 $object_anchors .= "<anchor id=\"$id\"$empty_element_end";
2344 # We used to output this, but is messes up our UpdateFileIfChanged code
2345 # since it changes every day (and it is only used in the man pages):
2346 # "<refentry id="$section_id" revision="$mday $month $year">"
2348 if ($OUTPUT_FORMAT eq "xml") {
2349 print OUTPUT $doctype_header;
2353 <refentry id="$section_id">
2355 <refentrytitle role="top_of_page" id="$section_id.top_of_page">$title</refentrytitle>
2356 <manvolnum>3</manvolnum>
2359 $image</refmiscinfo>
2362 <refname>$title</refname>
2363 <refpurpose>$short_desc</refpurpose>
2366 <refsynopsisdiv id="$section_id.synopsis" role="synopsis">
2367 <title role="synopsis.title">Synopsis</title>
2369 <synopsis>$include_output$${synopsis}</synopsis>
2371 $$hierarchy$$prerequisites$$derived$$interfaces$$implementations$$args_synop$$signals_synop
2372 <refsect1 id="$section_id.description" role="desc">
2373 <title role="desc.title">Description</title>
2374 $extralinks$long_desc
2376 <refsect1 id="$section_id.details" role="details">
2377 <title role="details.title">Details</title>
2380 $$args_desc$$signals_desc$see_also
2385 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
2389 #############################################################################
2390 # Function : OutputExtraFile
2391 # Description : Copies an "extra" DocBook file into the output directory,
2392 # expanding abbreviations
2393 # Arguments : $file - the source file.
2394 #############################################################################
2395 sub OutputExtraFile {
2400 ($basename = $file) =~ s!^.*/!!;
2402 my $old_sgml_file = "$SGML_OUTPUT_DIR/$basename";
2403 my $new_sgml_file = "$SGML_OUTPUT_DIR/$basename.new";
2407 open(EXTRA_FILE, "<$file") || die "Can't open $file";
2411 $contents = <EXTRA_FILE>;
2414 open (OUTPUT, ">$new_sgml_file")
2415 || die "Can't create $new_sgml_file: $!";
2417 print OUTPUT &ExpandAbbreviations ("$basename file", $contents);
2420 return &UpdateFileIfChanged ($old_sgml_file, $new_sgml_file, 0);
2422 #############################################################################
2423 # Function : OutputBook
2424 # Description : Outputs the SGML entities that need to be included into the
2425 # main SGML file for the module.
2426 # Arguments : $book_top - the declarations of the entities, which are added
2427 # at the top of the main SGML file.
2428 # $book_bottom - the references to the entities, which are
2429 # added in the main SGML file at the desired position.
2430 #############################################################################
2433 my ($book_top, $book_bottom) = @_;
2435 my $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top";
2436 my $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.top.new";
2438 open (OUTPUT, ">$new_file")
2439 || die "Can't create $new_file: $!";
2440 print OUTPUT $book_top;
2443 &UpdateFileIfChanged ($old_file, $new_file, 0);
2446 $old_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom";
2447 $new_file = "$SGML_OUTPUT_DIR/$MODULE-doc.bottom.new";
2449 open (OUTPUT, ">$new_file")
2450 || die "Can't create $new_file: $!";
2451 print OUTPUT $book_bottom;
2454 &UpdateFileIfChanged ($old_file, $new_file, 0);
2457 # If the main SGML/XML file hasn't been created yet, we create it here.
2458 # The user can tweak it later.
2459 if ($MAIN_SGML_FILE && ! -e $MAIN_SGML_FILE) {
2460 open (OUTPUT, ">$MAIN_SGML_FILE")
2461 || die "Can't create $MAIN_SGML_FILE: $!";
2463 if ($OUTPUT_FORMAT eq "xml") {
2465 <?xml version="1.0"?>
2466 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
2467 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
2469 <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
2475 <!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
2484 <title>$MODULE Reference Manual</title>
2486 for $MODULE [VERSION].
2487 The latest version of this documentation can be found on-line at
2488 <ulink role="online-location" url="http://[SERVER]/$MODULE/index.html">http://[SERVER]/$MODULE/</ulink>.
2493 <title>[Insert title here]</title>
2497 if (-e $OBJECT_TREE_FILE) {
2499 <chapter id="object-tree">
2500 <title>Object Hierarchy</title>
2501 <xi:include href="xml/tree_index.sgml"/>
2507 <index id="api-index-full">
2508 <title>API Index</title>
2509 <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
2511 <index id="deprecated-api-index" role="deprecated">
2512 <title>Index of deprecated API</title>
2513 <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
2516 <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
2525 #############################################################################
2526 # Function : CreateValidSGML
2527 # Description : This turns any chars which are used in SGML into entities,
2528 # e.g. '<' into '<'
2529 # Arguments : $text - the text to turn into proper SGML.
2530 #############################################################################
2532 sub CreateValidSGML {
2534 $text =~ s/&/&/g; # Do this first, or the others get messed up.
2535 $text =~ s/</</g;
2536 $text =~ s/>/>/g;
2537 # browers render single tabs inconsistently
2538 $text =~ s/([^\s])\t([^\s])/$1 $2/g;
2542 #############################################################################
2543 # Function : ConvertSGMLChars
2544 # Description : This is used for text in source code comment blocks, to turn
2545 # chars which are used in SGML into entities, e.g. '<' into
2546 # '<'. Depending on $INLINE_MARKUP_MODE, this is done
2547 # unconditionally or only if the character doesn't seem to be
2548 # part of an SGML construct (tag or entity reference).
2549 # Arguments : $text - the text to turn into proper SGML.
2550 #############################################################################
2552 sub ConvertSGMLChars {
2553 my ($symbol, $text) = @_;
2555 if ($INLINE_MARKUP_MODE) {
2556 # For the XML/SGML mode only convert to entities outside CDATA sections.
2557 return &ModifyXMLElements ($text, $symbol,
2558 "<!\\[CDATA\\[|<programlisting[^>]*>",
2559 \&ConvertSGMLCharsEndTag,
2560 \&ConvertSGMLCharsCallback);
2562 # For the simple non-sgml mode, convert to entities everywhere.
2563 $text =~ s/&/&/g; # Do this first, or the others get messed up.
2564 $text =~ s/</</g;
2565 $text =~ s/>/>/g;
2571 sub ConvertSGMLCharsEndTag {
2572 if ($_[0] eq "<!\[CDATA\[") {
2575 return "</programlisting>";
2579 sub ConvertSGMLCharsCallback {
2580 my ($text, $symbol, $tag) = @_;
2582 if ($tag =~ m/^<programlisting/) {
2583 # We can handle <programlisting> specially here.
2584 return &ModifyXMLElements ($text, $symbol,
2586 \&ConvertSGMLCharsEndTag,
2587 \&ConvertSGMLCharsCallback2);
2588 } elsif ($tag eq "") {
2589 # If we're not in CDATA convert to entities.
2590 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
2591 $text =~ s/<(?![a-zA-Z\/!])/</g;
2592 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
2594 # Handle "#include <xxxxx>"
2595 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
2601 sub ConvertSGMLCharsCallback2 {
2602 my ($text, $symbol, $tag) = @_;
2604 # If we're not in CDATA convert to entities.
2605 # We could handle <programlisting> differently, though I'm not sure it helps.
2607 # replace only if its not a tag
2608 $text =~ s/&(?![a-zA-Z#]+;)/&/g; # Do this first, or the others get messed up.
2609 $text =~ s/<(?![a-zA-Z\/!])/</g;
2610 $text =~ s/(?<![a-zA-Z0-9"'\/-])>/>/g;
2612 # Handle "#include <xxxxx>"
2613 $text =~ s/#include(\s+)<([^>]+)>/#include$1<$2>/g;
2619 #############################################################################
2620 # Function : ExpandAnnotation
2621 # Description : This turns annotations into acronym tags.
2622 # Arguments : $symbol - the symbol being documented, for error messages.
2623 # $text - the text to expand.
2624 #############################################################################
2625 sub ExpandAnnotation {
2626 my ($symbol, $param_desc) = @_;
2627 my $param_annotations = "";
2629 # look for annotations at the start of the comment part
2630 if ($param_desc =~ m%^\s*\((.*?)\):%) {
2635 @annotations = split(/\)\s*\(/,$1);
2636 foreach $annotation (@annotations) {
2637 # need to search for the longest key-match in %AnnotationDefinition
2639 my $match_annotation="";
2641 foreach $annotationdef (keys %AnnotationDefinition) {
2642 if ($annotation =~ m/^$annotationdef/) {
2643 if (length($annotationdef)>$match_length) {
2644 $match_length=length($annotationdef);
2645 $match_annotation=$annotationdef;
2649 my $annotation_extra = "";
2650 if ($match_annotation ne "") {
2651 if ($annotation =~ m%$match_annotation\s+(.*)%) {
2652 $annotation_extra = " $1";
2654 $AnnotationsUsed{$match_annotation} = 1;
2655 $param_annotations .= "[<acronym>$match_annotation</acronym>$annotation_extra]";
2658 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2659 "unknown annotation \"$annotation\" in documentation for $symbol.");
2660 $param_annotations .= "[$annotation]";
2664 $param_desc =~ m/^(.*?)\.*\s*$/s;
2665 $param_desc = "$1. ";
2667 if ($param_annotations ne "") {
2668 $param_annotations = "<emphasis role=\"annotation\">$param_annotations</emphasis>";
2670 return ($param_desc, $param_annotations);
2673 #############################################################################
2674 # Function : ExpandAbbreviations
2675 # Description : This turns the abbreviations function(), macro(), @param,
2676 # %constant, and #symbol into appropriate DocBook markup.
2677 # CDATA sections and <programlisting> parts are skipped.
2678 # Arguments : $symbol - the symbol being documented, for error messages.
2679 # $text - the text to expand.
2680 #############################################################################
2682 sub ExpandAbbreviations {
2683 my ($symbol, $text) = @_;
2685 # Convert "|[" and "]|" into the start and end of program listing examples.
2686 # FIXME: we like to have a way to specify parameters e.g. language="c"
2687 $text =~ s%\|\[%<informalexample><programlisting>%g;
2688 $text =~ s%\]\|%</programlisting></informalexample>%g;
2689 # TODO: check for a xml comment after |[ and pick the language attribute from
2692 # keep CDATA unmodified, preserve ulink tags (ideally we preseve all tags
2694 return &ModifyXMLElements ($text, $symbol,
2695 "<!\\[CDATA\\[|<ulink[^>]*>|<programlisting[^>]*>|<!DOCTYPE",
2696 \&ExpandAbbreviationsEndTag,
2697 \&ExpandAbbreviationsCallback);
2701 # Returns the end tag corresponding to the given start tag.
2702 sub ExpandAbbreviationsEndTag {
2703 my ($start_tag) = @_;
2705 if ($start_tag eq "<!\[CDATA\[") {
2707 } elsif ($start_tag eq "<!DOCTYPE") {
2709 } elsif ($start_tag =~ m/<(\w+)/) {
2714 # Called inside or outside each CDATA or <programlisting> section.
2715 sub ExpandAbbreviationsCallback {
2716 my ($text, $symbol, $tag) = @_;
2718 if ($tag =~ m/^<programlisting/) {
2719 # Handle any embedded CDATA sections.
2720 return &ModifyXMLElements ($text, $symbol,
2722 \&ExpandAbbreviationsEndTag,
2723 \&ExpandAbbreviationsCallback2);
2724 } elsif ($tag eq "") {
2725 # We are outside any CDATA or <programlisting> sections, so we expand
2726 # any gtk-doc abbreviations.
2728 # Convert '@param()'
2729 # FIXME: we could make those also links ($symbol.$2), but that would be less
2730 # useful as the link target is a few lines up or down
2731 $text =~ s/(\A|[^\\])\@(\w+((\.|->)\w+)*)\s*\(\)/$1<parameter>$2()<\/parameter>/g;
2733 # Convert 'function()' or 'macro()'.
2734 # if there is abc_*_def() we don't want to make a link to _def()
2735 # FIXME: also handle abc(def(....)) : but that would need to be done recursively :/
2736 $text =~ s/([^\*.\w])(\w+)\s*\(\)/$1.&MakeXRef($2, &tagify($2 . "()", "function"));/eg;
2737 # handle #Object.func()
2738 $text =~ s/(\A|[^\\])#([\w\-:\.]+[\w]+)\s*\(\)/$1.&MakeXRef($2, &tagify($2 . "()", "function"));/eg;
2740 # Convert '@param', but not '\@param'.
2741 $text =~ s/(\A|[^\\])\@(\w+((\.|->)\w+)*)/$1<parameter>$2<\/parameter>/g;
2742 $text =~ s/\\\@/\@/g;
2744 # Convert '%constant', but not '\%constant'.
2745 # Also allow negative numbers, e.g. %-1.
2746 $text =~ s/(\A|[^\\])\%(-?\w+)/$1.&MakeXRef($2, &tagify($2, "literal"));/eg;
2747 $text =~ s/\\\%/\%/g;
2749 # Convert '#symbol', but not '\#symbol'.
2750 $text =~ s/(\A|[^\\])#([\w\-:\.]+[\w]+)/$1.&MakeHashXRef($2, "type");/eg;
2754 # FIXME: should we skip urls that are already tagged? (e.g. <literal>http://...</literal>)
2755 # this is apparently also called for markup and not just for plain text
2757 #$text =~ s%(http|https|ftp)://(.*?)((?:\s|,|\)|\]|\<|\.\s))%<ulink url="$1://$2">$2</ulink>$3%g;
2759 # TODO: optionally check all words from $text against internal symbols and
2760 # warn if those could be xreffed, but miss a %,# or ()
2766 # This is called inside a <programlisting>
2767 sub ExpandAbbreviationsCallback2 {
2768 my ($text, $symbol, $tag) = @_;
2771 # We are inside a <programlisting> but outside any CDATA sections,
2772 # so we expand any gtk-doc abbreviations.
2773 # FIXME: why is this different from &ExpandAbbreviationsCallback(),
2774 # why not just call it
2775 $text =~ s/#(\w+)/&MakeHashXRef($1, "");/eg;
2782 my ($symbol, $tag) = @_;;
2785 # Check for things like '#include', '#define', and skip them.
2786 if ($PreProcessorDirectives{$symbol}) {
2790 # Get rid of any special '-struct' suffix.
2791 $text =~ s/-struct$//;
2793 # If the symbol is in the form "Object::signal", then change the symbol to
2794 # "Object-signal" and use "signal" as the text.
2795 if ($symbol =~ s/::/-/) {
2799 # If the symbol is in the form "Object:property", then change the symbol to
2800 # "Object--property" and use "property" as the text.
2801 if ($symbol =~ s/:/--/) {
2806 $text = tagify ($text, $tag);
2809 return &MakeXRef($symbol, $text);
2813 #############################################################################
2814 # Function : ModifyXMLElements
2815 # Description : Looks for given XML element tags within the text, and calls
2816 # the callback on pieces of text inside & outside those elements.
2817 # Used for special handling of text inside things like CDATA
2818 # and <programlisting>.
2819 # Arguments : $text - the text.
2820 # $symbol - the symbol currently being documented (only used for
2822 # $start_tag_regexp - the regular expression to match start tags.
2823 # e.g. "<!\\[CDATA\\[|<programlisting[^>]*>" to match
2824 # CDATA sections or programlisting elements.
2825 # $end_tag_func - function which is passed the matched start tag
2826 # and should return the appropriate end tag string.
2827 # $callback - callback called with each part of the text. It is
2828 # called with a piece of text, the symbol being
2829 # documented, and the matched start tag or "" if the text
2830 # is outside the XML elements being matched.
2831 #############################################################################
2832 sub ModifyXMLElements {
2833 my ($text, $symbol, $start_tag_regexp, $end_tag_func, $callback) = @_;
2834 my ($before_tag, $start_tag, $end_tag_regexp, $end_tag);
2837 while ($text =~ m/$start_tag_regexp/s) {
2838 $before_tag = $`; # Prematch for last successful match string
2839 $start_tag = $&; # Last successful match
2840 $text = $'; # Postmatch for last successful match string
2842 $result .= &$callback ($before_tag, $symbol, "");
2843 $result .= $start_tag;
2845 # get the mathing end-tag for current tag
2846 $end_tag_regexp = &$end_tag_func ($start_tag);
2848 if ($text =~ m/$end_tag_regexp/s) {
2853 $result .= &$callback ($before_tag, $symbol, $start_tag);
2854 $result .= $end_tag;
2856 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
2857 "Can't find tag end: $end_tag_regexp in docs for: $symbol.");
2858 # Just assume it is all inside the tag.
2859 $result .= &$callback ($text, $symbol, $start_tag);
2864 # Handle any remaining text outside the tags.
2865 $result .= &$callback ($text, $symbol, "");
2874 # Adds a tag around some text.
2875 # e.g tagify("Text", "literal") => "<literal>Text</literal>".
2877 my ($text, $elem) = @_;
2878 return "<" . $elem . ">" . $text . "</" . $elem . ">";
2882 #############################################################################
2883 # Function : MakeXRef
2884 # Description : This returns a cross-reference link to the given symbol.
2885 # Though it doesn't try to do this for a few standard C types
2886 # that it knows won't be in the documentation.
2887 # Arguments : $symbol - the symbol to try to create a XRef to.
2888 # $text - text text to put inside the XRef, defaults to $symbol
2889 #############################################################################
2892 my ($symbol, $text) = ($_[0], $_[1]);
2894 $symbol =~ s/^\s+//;
2895 $symbol =~ s/\s+$//;
2897 if (!defined($text)) {
2900 # Get rid of special '-struct' suffix.
2901 $text =~ s/-struct$//;
2904 if ($symbol =~ m/ /) {
2908 #print "Getting type link for $symbol -> $text\n";
2910 my $symbol_id = &CreateValidSGMLID ($symbol);
2911 return "<link linkend=\"$symbol_id\">$text</link>";
2915 #############################################################################
2916 # Function : MakeIndexterms
2917 # Description : This returns a indexterm elements for the given symbol
2918 # Arguments : $symbol - the symbol to create indexterms for
2919 #############################################################################
2921 sub MakeIndexterms {
2922 my ($symbol, $id) = @_;
2926 # make the index useful, by ommiting the namespace when sorting
2927 if ($NAME_SPACE ne "") {
2928 if ($symbol =~ m/^$NAME_SPACE\_?(.*)/i) {
2929 $sortas=" sortas=\"$1\"";
2933 if (exists $Deprecated{$symbol}) {
2934 $terms .= "<indexterm zone=\"$id\" role=\"deprecated\"><primary$sortas>$symbol</primary></indexterm>";
2935 $IndexEntriesDeprecated{$symbol}=$id;
2936 $IndexEntriesFull{$symbol}=$id;
2938 if (exists $Since{$symbol}) {
2939 my $since = $Since{$symbol};
2943 $terms .= "<indexterm zone=\"$id\" role=\"$since\"><primary$sortas>$symbol</primary></indexterm>";
2945 $IndexEntriesSince{$symbol}=$id;
2946 $IndexEntriesFull{$symbol}=$id;
2949 $terms .= "<indexterm zone=\"$id\"><primary$sortas>$symbol</primary></indexterm>";
2950 $IndexEntriesFull{$symbol}=$id;
2956 #############################################################################
2957 # Function : MakeDeprecationNote
2958 # Description : This returns a deprecation warning for the given symbol.
2959 # Arguments : $symbol - the symbol to try to create a warning for.
2960 #############################################################################
2962 sub MakeDeprecationNote {
2963 my ($symbol) = $_[0];
2966 if (exists $Deprecated{$symbol}) {
2967 $desc .= "<warning>";
2969 if ($Deprecated{$symbol} =~ /^\s*([0-9\.]+)\s*:/) {
2970 $desc .= "<para><literal>$symbol</literal> has been deprecated since version $1 and should not be used in newly-written code.";
2972 $desc .= "<para><literal>$symbol</literal> is deprecated and should not be used in newly-written code.";
2974 if ($Deprecated{$symbol} ne "") {
2975 $note = &ExpandAbbreviations($symbol, $Deprecated{$symbol});
2976 $note =~ s/^\s*([0-9\.]+)\s*:\s*//;
2979 $note =~ s%\n{2,}%\n</para>\n<para>\n%g;
2980 $desc .= " " . $note;
2982 $desc .= "</para></warning>\n";
2987 #############################################################################
2988 # Function : MakeConditionDescription
2989 # Description : This returns a sumary of conditions for the given symbol.
2990 # Arguments : $symbol - the symbol to try to create the sumary.
2991 #############################################################################
2993 sub MakeConditionDescription {
2994 my ($symbol) = $_[0];
2997 if (exists $Deprecated{$symbol}) {
3002 if ($Deprecated{$symbol} =~ /^\s*(.*?)\s*$/) {
3003 $desc .= "deprecated:$1";
3005 $desc .= "deprecated";
3009 if (exists $Since{$symbol}) {
3014 if ($Since{$symbol} =~ /^\s*(.*?)\s*$/) {
3015 $desc .= "since:$1";
3021 if (exists $StabilityLevel{$symbol}) {
3025 $desc .= "stability:".$StabilityLevel{$symbol};
3029 $desc=" condition=\"".$desc."\"";
3030 #print "condition for '$symbol' = '$desc'\n";
3035 #############################################################################
3036 # Function : GetHierarchy
3037 # Description : Returns the DocBook output describing the ancestors and
3038 # immediate children of a GObject subclass. It uses the
3039 # global @Objects and @ObjectLevels arrays to walk the tree.
3040 # Arguments : $object - the GtkObject subclass.
3041 #############################################################################
3046 # Find object in the objects array.
3052 for ($i = 0; $i < @Objects; $i++) {
3054 if ($ObjectLevels[$i] <= $level) {
3057 elsif ($ObjectLevels[$i] == $level + 1) {
3058 push (@children, $Objects[$i]);
3061 elsif ($Objects[$i] eq $object) {
3064 $level = $ObjectLevels[$i];
3071 # Walk up the hierarchy, pushing ancestors onto the ancestors array.
3073 push (@ancestors, $object);
3074 #print "Level: $level\n";
3075 while ($level > 1) {
3077 if ($ObjectLevels[$j] < $level) {
3078 push (@ancestors, $Objects[$j]);
3079 $level = $ObjectLevels[$j];
3080 #print "Level: $level\n";
3084 # Output the ancestors list, indented and with links.
3085 my $hierarchy = "<synopsis>\n";
3087 for ($i = $#ancestors; $i >= 0; $i--) {
3089 # Don't add a link to the current object, i.e. when i == 0.
3091 my $ancestor_id = &CreateValidSGMLID ($ancestors[$i]);
3092 $link_text = "<link linkend=\"$ancestor_id\">$ancestors[$i]</link>";
3094 $link_text = "$ancestors[$i]";
3097 $hierarchy .= " $link_text\n";
3099 # $hierarchy .= ' ' x ($level * 6 - 3) . "|\n";
3100 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
3104 for ($i = 0; $i <= $#children; $i++) {
3105 my $id = &CreateValidSGMLID ($children[$i]);
3106 my $link_text = "<link linkend=\"$id\">$children[$i]</link>";
3107 $hierarchy .= ' ' x ($level * 6 - 3) . "+----$link_text\n";
3109 $hierarchy .= "</synopsis>\n";
3115 #############################################################################
3116 # Function : GetInterfaces
3117 # Description : Returns the DocBook output describing the interfaces
3118 # implemented by a class. It uses the global %Interfaces hash.
3119 # Arguments : $object - the GtkObject subclass.
3120 #############################################################################
3127 # Find object in the objects array.
3128 if (exists($Interfaces{$object})) {
3129 my @ifaces = split(' ', $Interfaces{$object});
3134 for ($i = 0; $i <= $#ifaces; $i++) {
3135 my $id = &CreateValidSGMLID ($ifaces[$i]);
3136 $text .= " <link linkend=\"$id\">$ifaces[$i]</link>";
3137 if ($i < $#ifaces - 1) {
3140 elsif ($i < $#ifaces) {
3155 #############################################################################
3156 # Function : GetImplementations
3157 # Description : Returns the DocBook output describing the implementations
3158 # of an interface. It uses the global %Interfaces hash.
3159 # Arguments : $object - the GtkObject subclass.
3160 #############################################################################
3162 sub GetImplementations {
3167 foreach my $key (keys %Interfaces) {
3168 if ($Interfaces{$key} =~ /\b$object\b/) {
3169 push (@impls, $key);
3173 @impls = sort @impls;
3176 $object is implemented by
3178 for ($i = 0; $i <= $#impls; $i++) {
3179 my $id = &CreateValidSGMLID ($impls[$i]);
3180 $text .= " <link linkend=\"$id\">$impls[$i]</link>";
3181 if ($i < $#impls - 1) {
3184 elsif ($i < $#impls) {
3199 #############################################################################
3200 # Function : GetPrerequisites
3201 # Description : Returns the DocBook output describing the prerequisites
3202 # of an interface. It uses the global %Prerequisites hash.
3203 # Arguments : $iface - the interface.
3204 #############################################################################
3206 sub GetPrerequisites {
3211 if (exists($Prerequisites{$iface})) {
3216 my @prereqs = split(' ', $Prerequisites{$iface});
3217 for ($i = 0; $i <= $#prereqs; $i++) {
3218 my $id = &CreateValidSGMLID ($prereqs[$i]);
3219 $text .= " <link linkend=\"$id\">$prereqs[$i]</link>";
3220 if ($i < $#prereqs - 1) {
3223 elsif ($i < $#prereqs) {
3237 #############################################################################
3238 # Function : GetDerived
3239 # Description : Returns the DocBook output describing the derived interfaces
3240 # of an interface. It uses the global %Prerequisites hash.
3241 # Arguments : $iface - the interface.
3242 #############################################################################
3250 foreach my $key (keys %Prerequisites) {
3251 if ($Prerequisites{$key} =~ /\b$iface\b/) {
3252 push (@derived, $key);
3255 if ($#derived >= 0) {
3256 @derived = sort @derived;
3259 $iface is required by
3261 for ($i = 0; $i <= $#derived; $i++) {
3262 my $id = &CreateValidSGMLID ($derived[$i]);
3263 $text .= " <link linkend=\"$id\">$derived[$i]</link>";
3264 if ($i < $#derived - 1) {
3267 elsif ($i < $#derived) {
3282 #############################################################################
3283 # Function : GetSignals
3284 # Description : Returns the synopsis and detailed description DocBook output
3285 # for the signal handlers of a given GtkObject subclass.
3286 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
3287 #############################################################################
3295 for ($i = 0; $i <= $#SignalObjects; $i++) {
3296 if ($SignalObjects[$i] eq $object) {
3297 #print "Found signal: $SignalNames[$i]\n";
3298 my $name = $SignalNames[$i];
3299 my $symbol = "${object}::${name}";
3300 my $id = &CreateValidSGMLID ("$object-$name");
3302 my $pad = ' ' x (46 - length($name));
3303 $synop .= " "<link linkend=\"$id\">$name</link>"$pad ";
3305 $desc .= "<refsect2 id=\"$id\" role=\"signal\"><title>The <literal>"$name"</literal> signal</title>\n";
3306 $desc .= MakeIndexterms($symbol, $id);
3308 $desc .= OutputSymbolExtraLinks($symbol);
3310 $desc .= "<programlisting>";
3312 $SignalReturns[$i] =~ m/\s*(const\s+)?(\w+)\s*(\**)/;
3313 my $type_modifier = defined($1) ? $1 : "";
3316 my $xref = &MakeXRef ($type, &tagify($type, "returnvalue"));
3318 my $ret_type_len = length ($type_modifier) + length ($pointer)
3320 my $ret_type_output = "$type_modifier$xref$pointer"
3321 . (' ' x ($RETURN_TYPE_FIELD_WIDTH - $ret_type_len));
3323 $desc .= "${ret_type_output}user_function " . &MakeReturnField("") . " (";
3325 my $sourceparams = $SourceSymbolParams{$symbol};
3326 my @params = split ("\n", $SignalPrototypes[$i]);
3329 my $type_len = length("gpointer");
3330 my $name_len = length("user_data");
3331 # do two passes, the first one is to calculate padding
3332 for ($l = 0; $l < 2; $l++) {
3333 for ($j = 0; $j <= $#params; $j++) {
3334 # allow alphanumerics, '_', '[' & ']' in param names
3335 if ($params[$j] =~ m/^\s*(\w+)\s*(\**)\s*([\w\[\]]+)\s*$/) {
3338 if (defined($sourceparams)) {
3339 $name = $$sourceparams[$PARAM_FIELD_COUNT * $j];
3344 if (!defined($name)) {
3348 if (length($type) + length($pointer) > $type_len) {
3349 $type_len = length($type) + length($pointer);
3351 if (length($name) > $name_len) {
3352 $name_len = length($name);
3356 $xref = &MakeXRef ($type, &tagify($type, "type"));
3357 $pad = ' ' x ($type_len - length($type) - length($pointer));
3358 $desc .= "$xref$pad $pointer$name,\n";
3359 $desc .= (' ' x ($SYMBOL_FIELD_WIDTH + $RETURN_TYPE_FIELD_WIDTH));
3362 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
3363 "Can't parse arg: $params[$j]\nArgs:$SignalPrototypes[$i]");
3367 $xref = &MakeXRef ("gpointer", &tagify("gpointer", "type"));
3368 $pad = ' ' x ($type_len - length("gpointer"));
3369 $desc .= "$xref$pad user_data)";
3371 my $flags = $SignalFlags[$i];
3372 my $flags_string = "";
3374 if (defined ($flags)) {
3375 if ($flags =~ m/f/) {
3376 $flags_string = "<link linkend=\"G-SIGNAL-RUN-FIRST:CAPS\"><literal>Run First</literal></link>";
3378 elsif ($flags =~ m/l/) {
3379 $flags_string = "<link linkend=\"G-SIGNAL-RUN-LAST:CAPS\"><literal>Run Last</literal></link>";
3381 elsif ($flags =~ m/c/) {
3382 $flags_string = "<link linkend=\"G-SIGNAL-RUN-CLEANUP:CAPS\"><literal>Cleanup</literal></link>";
3383 $flags_string = "Cleanup";
3385 if ($flags =~ m/r/) {
3386 if ($flags_string) { $flags_string .= " / "; }
3387 $flags_string = "<link linkend=\"G-SIGNAL-NO-RECURSE:CAPS\"><literal>No Recursion</literal></link>";
3389 if ($flags =~ m/d/) {
3390 if ($flags_string) { $flags_string .= " / "; }
3391 $flags_string = "<link linkend=\"G-SIGNAL-DETAILED:CAPS\"><literal>Has Details</literal></link>";
3393 if ($flags =~ m/a/) {
3394 if ($flags_string) { $flags_string .= " / "; }
3395 $flags_string = "<link linkend=\"G-SIGNAL-ACTION:CAPS\"><literal>Action</literal></link>";
3397 if ($flags =~ m/h/) {
3398 if ($flags_string) { $flags_string .= " / "; }
3399 $flags_string = "<link linkend=\"G-SIGNAL-NO-HOOKS:CAPS\"><literal>No Hooks</literal></link>";
3405 $synop .= ": $flags_string\n";
3407 $pad = ' ' x (5 + $name_len - length("user_data"));
3408 $desc .= "$pad : $flags_string</programlisting>\n";
3413 $desc .= "</programlisting>\n";
3416 $desc .= &MakeDeprecationNote($symbol);
3418 my $parameters = &OutputParamDescriptions ("SIGNAL", $symbol);
3419 my $parameters_output = 0;
3421 $AllSymbols{$symbol} = 1;
3422 if (defined ($SymbolDocs{$symbol})) {
3423 my $symbol_docs = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
3425 # Try to insert the parameter table at the author's desired
3426 # position. Otherwise we need to tag it onto the end.
3427 if ($symbol_docs =~ s/<!--PARAMETERS-->/$parameters/) {
3428 $parameters_output = 1;
3430 $desc .= $symbol_docs;
3432 if (!IsEmptyDoc($SymbolDocs{$symbol})) {
3433 $AllDocumentedSymbols{$symbol} = 1;
3437 if ($parameters_output == 0) {
3438 $desc .= $parameters;
3440 $desc .= OutputSymbolTraits ($symbol);
3441 $desc .= "</refsect2>";
3444 return ($synop, $desc);
3448 #############################################################################
3449 # Function : GetArgs
3450 # Description : Returns the synopsis and detailed description DocBook output
3451 # for the Args of a given GtkObject subclass.
3452 # Arguments : $object - the GtkObject subclass, e.g. 'GtkButton'.
3453 #############################################################################
3459 my $child_synop = "";
3460 my $child_desc = "";
3461 my $style_synop = "";
3462 my $style_desc = "";
3465 for ($i = 0; $i <= $#ArgObjects; $i++) {
3466 if ($ArgObjects[$i] eq $object) {
3467 #print "Found arg: $ArgNames[$i]\n";
3468 my $name = $ArgNames[$i];
3469 my $flags = $ArgFlags[$i];
3470 my $flags_string = "";
3474 if ($flags =~ m/c/) {
3475 $kind = "child property";
3478 elsif ($flags =~ m/s/) {
3479 $kind = "style property";
3486 # Remember only one colon so we don't clash with signals.
3487 my $symbol = "${object}:${name}";
3488 # use two dashes and ev. an extra separator here for the same reason.
3489 my $id = &CreateValidSGMLID ("$object--$id_sep$name");
3491 my $type = $ArgTypes[$i];
3493 my $range = $ArgRanges[$i];
3494 my $range_output = CreateValidSGML ($range);
3495 my $default = $ArgDefaults[$i];
3496 my $default_output = CreateValidSGML ($default);
3498 if ($type eq "GtkString") {
3501 if ($type eq "GtkSignal") {
3502 $type = "GtkSignalFunc, gpointer";
3503 $type_output = &MakeXRef ("GtkSignalFunc") . ", "
3504 . &MakeXRef ("gpointer");
3505 } elsif ($type =~ m/^(\w+)\*$/) {
3506 $type_output = &MakeXRef ($1, &tagify($1, "type")) . "*";
3508 $type_output = &MakeXRef ($type, &tagify($type, "type"));
3511 if ($flags =~ m/r/) {
3512 $flags_string = "Read";
3514 if ($flags =~ m/w/) {
3515 if ($flags_string) { $flags_string .= " / "; }
3516 $flags_string .= "Write";
3518 if ($flags =~ m/x/) {
3519 if ($flags_string) { $flags_string .= " / "; }
3520 $flags_string .= "Construct";
3522 if ($flags =~ m/X/) {
3523 if ($flags_string) { $flags_string .= " / "; }
3524 $flags_string .= "Construct Only";
3527 $AllSymbols{$symbol} = 1;
3529 if (defined($SymbolDocs{$symbol}) &&
3530 !IsEmptyDoc($SymbolDocs{$symbol})) {
3531 $blurb = &ExpandAbbreviations($symbol, $SymbolDocs{$symbol});
3532 #print ".. [$SymbolDocs{$symbol}][$blurb]\n";
3533 $AllDocumentedSymbols{$symbol} = 1;
3536 if (!($ArgBlurbs[$i] eq "")) {
3537 $AllDocumentedSymbols{$symbol} = 1;
3539 # FIXME: print a warning?
3540 #print ".. no description\n";
3542 $blurb = "<para>" . &CreateValidSGML ($ArgBlurbs[$i]) . "</para>";
3545 my $pad1 = " " x (24 - length ($name));
3546 my $pad2 = " " x (20 - length ($type));
3548 my $arg_synop = " "<link linkend=\"$id\">$name</link>"$pad1 $type_output $pad2 : $flags_string\n";
3549 my $arg_desc = "<refsect2 id=\"$id\" role=\"property\"><title>The <literal>"$name"</literal> $kind</title>\n";
3550 $arg_desc .= MakeIndexterms($symbol, $id);
3552 $arg_desc .= OutputSymbolExtraLinks($symbol);
3554 $arg_desc .= "<programlisting> "$name"$pad1 $type_output $pad2 : $flags_string</programlisting>\n";
3555 $arg_desc .= &MakeDeprecationNote($symbol);
3556 $arg_desc .= $blurb;
3558 $arg_desc .= "<para>Allowed values: $range_output</para>\n";
3560 if ($default ne "") {
3561 $arg_desc .= "<para>Default value: $default_output</para>\n";
3563 $arg_desc .= OutputSymbolTraits ($symbol);
3564 $arg_desc .= "</refsect2>\n";
3566 if ($flags =~ m/c/) {
3567 $child_synop .= $arg_synop;
3568 $child_desc .= $arg_desc;
3570 elsif ($flags =~ m/s/) {
3571 $style_synop .= $arg_synop;
3572 $style_desc .= $arg_desc;
3575 $synop .= $arg_synop;
3580 return ($synop, $child_synop, $style_synop, $desc, $child_desc, $style_desc);
3584 #############################################################################
3585 # Function : ReadSourceDocumentation
3586 # Description : This reads in the documentation embedded in comment blocks
3587 # in the source code (for Gnome).
3589 # Parameter descriptions override any in the template files.
3590 # Function descriptions are placed before any description from
3591 # the template files.
3593 # It recursively descends the source directory looking for .c
3594 # files and scans them looking for specially-formatted comment
3597 # Arguments : $source_dir - the directory to scan.
3598 #############m###############################################################
3600 sub ReadSourceDocumentation {
3601 my ($source_dir) = @_;
3602 my ($file, $dir, @suffix_list, $suffix);
3603 #print "Scanning source directory: $source_dir\n";
3605 # This array holds any subdirectories found.
3608 @suffix_list = split (/,/, $SOURCE_SUFFIXES);
3610 opendir (SRCDIR, $source_dir)
3611 || die "Can't open source directory $source_dir: $!";
3613 foreach $file (readdir (SRCDIR)) {
3614 if ($file =~ /^\./) {
3616 } elsif (-d "$source_dir/$file") {
3617 push (@subdirs, $file);
3618 } elsif (@suffix_list) {
3619 foreach $suffix (@suffix_list) {
3620 if ($file =~ m/\.\Q${suffix}\E$/) {
3621 &ScanSourceFile ("$source_dir/$file");
3624 } elsif ($file =~ m/\.[ch]$/) {
3625 &ScanSourceFile ("$source_dir/$file");
3630 # Now recursively scan the subdirectories.
3631 foreach $dir (@subdirs) {
3632 next if ($IGNORE_FILES =~ m/(\s|^)\Q${dir}\E(\s|$)/);
3633 &ReadSourceDocumentation ("$source_dir/$dir");
3638 #############################################################################
3639 # Function : ScanSourceFile
3640 # Description : Scans one source file looking for specially-formatted comment
3641 # blocks. Later &MergeSourceDocumentation is used to merge any
3642 # documentation found with the documentation already read in
3643 # from the template files.
3645 # Arguments : $file - the file to scan.
3646 #############################################################################
3648 sub ScanSourceFile {
3652 if ($file =~ m/^.*[\/\\]([^\/\\]*)$/) {
3655 &LogWarning ($file, 1, "Can't find basename for this filename.");
3659 # Check if the basename is in the list of files to ignore.
3660 if ($IGNORE_FILES =~ m/(\s|^)\Q${basename}\E(\s|$)/) {
3664 #print "DEBUG: Scanning $file\n";
3666 open (SRCFILE, $file)
3667 || die "Can't open $file: $!";
3668 my $in_comment_block = 0;
3670 my ($in_description, $in_return, $in_since, $in_stability, $in_deprecated);
3671 my ($description, $return_desc, $return_start, $return_style);
3672 my ($since_desc, $stability_desc, $deprecated_desc);
3674 my $ignore_broken_returns;
3677 # Look for the start of a comment block.
3678 if (!$in_comment_block) {
3679 if (m%^\s*/\*.*\*/%) {
3680 #one-line comment - not gtkdoc
3681 } elsif (m%^\s*/\*\*\s%) {
3682 #print "Found comment block start\n";
3684 $in_comment_block = 1;
3686 # Reset all the symbol data.
3688 $in_description = 0;
3697 $deprecated_desc = "";
3698 $stability_desc = "";
3699 $current_param = -1;
3700 $ignore_broken_returns = 0;
3706 # We're in a comment block. Check if we've found the end of it.
3709 # maybe its not even meant to be a gtk-doc comment?
3710 &LogWarning ($file, $., "Symbol name not found at the start of the comment block.");
3712 # Add the return value description onto the end of the params.
3714 push (@params, "Returns");
3715 push (@params, $return_desc);
3716 if ($return_style eq 'broken') {
3717 &LogWarning ($file, $., "Free-form return value description in $symbol. Use `Returns:' to avoid ambiguities.");
3720 # Convert special SGML characters
3721 $description = &ConvertSGMLChars ($symbol, $description);
3723 for ($k = 1; $k <= $#params; $k += $PARAM_FIELD_COUNT) {
3724 $params[$k] = &ConvertSGMLChars ($symbol, $params[$k]);
3727 # Handle Section docs
3728 if ($symbol =~ m/SECTION:\s*(.*)/) {
3732 if (scalar %KnownSymbols) {
3733 if ((! defined($KnownSymbols{"$TMPL_DIR/$real_symbol:Long_Description"})) || $KnownSymbols{"$TMPL_DIR/$real_symbol:Long_Description"} != 1) {
3734 &LogWarning ($file, $., "Section $real_symbol is not defined in the $MODULE-section.txt file.");
3738 #print "SECTION DOCS found in source for : '$real_symbol'\n";
3739 $ignore_broken_returns = 1;
3740 for ($k = 0; $k <= $#params; $k += $PARAM_FIELD_COUNT) {
3741 #print " '".$params[$k]."'\n";
3742 $params[$k] = "\L$params[$k]";
3744 if ($params[$k] eq "short_description") {
3745 $key = "$TMPL_DIR/$real_symbol:Short_Description";
3746 } elsif ($params[$k] eq "see_also") {
3747 $key = "$TMPL_DIR/$real_symbol:See_Also";
3748 } elsif ($params[$k] eq "title") {
3749 $key = "$TMPL_DIR/$real_symbol:Title";
3750 } elsif ($params[$k] eq "stability") {
3751 $key = "$TMPL_DIR/$real_symbol:Stability_Level";
3752 } elsif ($params[$k] eq "section_id") {
3753 $key = "$TMPL_DIR/$real_symbol:Section_Id";
3754 } elsif ($params[$k] eq "include") {
3755 $key = "$TMPL_DIR/$real_symbol:Include";
3756 } elsif ($params[$k] eq "image") {
3757 $key = "$TMPL_DIR/$real_symbol:Image";
3759 if (defined($key)) {
3760 $SourceSymbolDocs{$key}=$params[$k+1];
3761 $SourceSymbolSourceFile{$key} = $file;
3762 $SourceSymbolSourceLine{$key} = $.;
3765 $SourceSymbolDocs{"$TMPL_DIR/$real_symbol:Long_Description"}=$description;
3766 $SourceSymbolSourceFile{"$TMPL_DIR/$real_symbol:Long_Description"} = $file;
3767 $SourceSymbolSourceLine{"$TMPL_DIR/$real_symbol:Long_Description"} = $.;
3768 #$SourceSymbolTypes{$symbol} = "SECTION";
3770 #print "SYMBOL DOCS found in source for : '$symbol' ",length($description), "\n";
3771 $SourceSymbolDocs{$symbol} = $description;
3772 $SourceSymbolParams{$symbol} = [ @params ];
3773 # FIXME $SourceSymbolTypes{$symbol} = "STRUCT,SIGNAL,ARG,FUNCTION,MACRO";
3774 #if (defined $DeclarationTypes{$symbol}) {
3775 # $SourceSymbolTypes{$symbol} = $DeclarationTypes{$symbol}
3777 $SourceSymbolSourceFile{$symbol} = $file;
3778 $SourceSymbolSourceLine{$symbol} = $.;
3782 ($since_desc, my @extra_lines) = split ("\n", $since_desc);
3783 $since_desc =~ s/^\s+//;
3784 $since_desc =~ s/\s+$//;
3785 #print "Since($symbol) : [$since_desc]\n";
3786 $Since{$symbol} = &ConvertSGMLChars ($symbol, $since_desc);
3787 if(scalar @extra_lines) {
3788 &LogWarning ($file, $., "multi-line since docs found");
3792 if ($stability_desc) {
3793 $stability_desc = &ParseStabilityLevel($stability_desc, $file, $., "Stability level for $symbol");
3794 $StabilityLevel{$symbol} = &ConvertSGMLChars ($symbol, $stability_desc);
3797 if ($deprecated_desc) {
3798 if (exists $Deprecated{$symbol}) {
3801 # don't warn for signals and properties
3802 #if ($symbol !~ m/::?(.*)/) {
3803 if (defined $DeclarationTypes{$symbol}) {
3804 &LogWarning ($file, $.,
3805 "$symbol is deprecated in the inline comments, but no deprecation guards were found around the declaration.".
3806 " (See the --deprecated-guards option for gtkdoc-scan.)");
3809 $Deprecated{$symbol} = &ConvertSGMLChars ($symbol, $deprecated_desc);
3813 $in_comment_block = 0;
3817 # Get rid of ' * ' at start of every line in the comment block.
3819 # But make sure we don't get rid of the newline at the end.
3823 #print "DEBUG: scanning :$_";
3825 # If we haven't found the symbol name yet, look for it.
3827 if (m%^\s*(SECTION:\s*\S+)%) {
3829 #print "SECTION DOCS found in source for : '$symbol'\n";
3830 $ignore_broken_returns = 1;
3831 } elsif (m%^\s*([\w:-]*\w)\s*:?\s*(\([a-z ]+\)\s*)*$%) {
3833 #print "SYMBOL DOCS found in source for : '$symbol'\n";
3838 # If we're in the return value description, add it to the end.
3840 # If we find another valid returns line, we assume that the first
3841 # one was really part of the description.
3842 if (m/^\s*(returns:|return\s+value:)/i) {
3843 if ($return_style eq 'broken') {
3844 $description .= $return_start . $return_desc;
3847 if ($return_style eq 'sane') {
3848 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3850 $return_style = 'sane';
3851 $ignore_broken_returns = 1;
3853 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3854 $description .= $return_start . $return_desc;
3856 $return_style = 'broken';
3858 } elsif (m%^\s*since:%i) {
3862 } elsif (m%^\s*stability:%i) {
3863 $stability_desc = $';
3866 } elsif (m%^\s*deprecated:%i) {
3867 $deprecated_desc = $';
3877 if (m/^\s*(returns:|return\s+value:)/i) {
3878 if ($return_style eq 'broken') {
3879 $description .= $return_start . $return_desc;
3882 if ($return_style eq 'sane') {
3883 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3885 $return_style = 'sane';
3886 $ignore_broken_returns = 1;
3890 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3892 $return_style = 'broken';
3896 } elsif (m%^\s*deprecated:%i) {
3897 $deprecated_desc = $';
3900 } elsif (m%^\s*stability:%i) {
3901 $stability_desc = $';
3910 if ($in_stability) {
3911 if (m/^\s*(returns:|return\s+value:)/i) {
3912 if ($return_style eq 'broken') {
3913 $description .= $return_start . $return_desc;
3916 if ($return_style eq 'sane') {
3917 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3919 $return_style = 'sane';
3920 $ignore_broken_returns = 1;
3924 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3926 $return_style = 'broken';
3930 } elsif (m%^\s*deprecated:%i) {
3931 $deprecated_desc = $';
3934 } elsif (m%^\s*since:%i) {
3939 $stability_desc .= $_;
3944 if ($in_deprecated) {
3945 if (m/^\s*(returns:|return\s+value:)/i) {
3946 if ($return_style eq 'broken') {
3947 $description .= $return_start . $return_desc;
3950 if ($return_style eq 'sane') {
3951 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3953 $return_style = 'sane';
3954 $ignore_broken_returns = 1;
3958 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3960 $return_style = 'broken';
3964 } elsif (m%^\s*since:%i) {
3968 } elsif (m%^\s*stability:%i) {
3969 $stability_desc = $';
3973 $deprecated_desc .= $_;
3978 # If we're in the description part, check for the 'Returns:' line.
3979 # If that isn't found, add the text to the end.
3980 if ($in_description) {
3981 # Get rid of 'Description:'
3982 s%^\s*Description:%%;
3984 if (m/^\s*(returns:|return\s+value:)/i) {
3985 if ($return_style eq 'broken') {
3986 $description .= $return_start . $return_desc;
3989 if ($return_style eq 'sane') {
3990 &LogWarning ($file, $., "Multiple Returns for $symbol.");
3992 $return_style = 'sane';
3993 $ignore_broken_returns = 1;
3997 } elsif (!$ignore_broken_returns && m/^\s*(returns\b\s*)/i) {
3999 $return_style = 'broken';
4003 } elsif (m%^\s*since:%i) {
4007 } elsif (m%^\s*deprecated:%i) {
4008 $deprecated_desc = $';
4011 } elsif (m%^\s*stability:%i) {
4012 $stability_desc = $';
4021 # We must be in the parameters. Check for the empty line below them.
4023 $in_description = 1;
4027 # Look for a parameter name.
4028 if (m%^\s*@(\S+)\s*:\s*%) {
4029 my $param_name = $1;
4030 my $param_desc = $';
4032 #print "Found parameter: $param_name\n";
4033 # Allow '...' as the Varargs parameter.
4034 if ($param_name eq "...") {
4035 $param_name = "Varargs";
4037 if ("\L$param_name" eq "returns") {
4038 $return_style = 'sane';
4039 $ignore_broken_returns = 1;
4041 push (@params, $param_name);
4042 push (@params, $param_desc);
4043 $current_param += $PARAM_FIELD_COUNT;
4047 # We must be in the middle of a parameter description, so add it on
4048 # to the last element in @params.
4049 if ($current_param == -1) {
4050 &LogWarning ($file, $., "Parsing comment block file : parameter expected.");
4052 $params[$#params] .= $_;
4058 #############################################################################
4059 # Function : OutputMissingDocumentation
4060 # Description : Outputs report of documentation coverage to a file
4063 #############################################################################
4065 sub OutputMissingDocumentation {
4066 my $old_undocumented_file = "$ROOT_DIR/$MODULE-undocumented.txt";
4067 my $new_undocumented_file = "$ROOT_DIR/$MODULE-undocumented.new";
4069 my $n_documented = 0;
4070 my $n_incomplete = 0;
4076 my $buffer_deprecated = "";
4077 my $buffer_descriptions = "";
4079 open(UNDOCUMENTED, ">$new_undocumented_file")
4080 || die "Can't create $new_undocumented_file";
4082 foreach $symbol (sort (keys (%AllSymbols))) {
4083 # FIXME: should we print LogWarnings for undocumented stuff?
4085 #my $ssfile = &GetSymbolSourceFile($symbol);
4086 #my $ssline = &GetSymbolSourceLine($symbol);
4087 #my $location = "defined at " . (defined($ssfile)?$ssfile:"?") . ":" . (defined($ssline)?$ssline:"0") . "\n";
4089 if ($symbol !~ /:(Title|Long_Description|Short_Description|See_Also|Stability_Level|Include|Section_Id|Image)/) {
4091 if (exists ($AllDocumentedSymbols{$symbol})) {
4093 if (exists ($AllIncompleteSymbols{$symbol})) {
4095 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4096 #$buffer .= "\t0: ".$location;
4098 } elsif (exists $Deprecated{$symbol}) {
4099 if (exists ($AllIncompleteSymbols{$symbol})) {
4101 $buffer_deprecated .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4102 #$buffer .= "\t1a: ".$location;
4104 $buffer_deprecated .= $symbol . "\n";
4105 #$buffer .= "\t1b: ".$location;
4108 if (exists ($AllIncompleteSymbols{$symbol})) {
4110 $buffer .= $symbol . " (" . $AllIncompleteSymbols{$symbol} . ")\n";
4111 #$buffer .= "\t2a: ".$location;
4113 $buffer .= $symbol . "\n";
4114 #$buffer .= "\t2b: ".$location;
4117 } elsif ($symbol =~ /:(Long_Description|Short_Description)/) {
4119 #my $len1=(exists($SymbolDocs{$symbol}))?length($SymbolDocs{$symbol}):-1;
4120 #my $len2=(exists($AllDocumentedSymbols{$symbol}))?length($AllDocumentedSymbols{$symbol}):-1;
4121 #print "%%%% $symbol : $len1,$len2\n";
4122 if (((exists ($SymbolDocs{$symbol})) && (length ($SymbolDocs{$symbol}) > 0))
4123 || ((exists ($AllDocumentedSymbols{$symbol})) && (length ($AllDocumentedSymbols{$symbol}) > 0))) {
4126 # cut off the leading namespace ($TMPL_DIR)
4127 $symbol =~ m/^.*\/(.*)$/;
4128 $buffer_descriptions .= $1 . "\n";
4133 $buffer .= "\n" . $buffer_deprecated . "\n" . $buffer_descriptions;
4138 $percent = ($n_documented / $total) * 100.0;
4141 printf UNDOCUMENTED "%.0f%% symbol docs coverage.\n", $percent;
4142 print UNDOCUMENTED "$n_documented symbols documented.\n";
4143 print UNDOCUMENTED "$n_incomplete symbols incomplete.\n";
4144 print UNDOCUMENTED ($total - $n_documented) . " not documented.\n\n\n";
4146 print UNDOCUMENTED $buffer;
4147 close (UNDOCUMENTED);
4149 return &UpdateFileIfChanged ($old_undocumented_file, $new_undocumented_file, 0);
4151 printf "%.0f%% symbol docs coverage", $percent;
4152 print "($n_documented symbols documented, $n_incomplete symbols incomplete, " . ($total - $n_documented) . " not documented)\n";
4153 print "See $MODULE-undocumented.txt for a list of missing docs.\nThe doc coverage percentage doesn't include intro sections.\n";
4157 #############################################################################
4158 # Function : OutputUndeclaredSymbols
4159 # Description : Outputs symbols that are listed in the section file, but not
4160 # declaration is found in the sources
4163 #############################################################################
4165 sub OutputUndeclaredSymbols {
4166 my $old_undeclared_file = "$ROOT_DIR/$MODULE-undeclared.txt";
4167 my $new_undeclared_file = "$ROOT_DIR/$MODULE-undeclared.new";
4169 open(UNDECLARED, ">$new_undeclared_file")
4170 || die "Can't create $new_undeclared_file";
4172 if (%UndeclaredSymbols) {
4173 print UNDECLARED (join("\n", sort keys %UndeclaredSymbols));
4174 print UNDECLARED "\n";
4175 print "See $MODULE-undeclared.txt for the list of undeclared symbols.\n"
4179 return &UpdateFileIfChanged ($old_undeclared_file, $new_undeclared_file, 0);
4182 #############################################################################
4183 # Function : OutputUnusedSymbols
4184 # Description : Outputs symbols that are documented in comments, but not
4185 # declared in the sources
4188 #############################################################################
4190 sub OutputUnusedSymbols {
4192 my $old_unused_file = "$ROOT_DIR/$MODULE-unused.txt";
4193 my $new_unused_file = "$ROOT_DIR/$MODULE-unused.new";
4195 open (UNUSED, ">$new_unused_file")
4196 || die "Can't open $new_unused_file";
4198 foreach $symbol (sort keys (%Declarations)) {
4199 if (!defined ($DeclarationOutput{$symbol})) {
4200 print (UNUSED "$symbol\n");
4204 foreach $symbol (sort (keys (%AllUnusedSymbols))) {
4205 print (UNUSED "$symbol(" . $AllUnusedSymbols{$symbol} . ")\n");
4209 if ($num_unused != 0) {
4210 &LogWarning ($old_unused_file, 1, "$num_unused unused declarations.".
4211 "They should be added to $MODULE-sections.txt in the appropriate place.");
4214 return &UpdateFileIfChanged ($old_unused_file, $new_unused_file, 0);
4218 #############################################################################
4219 # Function : OutputAllSymbols
4220 # Description : Outputs list of all symbols to a file
4223 #############################################################################
4225 sub OutputAllSymbols {
4226 my $n_documented = 0;
4232 open (SYMBOLS, ">$ROOT_DIR/$MODULE-symbols.txt")
4233 || die "Can't create $ROOT_DIR/$MODULE-symbols.txt: $!";
4235 foreach $symbol (sort (keys (%AllSymbols))) {
4236 print SYMBOLS $symbol . "\n";
4242 #############################################################################
4243 # Function : OutputSymbolsWithoutSince
4244 # Description : Outputs list of all symbols without a since tag to a file
4247 #############################################################################
4249 sub OutputSymbolsWithoutSince {
4250 my $n_documented = 0;
4256 open (SYMBOLS, ">$ROOT_DIR/$MODULE-nosince.txt")
4257 || die "Can't create $ROOT_DIR/$MODULE-nosince.txt: $!";
4259 foreach $symbol (sort (keys (%SourceSymbolDocs))) {
4260 if (!defined $Since{$symbol}) {
4261 print SYMBOLS $symbol . "\n";
4269 #############################################################################
4270 # Function : MergeSourceDocumentation
4271 # Description : This merges documentation read from a source file into the
4272 # documentation read in from a template file.
4274 # Parameter descriptions override any in the template files.
4275 # Function descriptions are placed before any description from
4276 # the template files.
4279 #############################################################################
4281 sub MergeSourceDocumentation {
4285 if (scalar %SymbolDocs) {
4286 @Symbols=keys (%SymbolDocs);
4287 #print "num existing entries: ".(scalar @Symbols)."\n";
4288 #print " ",$Symbols[0], " ",$Symbols[1],"\n";
4291 # filter scanned declarations, with what we suppress from -sections.txt
4293 foreach $symbol (keys (%Declarations)) {
4294 if (defined($KnownSymbols{$symbol}) && $KnownSymbols{$symbol} == 1) {
4298 # , add the rest from -sections.txt
4299 foreach $symbol (keys (%KnownSymbols)) {
4300 if ($KnownSymbols{$symbol} == 1) {
4304 # and add whats found in the source
4305 foreach $symbol (keys (%SourceSymbolDocs)) {
4308 @Symbols = keys (%tmp);
4309 #print "num source entries: ".(scalar @Symbols)."\n";
4311 foreach $symbol (@Symbols) {
4312 $AllSymbols{$symbol} = 1;
4314 my $have_tmpl_docs = 0;
4316 ## see if the symbol is documented in template
4317 my $tmpl_doc = defined ($SymbolDocs{$symbol}) ? $SymbolDocs{$symbol} : "";
4318 my $check_tmpl_doc =$tmpl_doc;
4319 # remove all xml-tags and whitespaces
4320 $check_tmpl_doc =~ s/<.*?>//g;
4321 $check_tmpl_doc =~ s/\s//g;
4323 if ($check_tmpl_doc ne "") {
4324 $have_tmpl_docs = 1;
4325 #print "## [$check_tmpl_doc]\n";
4327 # if the docs have just an empty para, don't merge that.
4328 $check_tmpl_doc = $tmpl_doc;
4329 $check_tmpl_doc =~ s/(\s|\n)//msg;
4330 if ($check_tmpl_doc eq "<para></para>") {
4335 if (exists ($SourceSymbolDocs{$symbol})) {
4336 my $type = $DeclarationTypes {$symbol};
4338 #print "merging [$symbol] from source\n";
4340 my $item = "Parameter";
4341 if (defined ($type)) {
4342 if ($type eq 'STRUCT') {
4344 } elsif ($type eq 'ENUM') {
4346 } elsif ($type eq 'UNION') {
4353 my $src_doc = $SourceSymbolDocs{$symbol};
4354 # remove leading and training whitespaces
4355 $src_doc =~ s/^\s+//;
4356 $src_doc =~ s/\s+$//;
4358 # Don't output warnings for overridden titles as titles are
4359 # automatically generated in the -sections.txt file, and thus they
4360 # are often overridden.
4361 if ($have_tmpl_docs && $symbol !~ m/:Title$/) {
4362 # check if content is different
4363 if ($tmpl_doc ne $src_doc) {
4364 #print "[$tmpl_doc] [$src_doc]\n";
4365 &LogWarning ($SourceSymbolSourceFile{$symbol}, $SourceSymbolSourceLine{$symbol},
4366 "Documentation in template ".$SymbolSourceFile{$symbol}.":".$SymbolSourceLine{$symbol}." for $symbol being overridden by inline comments.");
4370 if ($src_doc ne "") {
4371 $AllDocumentedSymbols{$symbol} = 1;
4374 # Convert <!--PARAMETERS--> with any blank lines around it to
4375 # a </para> followed by <!--PARAMETERS--> followed by <para>.
4376 $src_doc =~ s%\n+\s*<!--PARAMETERS-->\s*\n+%\n</para>\n<!--PARAMETERS-->\n<para>\n%g;
4378 # Do not add <para> to nothing, it breaks missing docs checks.
4379 my $src_doc_para = "";
4380 if ($src_doc ne "") {
4381 # Expand markdown (and do paragraphs)
4382 $src_doc_para = &ConvertMarkDown ($src_doc, $symbol);
4384 # FIXME: this is questionable, as we can't make assumtions on the content really
4385 #$src_doc_para =~ s%^<para>\n(<refsect[1-9])%$1%gms;
4386 #$src_doc_para =~ s%^<para>\n<para>%<para>%gms;
4387 #$src_doc_para =~ s%(</refsect[1-9]>)\n</para>$%$1%gms;
4388 #print "$symbol : [$src_doc][$src_doc_para]\n";
4391 if ($symbol =~ m/$TMPL_DIR\/.+:Long_Description/) {
4392 $SymbolDocs{$symbol} = "$src_doc_para$tmpl_doc";
4393 } elsif ($symbol =~ m/$TMPL_DIR\/.+:.+/) {
4394 # For the title/summary/see also section docs we don't want to
4395 # add any <para> tags.
4396 $SymbolDocs{$symbol} = "$src_doc"
4398 $SymbolDocs{$symbol} = "$src_doc_para$tmpl_doc";
4402 if ($symbol =~ m/.*::.*/) {
4403 # For signals we prefer the param names from the source docs,
4404 # since the ones from the templates are likely to contain the
4405 # artificial argn names which are generated by gtkdoc-scangobj.
4406 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
4407 # FIXME: we need to check for empty docs here as well!
4409 # The templates contain the definitive parameter names and order,
4410 # so we will not change that. We only override the actual text.
4411 my $tmpl_params = $SymbolParams{$symbol};
4412 if (!defined ($tmpl_params)) {
4413 #print "No merge needed for $symbol\n";
4414 $SymbolParams{$symbol} = $SourceSymbolParams{$symbol};
4415 # FIXME: we still like to get the number of params and merge
4416 # 1) we would noticed that params have been removed/renamed
4417 # 2) we would catch undocumented params
4418 # params are not (yet) exported in -decl.txt so that we
4419 # could easily grab them :/
4421 my $params = $SourceSymbolParams{$symbol};
4423 #print "Merge needed for $symbol, tmpl_params: ",$#$tmpl_params,", source_params: ",$#$params," \n";
4424 for ($j = 0; $j <= $#$tmpl_params; $j += $PARAM_FIELD_COUNT) {
4425 my $tmpl_param_name = $$tmpl_params[$j];
4427 # Allow '...' as the Varargs parameter.
4428 if ($tmpl_param_name eq "...") {
4429 $tmpl_param_name = "Varargs";
4432 # Try to find the param in the source comment documentation.
4435 #print " try merge param $tmpl_param_name\n";
4436 for ($k = 0; $k <= $#$params; $k += $PARAM_FIELD_COUNT) {
4437 my $param_name = $$params[$k];
4438 my $param_desc = $$params[$k + 1];
4440 #print " test param $param_name\n";
4441 # We accept changes in case, since the Gnome source
4442 # docs contain a lot of these.
4443 if ("\L$param_name" eq "\L$tmpl_param_name") {
4446 # Override the description.
4447 $$tmpl_params[$j + 1] = $param_desc;
4449 # Set the name to "" to mark it as used.
4455 # If it looks like the parameters are there, but not
4456 # in the right place, try to explain a bit better.
4457 if ((!$found) && ($src_doc =~ m/\@$tmpl_param_name:/)) {
4458 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4459 "Parameters for $symbol must start on the line immediately after the function or macro name.");
4463 # Now we output a warning if parameters have been described which
4465 for ($j = 0; $j <= $#$params; $j += $PARAM_FIELD_COUNT) {
4466 my $param_name = $$params[$j];
4468 # the template builder cannot detect if a macro returns
4470 if(($type eq "MACRO") && ($param_name eq "Returns")) {
4471 # FIXME: do we need to add it then to tmpl_params[] ?
4472 my $num=$#$tmpl_params;
4473 #print " adding Returns: to macro docs for $symbol.\n";
4474 $$tmpl_params[$num+1]="Returns";
4475 $$tmpl_params[$num+2]=$$params[$j+1];
4478 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4479 "$item described in source code comment block but does not exist. $type: $symbol $item: $param_name.");
4485 if ($have_tmpl_docs) {
4486 $AllDocumentedSymbols{$symbol} = 1;
4487 #print "merging [$symbol] from template\n";
4490 #print "[$symbol] undocumented\n";
4494 # if this symbol is documented, check if docs are complete
4495 $check_tmpl_doc = defined ($SymbolDocs{$symbol}) ? $SymbolDocs{$symbol} : "";
4496 # remove all xml-tags and whitespaces
4497 $check_tmpl_doc =~ s/<.*?>//g;
4498 $check_tmpl_doc =~ s/\s//g;
4499 if ($check_tmpl_doc ne "") {
4500 my $tmpl_params = $SymbolParams{$symbol};
4501 if (defined ($tmpl_params)) {
4502 my $type = $DeclarationTypes {$symbol};
4504 my $item = "Parameter";
4505 if (defined ($type)) {
4506 if ($type eq 'STRUCT') {
4508 } elsif ($type eq 'ENUM') {
4510 } elsif ($type eq 'UNION') {
4517 #print "Check param docs for $symbol, tmpl_params: ",$#$tmpl_params," entries, type=$type\n";
4519 if ($#$tmpl_params > 0) {
4521 for ($j = 0; $j <= $#$tmpl_params; $j += $PARAM_FIELD_COUNT) {
4522 # Output a warning if the parameter is empty and
4523 # remember for stats.
4524 my $tmpl_param_name = $$tmpl_params[$j];
4525 my $tmpl_param_desc = $$tmpl_params[$j + 1];
4526 if ($tmpl_param_name ne "void" && $tmpl_param_desc !~ m/\S/) {
4527 if (exists ($AllIncompleteSymbols{$symbol})) {
4528 $AllIncompleteSymbols{$symbol}.=", ".$tmpl_param_name;
4530 $AllIncompleteSymbols{$symbol}=$tmpl_param_name;
4532 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4533 "$item description for $symbol"."::"."$tmpl_param_name is missing in source code comment block.");
4538 if ($#$tmpl_params == 0) {
4539 $AllIncompleteSymbols{$symbol}="<items>";
4540 &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
4541 "$item descriptions for $symbol are missing in source code comment block.");
4543 # $#$tmpl_params==-1 means we don't know about parameters
4544 # this unfortunately does not tell if there should be some
4549 #print "num doc entries: ".(scalar %SymbolDocs)."\n";
4552 #############################################################################
4553 # Function : IsEmptyDoc
4554 # Description : Check if a doc-string is empty. Its also regarded as empty if
4555 # it only consist of whitespace or e.g. FIXME.
4556 # Arguments : the doc-string
4557 #############################################################################
4561 if ($doc =~ /^\s*$/) {
4565 if ($doc =~ /^\s*<para>\s*(FIXME)?\s*<\/para>\s*$/) {
4573 #############################################################################
4574 # Function : ConvertMarkDown
4575 # Description : Converts mark down syntax to the respective docbook, but only
4576 # outside CDATA and <programlisting> tags.
4577 # http://de.wikipedia.org/wiki/Markdown
4578 # Code snippets have been takesn from
4579 # http://daringfireball.net/projects/markdown/
4580 # Copyright (c) 2004 John Gruber
4581 # Arguments : the doc-string, the symbol name
4582 #############################################################################
4584 sub ConvertMarkDown {
4585 my ($text, $symbol) = @_;
4591 $text = &ModifyXMLElements ($text, $symbol,
4592 "<!\\[CDATA\\[|<programlisting[^>]*>|\\|\\[",
4593 \&ConvertMarkDownEndTag,
4594 \&ConvertMarkDownCallback);
4595 # encapsulate and terminate
4596 $text = "<para>\n$text\n</para>";
4597 if ($md_in_refsect2==1) {
4598 $text = "$text</refsect2>"
4603 sub ConvertMarkDownEndTag {
4604 if ($_[0] eq "<!\[CDATA\[") {
4606 } elsif ($_[0] eq "|[") {
4609 return "</programlisting>";
4613 sub ConvertMarkDownCallback {
4614 my ($text, $symbol, $tag) = @_;
4616 # If we're not in CDATA or a <programlisting> we convert blank lines so
4617 # they start a new <para>.
4620 my $end_of_section="";
4623 $end_of_para = "$end_of_para</para>";
4624 $end_of_section = "$end_of_section</para>";
4625 if ($md_in_refsect2==1) {
4626 $end_of_section= "$end_of_section</refsect2>";
4629 # Setext-style headers:
4636 if($text =~ s%^\n(.+)[ \t]*\n=+[ \t]*\n\n%$end_of_section<refsect2><title>$1</title><para>\n%gm) {
4640 # atx-style headers:
4643 # ## Header 2 with closing hashes ##
4647 if($text =~ s%^\n\#[ \t]*(.+?)[ \t]*\#\n+%$end_of_section<refsect2><title>$1</title><para>\n%gm) {
4651 # Simple (unnested) lists:
4654 # - item 2 with loooong
4659 $text.="\n"; # we need a new line to avoid too complicated matching rules below
4660 if ($text =~ s%(?<=\n)-\s+(.+?)(?=(?:\n-\s+)|(?:\n\n)|(?:\n$))%<listitem><para>$1</para></listitem>%gs) {
4661 $text =~ s%(?<!</listitem>)(\n<listitem>)%\n<itemizedlist>$1%g;
4662 $text =~ s%(</listitem>\n)(?!<listitem>)%$1</itemizedlist>\n%g;
4666 # Make Paragraphs on blank lines
4667 $text =~ s%\n{2,}%\n$end_of_para\n<para>\n%g;
4674 #############################################################################
4675 # LIBRARY FUNCTIONS - These functions are used in both gtkdoc-mkdb and
4676 # gtkdoc-mktmpl and should eventually be moved to a
4678 #############################################################################
4680 #############################################################################
4681 # Function : ReadDeclarationsFile
4682 # Description : This reads in a file containing the function/macro/enum etc.
4685 # Note that in some cases there are several declarations with
4686 # the same name, e.g. for conditional macros. In this case we
4687 # set a flag in the %DeclarationConditional hash so the
4688 # declaration is not shown in the docs.
4690 # If a macro and a function have the same name, e.g. for
4691 # gtk_object_ref, the function declaration takes precedence.
4693 # Some opaque structs are just declared with 'typedef struct
4694 # _name name;' in which case the declaration may be empty.
4695 # The structure may have been found later in the header, so
4696 # that overrides the empty declaration.
4698 # Arguments : $file - the declarations file to read
4699 # $override - if declarations in this file should override
4700 # any current declaration.
4701 #############################################################################
4703 sub ReadDeclarationsFile {
4704 my ($file, $override) = @_;
4706 if ($override == 0) {
4708 %DeclarationTypes = ();
4709 %DeclarationConditional = ();
4710 %DeclarationOutput = ();
4714 || die "Can't open $file: $!";
4715 my $declaration_type = "";
4716 my $declaration_name;
4718 my $is_deprecated = 0;
4720 if (!$declaration_type) {
4721 if (m/^<([^>]+)>/) {
4722 $declaration_type = $1;
4723 $declaration_name = "";
4724 #print "Found declaration: $declaration_type\n";
4728 if (m%^<NAME>(.*)</NAME>%) {
4729 $declaration_name = $1;
4730 } elsif (m%^<DEPRECATED/>%) {
4732 } elsif (m%^</$declaration_type>%) {
4733 #print "Found end of declaration: $declaration_name\n";
4734 # Check that the declaration has a name
4735 if ($declaration_name eq "") {
4736 print "ERROR: $declaration_type has no name $file:$.\n";
4739 # If the declaration is an empty typedef struct _XXX XXX
4740 # set the flag to indicate the struct has a typedef.
4741 if ($declaration_type eq 'STRUCT'
4742 && $declaration =~ m/^\s*$/) {
4743 #print "Struct has typedef: $declaration_name\n";
4744 $StructHasTypedef{$declaration_name} = 1;
4747 # Check if the symbol is already defined.
4748 if (defined ($Declarations{$declaration_name})
4749 && $override == 0) {
4750 # Function declarations take precedence.
4751 if ($DeclarationTypes{$declaration_name} eq 'FUNCTION') {
4753 } elsif ($declaration_type eq 'FUNCTION') {
4754 if ($is_deprecated) {
4755 $Deprecated{$declaration_name} = "";
4757 $Declarations{$declaration_name} = $declaration;
4758 $DeclarationTypes{$declaration_name} = $declaration_type;
4759 } elsif ($DeclarationTypes{$declaration_name}
4760 eq $declaration_type) {
4761 # If the existing declaration is empty, or is just a
4762 # forward declaration of a struct, override it.
4763 if ($declaration_type eq 'STRUCT') {
4764 if ($Declarations{$declaration_name} =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
4765 if ($is_deprecated) {
4766 $Deprecated{$declaration_name} = "";
4768 $Declarations{$declaration_name} = $declaration;
4769 } elsif ($declaration =~ m/^\s*(struct\s+\w+\s*;)?\s*$/) {
4770 # Ignore an empty or forward declaration.
4772 &LogWarning ($file, $., "Structure $declaration_name has multiple definitions.");
4775 # set flag in %DeclarationConditional hash for
4776 # multiply defined macros/typedefs.
4777 $DeclarationConditional{$declaration_name} = 1;
4780 &LogWarning ($file, $., "$declaration_name has multiple definitions.");
4783 if ($is_deprecated) {
4784 $Deprecated{$declaration_name} = "";
4786 $Declarations{$declaration_name} = $declaration;
4787 $DeclarationTypes{$declaration_name} = $declaration_type;
4790 $declaration_type = "";
4801 #############################################################################
4802 # Function : ReadSignalsFile
4803 # Description : This reads in an existing file which contains information on
4804 # all GTK signals. It creates the arrays @SignalNames and
4805 # @SignalPrototypes containing info on the signals. The first
4806 # line of the SignalPrototype is the return type of the signal
4807 # handler. The remaining lines are the parameters passed to it.
4808 # The last parameter, "gpointer user_data" is always the same
4809 # so is not included.
4810 # Arguments : $file - the file containing the signal handler prototype
4812 #############################################################################
4814 sub ReadSignalsFile {
4822 my $signal_prototype;
4824 # Reset the signal info.
4825 @SignalObjects = ();
4827 @SignalReturns = ();
4829 @SignalPrototypes = ();
4834 if (!open (INPUT, $file)) {
4835 warn "Can't open $file - skipping signals\n";
4842 $signal_object = "";
4844 $signal_returns = "";
4845 $signal_prototype = "";
4848 if (m/^<NAME>(.*)<\/NAME>/) {
4850 if ($signal_name =~ m/^(.*)::(.*)$/) {
4851 $signal_object = $1;
4852 ($signal_name = $2) =~ s/_/-/g;
4853 #print "Found signal: $signal_name\n";
4855 &LogWarning ($file, $., "Invalid signal name: $signal_name.");
4857 } elsif (m/^<RETURNS>(.*)<\/RETURNS>/) {
4858 $signal_returns = $1;
4859 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
4861 } elsif (m%^</SIGNAL>%) {
4862 #print "Found end of signal: ${signal_object}::${signal_name}\nReturns: ${signal_returns}\n${signal_prototype}";
4863 push (@SignalObjects, $signal_object);
4864 push (@SignalNames, $signal_name);
4865 push (@SignalReturns, $signal_returns);
4866 push (@SignalFlags, $signal_flags);
4867 push (@SignalPrototypes, $signal_prototype);
4870 $signal_prototype .= $_;
4878 #############################################################################
4879 # Function : ReadTemplateFile
4880 # Description : This reads in the manually-edited documentation file
4881 # corresponding to the file currently being created, so we can
4882 # insert the documentation at the appropriate places.
4883 # It outputs %SymbolTypes, %SymbolDocs and %SymbolParams, which
4884 # is a hash of arrays.
4885 # NOTE: This function is duplicated in gtkdoc-mktmpl (but
4886 # slightly different).
4887 # Arguments : $docsfile - the template file to read in.
4888 # $skip_unused_params - 1 if the unused parameters should be
4890 #############################################################################
4892 sub ReadTemplateFile {
4893 my ($docsfile, $skip_unused_params) = @_;
4895 my $template = "$docsfile.sgml";
4896 if (! -f $template) {
4897 #print "File doesn't exist: $template\n";
4900 #print "Reading $template\n";
4902 # start with empty hashes, we merge the source comment for each file
4908 my $current_type = ""; # Type of symbol being read.
4909 my $current_symbol = ""; # Name of symbol being read.
4910 my $symbol_doc = ""; # Description of symbol being read.
4911 my @params; # Parameter names and descriptions of current
4912 # function/macro/function typedef.
4913 my $current_param = -1; # Index of parameter currently being read.
4914 # Note that the param array contains pairs
4915 # of param name & description.
4916 my $in_unused_params = 0; # True if we are reading in the unused params.
4917 my $in_deprecated = 0;
4919 my $in_stability = 0;
4921 open (DOCS, "$template")
4922 || die "Can't open $template: $!";
4924 if (m/^<!-- ##### ([A-Z_]+) (\S+) ##### -->/) {
4927 if ($symbol eq "Title"
4928 || $symbol eq "Short_Description"
4929 || $symbol eq "Long_Description"
4930 || $symbol eq "See_Also"
4931 || $symbol eq "Stability_Level"
4932 || $symbol eq "Include"
4933 || $symbol eq "Image") {
4935 $symbol = $docsfile . ":" . $symbol;
4938 #print "Found symbol: $symbol\n";
4939 # Remember file and line for the symbol
4940 $SymbolSourceFile{$symbol} = $template;
4941 $SymbolSourceLine{$symbol} = $.;
4943 # Store previous symbol, but remove any trailing blank lines.
4944 if ($current_symbol ne "") {
4945 $symbol_doc =~ s/\s+$//;
4946 $SymbolTypes{$current_symbol} = $current_type;
4947 $SymbolDocs{$current_symbol} = $symbol_doc;
4949 # Check that the stability level is valid.
4950 if ($StabilityLevel{$current_symbol}) {
4951 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, $template, $., "Stability level for $current_symbol");
4954 if ($current_param >= 0) {
4955 $SymbolParams{$current_symbol} = [ @params ];
4957 # Delete any existing params in case we are overriding a
4958 # previously read template.
4959 delete $SymbolParams{$current_symbol};
4962 $current_type = $type;
4963 $current_symbol = $symbol;
4964 $current_param = -1;
4965 $in_unused_params = 0;
4972 } elsif (m/^<!-- # Unused Parameters # -->/) {
4973 #print "DEBUG: Found unused parameters\n";
4974 $in_unused_params = 1;
4977 } elsif ($in_unused_params && $skip_unused_params) {
4978 # When outputting the DocBook we skip unused parameters.
4979 #print "DEBUG: Skipping unused param: $_";
4983 # Check if param found. Need to handle "..." and "format...".
4984 if (s/^\@([\w\.]+):\040?//) {
4985 my $param_name = $1;
4986 my $param_desc = $_;
4987 # Allow variations of 'Returns'
4988 if ($param_name =~ m/^[Rr]eturns?$/) {
4989 $param_name = "Returns";
4992 # strip trailing whitespaces and blank lines
4995 #print "Found param for symbol $current_symbol : '$param_name'= '$_'";
4997 if ($param_name eq "Deprecated") {
4999 $Deprecated{$current_symbol} = $_;
5000 } elsif ($param_name eq "Since") {
5003 $Since{$current_symbol} = $_;
5004 } elsif ($param_name eq "Stability") {
5006 $StabilityLevel{$current_symbol} = $_;
5008 push (@params, $param_name);
5009 push (@params, $param_desc);
5010 $current_param += $PARAM_FIELD_COUNT;
5013 # strip trailing whitespaces and blank lines
5018 if ($in_deprecated) {
5019 $Deprecated{$current_symbol} .= $_;
5020 } elsif ($in_since) {
5021 &LogWarning ($template, $., "multi-line since docs found");
5022 #$Since{$current_symbol} .= $_;
5023 } elsif ($in_stability) {
5024 $StabilityLevel{$current_symbol} .= $_;
5025 } elsif ($current_param >= 0) {
5026 $params[$current_param] .= $_;
5035 # Remember to finish the current symbol doccs.
5036 if ($current_symbol ne "") {
5038 $symbol_doc =~ s/\s+$//;
5039 $SymbolTypes{$current_symbol} = $current_type;
5040 $SymbolDocs{$current_symbol} = $symbol_doc;
5042 # Check that the stability level is valid.
5043 if ($StabilityLevel{$current_symbol}) {
5044 $StabilityLevel{$current_symbol} = &ParseStabilityLevel($StabilityLevel{$current_symbol}, $template, $., "Stability level for $current_symbol");
5047 if ($current_param >= 0) {
5048 $SymbolParams{$current_symbol} = [ @params ];
5050 # Delete any existing params in case we are overriding a
5051 # previously read template.
5052 delete $SymbolParams{$current_symbol};
5061 #############################################################################
5062 # Function : ReadObjectHierarchy
5063 # Description : This reads in the $MODULE-hierarchy.txt file containing all
5064 # the GtkObject subclasses described in this module (and their
5066 # It places them in the @Objects array, and places their level
5067 # in the object hierarchy in the @ObjectLevels array, at the
5068 # same index. GtkObject, the root object, has a level of 1.
5070 # FIXME: the version in gtkdoc-mkdb also generates tree_index.sgml
5071 # as it goes along, this should be split out into a separate
5075 #############################################################################
5077 sub ReadObjectHierarchy {
5081 if (! -f $OBJECT_TREE_FILE) {
5084 if (!open (INPUT, $OBJECT_TREE_FILE)) {
5085 warn "Can't open $OBJECT_TREE_FILE - skipping object tree\n";
5089 # FIXME: use $OUTPUT_FORMAT
5090 # my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.$OUTPUT_FORMAT";
5091 my $old_tree_index = "$SGML_OUTPUT_DIR/tree_index.sgml";
5092 my $new_tree_index = "$SGML_OUTPUT_DIR/tree_index.new";
5094 open (OUTPUT, ">$new_tree_index")
5095 || die "Can't create $new_tree_index: $!";
5097 if ($OUTPUT_FORMAT eq "xml") {
5098 my $tree_header = $doctype_header;
5100 $tree_header =~ s/<!DOCTYPE \w+/<!DOCTYPE screen/;
5101 print (OUTPUT "$tree_header");
5103 print (OUTPUT "<screen>\n");
5105 # Only emit objects if they are supposed to be documented, or if
5106 # they have documented children. To implement this, we maintain a
5107 # stack of pending objects which will be emitted if a documented
5109 my @pending_objects = ();
5110 my @pending_levels = ();
5114 my $level = (length($`)) / 2 + 1;
5117 while (($#pending_levels >= 0) && ($pending_levels[$#pending_levels] >= $level)) {
5118 my $pobject = pop(@pending_objects);
5119 my $plevel = pop(@pending_levels);
5122 push (@pending_objects, $object);
5123 push (@pending_levels, $level);
5125 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
5126 while ($#pending_levels >= 0) {
5127 $object = shift @pending_objects;
5128 $level = shift @pending_levels;
5129 $xref = &MakeXRef ($object);
5131 print (OUTPUT ' ' x ($level * 4), "$xref\n");
5132 push (@Objects, $object);
5133 push (@ObjectLevels, $level);
5137 # LogWarning ($OBJECT_TREE_FILE, $., "unknown type $object");
5141 print (OUTPUT "</screen>\n");
5146 &UpdateFileIfChanged ($old_tree_index, $new_tree_index, 0);
5151 #############################################################################
5152 # Function : ReadInterfaces
5153 # Description : This reads in the $MODULE.interfaces file.
5156 #############################################################################
5158 sub ReadInterfaces {
5161 if (! -f $INTERFACES_FILE) {
5164 if (!open (INPUT, $INTERFACES_FILE)) {
5165 warn "Can't open $INTERFACES_FILE - skipping interfaces\n";
5171 my ($object, @ifaces) = split;
5172 if (exists($KnownSymbols{$object}) && $KnownSymbols{$object} == 1) {
5173 my @knownIfaces = ();
5175 # filter out private interfaces, but leave foreign interfaces
5176 foreach my $iface (@ifaces) {
5177 if (!exists($KnownSymbols{$iface}) || $KnownSymbols{$iface} == 1) {
5178 push (@knownIfaces, $iface);
5182 $Interfaces{$object} = join(' ', @knownIfaces);
5188 #############################################################################
5189 # Function : ReadPrerequisites
5190 # Description : This reads in the $MODULE.prerequisites file.
5193 #############################################################################
5195 sub ReadPrerequisites {
5196 %Prerequisites = ();
5198 if (! -f $PREREQUISITES_FILE) {
5201 if (!open (INPUT, $PREREQUISITES_FILE)) {
5202 warn "Can't open $PREREQUISITES_FILE - skipping prerequisites\n";
5208 my ($iface, @prereqs) = split;
5209 if (exists($KnownSymbols{$iface}) && $KnownSymbols{$iface} == 1) {
5210 my @knownPrereqs = ();
5212 # filter out private prerequisites, but leave foreign prerequisites
5213 foreach my $prereq (@prereqs) {
5214 if (!exists($KnownSymbols{$prereq}) || $KnownSymbols{$prereq} == 1) {
5215 push (@knownPrereqs, $prereq);
5219 $Prerequisites{$iface} = join(' ', @knownPrereqs);
5225 #############################################################################
5226 # Function : ReadArgsFile
5227 # Description : This reads in an existing file which contains information on
5228 # all GTK args. It creates the arrays @ArgObjects, @ArgNames,
5229 # @ArgTypes, @ArgFlags, @ArgNicks and @ArgBlurbs containing info
5231 # Arguments : $file - the file containing the arg information.
5232 #############################################################################
5247 # Reset the args info.
5260 if (!open (INPUT, $file)) {
5261 warn "Can't open $file - skipping args\n";
5278 if (m/^<NAME>(.*)<\/NAME>/) {
5280 if ($arg_name =~ m/^(.*)::(.*)$/) {
5282 ($arg_name = $2) =~ s/_/-/g;
5283 #print "Found arg: $arg_name\n";
5285 &LogWarning ($file, $., "Invalid argument name: $arg_name");
5287 } elsif (m/^<TYPE>(.*)<\/TYPE>/) {
5289 } elsif (m/^<RANGE>(.*)<\/RANGE>/) {
5291 } elsif (m/^<FLAGS>(.*)<\/FLAGS>/) {
5293 } elsif (m/^<NICK>(.*)<\/NICK>/) {
5295 } elsif (m/^<BLURB>(.*)<\/BLURB>/) {
5297 if ($arg_blurb eq "(null)") {
5299 &LogWarning ($file, $., "Property ${arg_object}:${arg_name} has no documentation.");
5301 } elsif (m/^<DEFAULT>(.*)<\/DEFAULT>/) {
5303 } elsif (m%^</ARG>%) {
5304 #print "Found end of arg: ${arg_object}::${arg_name}\n${arg_type} : ${arg_flags}\n";
5305 push (@ArgObjects, $arg_object);
5306 push (@ArgNames, $arg_name);
5307 push (@ArgTypes, $arg_type);
5308 push (@ArgRanges, $arg_range);
5309 push (@ArgFlags, $arg_flags);
5310 push (@ArgNicks, $arg_nick);
5311 push (@ArgBlurbs, $arg_blurb);
5312 push (@ArgDefaults, $arg_default);
5321 #############################################################################
5322 # Function : CheckIsObject
5323 # Description : Returns 1 if the given name is a GObject or a subclass.
5324 # It uses the global @Objects array.
5325 # Note that the @Objects array only contains classes in the
5326 # current module and their ancestors - not all GObject classes.
5327 # Arguments : $name - the name to check.
5328 #############################################################################
5334 foreach $object (@Objects) {
5335 if ($object eq $name) {
5343 #############################################################################
5344 # Function : MakeReturnField
5345 # Description : Pads a string to $RETURN_TYPE_FIELD_WIDTH.
5346 # Arguments : $str - the string to pad.
5347 #############################################################################
5349 sub MakeReturnField {
5352 return $str . (' ' x ($RETURN_TYPE_FIELD_WIDTH - length ($str)));
5355 #############################################################################
5356 # Function : GetSymbolSourceFile
5357 # Description : Get the filename where the symbol docs where taken from.
5358 # Arguments : $symbol - the symbol name
5359 #############################################################################
5361 sub GetSymbolSourceFile {
5364 if (defined($SourceSymbolSourceFile{$symbol})) {
5365 return $SourceSymbolSourceFile{$symbol};
5366 } elsif (defined($SymbolSourceFile{$symbol})) {
5367 return $SymbolSourceFile{$symbol};
5373 #############################################################################
5374 # Function : GetSymbolSourceLine
5375 # Description : Get the file line where the symbol docs where taken from.
5376 # Arguments : $symbol - the symbol name
5377 #############################################################################
5379 sub GetSymbolSourceLine {
5382 if (defined($SourceSymbolSourceLine{$symbol})) {
5383 return $SourceSymbolSourceLine{$symbol};
5384 } elsif (defined($SymbolSourceLine{$symbol})) {
5385 return $SymbolSourceLine{$symbol};