comp.lang.ada
 help / color / mirror / Atom feed
* WWW browser for GNAT libraries
@ 1995-04-21  0:00 Simon Johnston
  0 siblings, 0 replies; only message in thread
From: Simon Johnston @ 1995-04-21  0:00 UTC (permalink / raw)


Hi, included in this mail is a Perl package 'alibdoc' which can be used to 
produce a WWW view of the GNAT library. comments are included, you need to 
create a script to call the two functions which will throw out on stdout an 
HTML file which uses the Unnumbered List construct to build a tree view of the 
library hierarchy. Each list element is a URL to the .ads file. This works 
fine for both OS/2 and Windows-NT, though there may be a some 'PC-isms' I 
haven't spotted.
I am working on a script to break down the package specs themselves and 
produce a completely HTML overview, this may take some time.

----Start of alibdoc.pl
package alibdoc;

%packages = ();

sub main'extract_packages {
# Using the standard environment look for all files like *.ads
# and check them for Ada packages.
# The global dictionary packages associates the package file
# name with the package. This does nothing more than compile
# the list of packages available.

    foreach $dir (split(/;/, $ENV{"ADA_INCLUDE_PATH"})) {

	chdir($dir);
    
	foreach $afile (split(/\s+/, `ls *.ads`)) {
	    
	    open(FH, "<$afile") || die "cannot open $afile";
	    
	    while (<FH>) {
		
		if (/^package\s+(\S+)\s+is/) {
		    
		    $packages{$1} = $afile;
		    end;
		}
	    }
	    close(FH);
	}
    }
}

sub main'print_package_hier {
# This uses the list of packages in the global variable to
# print a structures tree view of the Ada95 standard library.
# The function extract_packages must have been called first
# to ensure the state of the global dictionary.

    $depth = 0;
    $dir   = $ENV{"ADA_INCLUDE_PATH"};

    # Print the HTML header block.
    print  "<HTML>\n";
    print  "<HEAD>\n";
    print  "<TITLE>GNAT Package Hierarchy in dir</TITLE>\n";

    print  "<BODY>\n";
    print  "<H1>GNAT Packages:</H1>\n";
    print  "<UL>\n";

    # now change the directory if it looks like a PC one.
    if ($dir =~ /([a-zA-Z]):(\S+)/) {

	$dir = "/$1|$2";
    }

    # If the packages are sorted first then the job is so much easier.
    foreach $package (sort(keys %packages)) {

	$dots = ($package =~ tr/././);
	if ($dots > $depth) {

	    print  "<UL>\n";
	    $depth = $dots;
	}
	if ($dots < $depth) {

	    while ($depth > $dots) {

		print  "</UL>\n";
		$depth--;
	    }
	}
	@splitname = split(/\./, $package);

	# Print only the package name itself, as a URL pointing
	# to the file containing it.
	print  "<LI><A REF=\"file://$dir/$packages{$package}\">"
        print  "$pad$splitname[$#splitname]</A>\n";
    }
    while ($depth >= 0) {

	print  "</UL>\n";
	$depth--;
    }    

    # HTML trailer stuff.
    print  "<HR>\n";
    print  "This list produced automatically by the perl"
    print  " script alibdoc.<BR>\n";
    print  "<ADDRESS>\n";
    print  "&copy 1995 Simon Johnston, <I>Team</I>Ada.<BR>\n";
    print  "<A HREF=\"mailto:skj@rb.icl.co.uk\">skj@rb.icl.co.uk</A>\n";
    print  "</ADDRESS>\n";

    print  "</BODY>\n";
    print  "</HTML>\n";
}

1;

with StandardDisclaimer; use StandardDisclaimer;
package body Sig is
begin
--,--------------------------------------------------------------------------.
--|Simon K. Johnston - Development Engineer (C/C++)      |ICL Retail Systems |
--|------------------------------------------------------|3/4 Willoughby Road|
--|Unix Mail : S.K.Johnston@bra0801.wins.icl.co.uk       |Bracknell, Berks   |
--|Telephone : +44 (0)344 476320   Fax: +44 (0)344 476302|United Kingdom     |
--|Internal  : 7261 6320    OP Mail: S.K.Johnston@BRA0801|RG12 8TJ           |
--`--------------------------------------------------------------------------'
end Sig;




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-04-21  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-04-21  0:00 WWW browser for GNAT libraries Simon Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox