\n/g;
# Highlight URLs
$comment =~ s,(http://\S+),$1<\/a>,g;
# Highlight internal cross-refs. This is done by detecting words starting
# with an upper case that reference a known package or widget type
$comment =~ s/([A-Z](?:\.?\w+)*)/
my ($name) = $1;
my ($file, $anchor);
if (defined $params{$name}) {
"$name<\/tt>";
} else {
if (defined $entities{$name}) {
($file, $anchor) = @{$entities{$name}};
} elsif (defined $entities{"${name}_Record"}) {
($file, $anchor) = @{$entities{"${name}_Record"}};
} elsif (defined $entities{"$package.${name}_Record"}) {
($file, $anchor) = @{$entities{"$package.${name}_Record"}};
} elsif (defined $entities{"$package.$name"}) {
($file, $anchor) = @{$entities{"$package.$name"}};
}
if (defined $file) {
if ($anchor ne "") {
"$name<\/a>";
} else {
"$name<\/a>";
}
} else {
$name;
}
}
/xeg;
## Highlight cross-refs to specific file names (only starting with g
## so that we do not add xref to files in testgtk, since no html is
## generated for these)
$comment =~ s/\b(g[\w.-]+)(\.ad[bs])/$1$2<\/a>/g;
return $comment;
}
#####################
## Display the profile of a subprogram, including xref
#####################
sub process_profile() {
my ($profile) = shift;
# Unindent as much as possible
$profile =~ s/^[ \t]*\n//mg;
my ($spaces) = ($profile =~ /^(\s*)/);
$profile =~ s/^$spaces//gm;
# Remove empty lines
$profile =~ s/\s*$//;
# Create xref for types
$profile =~ s/(:\s*(?:access|in|out)?\s*)([\w.]+)((?:'Class)?(\s*:=\s*\w+)?[;)])/
if (defined $entities{$2}) {
"$1$2<\/a>$3";
} else {
"$1$2$3";
}
/xeg;
$profile =~ s/(return\s+|is\s+new\s+)([\w.]+)/
if (defined $entities{$2}) {
"$1$2<\/a>";
} else {
"$1$2";
}
/xeg;
return &highlight_syntax ($profile);
}
sub highlight_syntax() {
my ($profile) = shift;
# Highlight comments
$profile =~ s/^([ \t]*--.*)/$1<\/i>/mg;
# Highlight subprogram name (for subprograms section, not examples)
$profile =~ s/^(procedure|function)\s+(\w+|".")/$1 $2<\/span>/gi;
# Highlight keywords, not in comments
$profile =~ s/\b($keywords)\b/$1<\/b>/og;
while (($profile =~ s/(.*)(\w+)<\/b>/$1$2/g)){};
return $profile;
}
######################
## Parse the signals section
######################
our $non_empty_non_signal_comment_re = '(?:[ \t]+-- [^-][^\n]*\n)';
our $non_empty_comment_non_signal_block_re =
'(' . $non_empty_non_signal_comment_re . '*)';
our $signal_re = '--[ \t]+-[ \t]*"(\w+)"\n' # Signal name
. '[ \t]+--[ \t]+((?:procedure|function) Handler[\s-]+\([^)]+\)[\s-]*'
. '(?:return [\w.]+)?;)\n'
. $empty_comment_re . '?' # Optional blank line between profile and comment
. $non_empty_comment_non_signal_block_re; # comment
sub parse_signals() {
my ($section) = shift;
my (%signals);
while ($section =~ /$signal_re/goi) {
my ($name, $profile, $comment) = ($1, $2, $3);
$profile =~ s/^\s+--//mg if (defined $profile);
$signals{$name} = [$profile, $comment];
}
return %signals;
}
######################
## Parse the properties section
######################
our $properties_re = '--[ \t]+(?:- )?Name:[ \t]*(.+)\n'
. '[ \t]+--[ \t]+(?:- )?Type:[ \t]*(.+)\n'
. '(?:[ \t]+--[ \t]+(?:- )?Flags:[ \t]*(.+\n))?'
. '(?:[ \t]+--[ \t]+(?:- )?Descr:[ \t]*(.+\n(?:--[ \t]{4,})*))?'
. '(?:[ \t]+--[ \t]+(?:- )?See also:[ \t]*(.+)\n)?';
sub parse_properties() {
my ($section) = shift;
my (%properties);
while ($section =~ /$properties_re/goi) {
my ($name, $type, $descr, $see) = ($1, $2, $4, $5);
$properties{$name} = [$type, $descr, $see];
}
return %properties;
}
######################
## Generate a HTML header in the given FILE
######################
sub generate_header() {
my ($title) = shift;
local (*FILE) = shift;
# Headers
print FILE "\n";
print FILE '', "\n";
print FILE "\n";
print FILE " ";
print OUTPUT "
\n";
print OUTPUT "
\n";
print OUTPUT "
\n";
print OUTPUT " \n$title\n";
print OUTPUT "
Screenshot
\n";
print OUTPUT " \n";
print OUTPUT "
Hierarchy
\n";
&generate_tree_for_widgets (\@widgets, 0, *OUTPUT);
print OUTPUT " Interfaces
\n";
print OUTPUT " \n";
foreach (@interfaces) {
my ($name) = $_;
my ($short) = $name;
$short =~ s/^.*?\.([^.]+)$/$1/;
my ($f) = $files_from_widget{$short};
if (defined $f) {
print OUTPUT "
\n";
print OUTPUT " Implemented by
\n";
print OUTPUT " \n";
foreach (@{$implemented{$has_interface}}) {
print OUTPUT "
\n";
print OUTPUT " See Also
\n";
print OUTPUT " \n";
foreach $w (split ("\n", $tags{'see'})) {
my ($file) = $files_from_package{$w};
if (defined $file) {
print OUTPUT "
\n";
print OUTPUT " \n";
print OUTPUT "
\n\n";
## First notebook page
print OUTPUT " Description
\n";
print OUTPUT &process_comment ($tags{'description'}, $package);
print OUTPUT " Types
\n";
print OUTPUT " \n";
foreach (sort keys %types) {
my ($name, $def, $comment) = ($_, $types{$_}->[0], $types{$_}->[1]);
$def =~ s/</g; ## Think of "type A (<>) is ..."
$def =~ s/>/>/g;
print OUTPUT "
\n";
print OUTPUT " Subprograms
\n";
print OUTPUT " \n";
my (%names);
my ($current_section) = "General";
$count = 1;
foreach $w (@subprograms) {
my ($section, $description, $comment) = ($w->[0], $w->[1], $w->[2]);
if ($section ne $current_section) {
$current_section = $section;
$section =~ s/[ \t]/_/g;
print OUTPUT " \n";
print OUTPUT "
\n";
print OUTPUT " $current_section
\n";
foreach (@sections) {
my ($name, $comment) = ($_->[0], $_->[1]);
if ($name eq $current_section) {
print OUTPUT " Signals
\n";
my (%signals) = &parse_signals ($tags{'signals'});
print OUTPUT " \n";
foreach (sort keys %signals) {
my ($name, $profile, $comment) = ($_, $signals{$_}->[0], $signals{$_}->[1]);
print OUTPUT "
$properties_sections{$proptype}
\n";
my (%props) = &parse_properties ($tags{$proptype});
print OUTPUT " \n";
foreach (sort keys %props) {
my ($name, $type, $descr, $see) = ($_, $props{$_}->[0],
$props{$_}->[1],
$props{$_}->[2],
$props{$_}->[3]);
print OUTPUT "
\n";
print OUTPUT "
See: " . &process_comment ($see, $package) : ""),
"Example
";
my ($example) = $tags{'example'};
if (($example =~ /Testgtk source code
";
print OUTPUT "Alphabetical Index
\n";
print OUTPUT " \n";
foreach $w (sort keys %names) {
print OUTPUT "
\n";
print OUTPUT " Index
\n";
print OUTPUT "\n";
print OUTPUT "
\n";
print OUTPUT "operators \n";
for ($first = ord ('a'); $first <= ord ('z'); $first++) {
print OUTPUT " \n" if (($first - ord ('a')) % 3 == 0);
print OUTPUT " \n" if (($first - ord ('a')) % 3 == 2);
}
print OUTPUT "", uc (chr ($first)), " \n";
print OUTPUT "