#!/usr/bin/perl use strict; sub definitions { my $file = shift; my (@functions, @classes); open FP, "<$file" or die "Cannot open `$file': $!\n"; while () { chomp; push @functions, "$_" if m/^function/; push @classes, "$_" if m/Class{/; } close FP; return (functions => \@functions, classes => \@classes); } my @html = (); my $header = < HardonCollider - A collision detection library EOHEADER push @html, $header; my $html_chunk; for (@ARGV) { my $fn = $_; my %info = definitions($fn); my $module = substr($fn,0, length($fn)-4); $html_chunk = <
hardoncollider.$module^ top
Description here

Module overview

EOCHUNK push @html, $html_chunk; for (@{$info{classes}}) { my ($name, $arglist); if (m/(\S+).+function\(self,\s+([^\)]*)\)/) { ($name, $arglist) = ($1,$2); } my @arguments = split /,\s*/, $arglist; $html_chunk = <class$name()
Short description
EOCHUNK push @html, $html_chunk; } for (@{$info{functions}}) { my ($name, $arglist); if (m/^function\s+(\S+)\(([^\)]*)\)$/) { ($name, $arglist) = ($1, $2); } $html_chunk = <function $name()
Short description
EOCHUNK push @html, $html_chunk; } $html_chunk = <
EOCHUNK push @html, $html_chunk; for (@{$info{classes}}) { my ($name, $arglist); if (m/(\S+).+function\(self,\s+([^\)]*)\)/) { ($name, $arglist) = ($1,$2); } my @arguments = split /,\s*/, $arglist; $html_chunk = <
$name($arglist)^ top

Description here

Parameters:
EOCHUNK push @html, $html_chunk; for my $arg (@arguments) { $html_chunk = <[type] $arg
Description here
EOCHUNK push @html, $html_chunk; } $html_chunk = <
Returns:
[type]
Description here
Example:

				Example code
			
EOCHUNK push @html, $html_chunk; } for (@{$info{functions}}) { my ($name, $arglist); if (m/^function\s+(\S+)\(([^\)]*)\)$/) { ($name, $arglist) = ($1, $2); } my @arguments = split /,\s*/, $arglist; $html_chunk = <
function $name($arglist)^ top

Description here

Parameters:
EOCHUNK push @html, $html_chunk; for my $arg (@arguments) { $html_chunk = <[type] $arg
Description here
EOCHUNK push @html, $html_chunk; } $html_chunk = <
Returns:
[type]
Description here
Example:

				Example code
			
EOCHUNK push @html, $html_chunk; } push @html, "
\n"; } push @html, "\n"; print join "", @html;