use strict; use POSIX qw(strftime); sub plugin { my $global=shift; print "Generation class documentation\n"; print_class_index($global); print_classes($global); print "Done with classes\n"; } sub print_classes { my $space=shift; foreach (sort byfullname $space->all()) { next if (!$_->is_class()); print_class($_); } } my %see_also; # Remember to set $new_line_flag = 0 before using this function my $new_line_flag = 0; my @classes; sub print_description { my $mydesc=shift; foreach (@classes) { my $item = $_; my $name = $$item{fullname}; # Find comment cross reference my $mylink=$item->href($$item{fullname}); $mydesc=~s/([. ,()])${name}([. ,()])/${1}${mylink}${2}/g; $mydesc=~s/([. ,()])${name}$/${1}${mylink}/g; $mydesc=~s/^${name}([. ,()])/${mylink}${1}/g; } # Check if new lines are required if ($mydesc=~/<p>/) { $new_line_flag = 1; $mydesc=~s/<p>//g; } if ($mydesc=~/<\/p>/) { $new_line_flag = 0; $mydesc=~s/<\/p>//g; } $mydesc = &addCrossRef($mydesc); if ($new_line_flag eq 0) { print FILE "$mydesc
"; }else { print FILE "$mydesc"; } } sub addCrossRef { my $text = shift; # my @sortedClasses = sort { $$b{fullname} cmp $$a{fullname} } @classes; foreach (@classes) { my $name = $$_{fullname}; my $loc = $name . ".html"; # $text =~ s/${name}/$name<\/a>/g; if ($text =~ /${name}/) { $see_also{$name} = "$name<\/a>"; } } return $text; } sub print_html_header { my $html_name=shift; my $index_number=shift; my $colour=shift; print FILE ' ', $html_name, ' - ClanLib Game SDK

Home | All Classes | Grouped Classes | Index | Search

'; # if ($index_number eq 1) # { # print FILE "Entire Class Index\n"; # }else # { # print FILE "Entire Class Index\n"; # } # # if ($index_number eq 2) # { # print FILE "Main Class Index\n"; # }else # { # print FILE "Main Class Index\n"; # } # #: if ($index_number eq 3) # { # print FILE "Cross Index\n"; # }else # { # print FILE "Cross Index\n"; # } # # if ($index_number eq 4) # { # print FILE "Global Index\n"; # }else # { # print FILE "Global Index\n"; # } # print FILE ""; } sub print_html_footer { print FILE '


Questions or comments, write to the ClanLib mailing list.
'; } my $last_group; my $last_section; my $file_open_flag; sub print_class_index { my $space=shift; my $clan_group; my $clan_section; my $id; my %hash; my %classname_hash; my $time_string = strftime "%e %b %Y", gmtime; my @alpha_classes; # Get the class in order of Group / Section / Name $id = 0; foreach (all $space) { if ($_->is_class()) { my $cname = $_->name; $clan_group = ""; $clan_section = ""; foreach (split("\n",$$_{unique_string})) { /^!.(.*)$/; my $workbuffer; $workbuffer=$1; if (substr($workbuffer,0,4) eq "clan") { $workbuffer = substr($workbuffer,4); ($clan_group, $clan_section)=split(/=/, $workbuffer); $clan_section=~s/\"//g; } } my $name = "$clan_group=$clan_section=$cname=$id\n"; $hash{$name}=[] if (!$hash{$name}); my $classname = "$cname=$clan_group=$clan_section=$id\n"; $classname_hash{$classname}=[] if (!$classname_hash{$classname}); } $id = $id + 1; } my @entire_list = $space->all(); foreach (sort keys %hash) { my $cname; ($clan_group, $clan_section, $cname, $id) = split(/=/, $_); if ($cname =~ /^CL_/) { push(@classes, $entire_list[$id]); } } my $num_alpha = 0; foreach (sort keys %classname_hash) { my $cname; ($cname, $clan_group, $clan_section, $id) = split(/=/, $_); if ($cname =~ /^CL_/) { push(@alpha_classes, $entire_list[$id]); $num_alpha = $num_alpha + 1; } } open(FILE,">html/classes.html"); print_html_header("All Classes", 1, "green"); print FILE "

All Classes

\n"; print FILE "\n"; print FILE "\n\n\n"; print FILE "

\n"; my $last_letter=""; my $next_tr = int ($num_alpha/3-5); foreach (@alpha_classes) { my $cname = $_->name; $cname =~ /CL_(.)/; my $letter = $1; if ($last_letter ne $letter) { if ($next_tr < 3) { print FILE "

\n"; $next_tr = int ($num_alpha/3-5); } if ($next_tr < int ($num_alpha/3-5)) { print FILE "
"; $next_tr = $next_tr - 1; } print FILE "$letter
\n"; $last_letter = $letter; $next_tr = $next_tr - 1; } print FILE "$$_{name}
\n"; $next_tr = $next_tr - 1; if ($next_tr == 0) { print FILE "

\n"; $next_tr = int ($num_alpha/3-5); } } print FILE "

\n"; print_html_footer(); close(FILE); open(FILE,">html/modules.html"); print_html_header("Grouped Classes", 1, "green"); print FILE "

Grouped Classes

\n"; print FILE "\n"; print FILE "\n\n\n\n"; print FILE "

\n"; my $last_group=""; my $last_section=""; my %func_hash; my %empty; my $next_tr = int ($num_alpha/2)-22; foreach (@classes) { my $cname = $_->name; $clan_group = ""; $clan_section = ""; foreach (split("\n",$$_{unique_string})) { /^!.(.*)$/; my $workbuffer; $workbuffer=$1; if (substr($workbuffer,0,4) eq "clan") { $workbuffer = substr($workbuffer,4); ($clan_group, $clan_section)=split(/=/, $workbuffer); $clan_section=~s/\"//g; } } if ($last_group ne $clan_group || $last_section ne $clan_section) { my $key; foreach $key (sort keys %func_hash) { print FILE $func_hash{$key}; $next_tr = $next_tr - 1; if ($next_tr <= 0) { print FILE "

\n"; $next_tr = int ($num_alpha/2)-22; } } %func_hash = %empty; if ($next_tr < 3) { print FILE "

\n"; $next_tr = int ($num_alpha/2)-22; } if ($next_tr < int ($num_alpha/2-22)) { print FILE "
"; $next_tr = $next_tr - 1; } if ($last_group ne $clan_group) { print FILE "$clan_group
\n"; $next_tr = $next_tr - 1; } print FILE "$clan_section
\n"; $next_tr = $next_tr - 1; $last_group = $clan_group; $last_section = $clan_section; } $func_hash{$$_{name}} = "$$_{name}
\n"; } my $key; foreach $key (sort keys %func_hash) { print FILE $func_hash{$key}; $next_tr = $next_tr - 1; if ($next_tr <= 0) { print FILE "

\n"; $next_tr = int ($num_alpha/2)-22; } } %func_hash = %empty; print FILE "

\n"; print_html_footer(); close(FILE); # Print index: my %index; foreach (sort byfullname $space->all()) { next if (!$_->is_class()); my $dfilename = $$_{fullname}; $dfilename=~s/::/__/g; $index{$$_{fullname}} .= "
$$_{fullname}
\n"; if ($_->functions()) { my $access; foreach $access ($Enum::PUBLIC, $Enum::PROTECTED, $Enum::PRIVATE) { foreach ($_->get_by_access($access)) { next if ($$_{name} =~ /^~/); # no destructors please. # Replace :: with __ for filenames my $dummyfilename = $$_{fullname}; $dummyfilename=~s/::/__/g; my $func_ref = "
$$_{fullname}
\n"; $index{$$_{name}} .= $func_ref if ($_->is_function()); # $index{$$_{name}} .= $func_ref if ($_->is_function() && !($index{$$_{name}} =~ /$func_ref/)); } } } } open(FILE,">html/index.html"); print_html_header("Index", 1, "green"); print FILE "

Index

\n"; my $key; foreach $key (sort keys %index) { print FILE "

$key
\n$index{$key}

\n"; } print_html_footer(); close(FILE); open(FILE,">html/search.html"); print_html_header("Search", 1, "green"); print FILE "

Search

\n"; print FILE "\n"; print FILE "\n"; print FILE "
\n"; print FILE "\n"; print FILE "\n"; print FILE "
\n"; print FILE "\n"; print FILE "\n"; print FILE "\n"; print FILE "\n"; print FILE "
\n"; print FILE "
\n"; print_html_footer(); close(FILE); # open(FILE,">html/entire_class_index.html"); # print_html_header("Entire Class Index", 1, "green"); # print FILE "

Entire Class Index

\nDocumentation Created : $time_string\n"; # print_html_footer(); # close(FILE); # # open(FILE,">html/class_index.html"); # print_html_header("Main Index", 2, "orange"); # print FILE "

Main Index

\nDocumentation Created : $time_string\n"; # print_html_footer(); # close(FILE); # # $last_group="E R R O R"; # $last_section="E R R O R"; # $file_open_flag = 0; # foreach (@classes) { # print_class_section_index($_); # } # # # Close the old file # if ($file_open_flag ne 0) # { # $file_open_flag = 0; # print_html_footer(); # close(FILE); # } } sub print_class_section_index { my $item=shift; my $clan_group=""; my $clan_section=""; my $workbuffer; foreach (split("\n",$$_{unique_string})) { /^!.(.*)$/; $workbuffer=$1; if (substr($workbuffer,0,4) eq "clan") { $workbuffer = substr($workbuffer,4); ($clan_group, $clan_section)=split(/=/, $workbuffer); $clan_section=~s/\"//g; } } # Start of a new group if ($clan_group ne $last_group) { # Close the old file if ($file_open_flag ne 0) { $file_open_flag = 0; print_html_footer(); close(FILE); } # Open a new file open(FILE,">html/${clan_group}_index.html"); print_html_header("$clan_group Index", 0, "orange"); print FILE "

$clan_group Index

\n