[prev in list] [next in list] [prev in thread] [next in thread]
List: midgard-dev
Subject: [midgard-cvs] cvs: midgard /doc/mgddoc14 man.pl man.sh
From: cmusso <cvslog () midgard-project ! org>
Date: 2000-10-31 15:24:25
[Download RAW message or body]
cmusso Tue Oct 31 16:24:25 2000 EDT
Added files:
/midgard/doc/mgddoc14 man.pl man.sh
Log:
added (dirty) man pages generation : run man.sh
Index: midgard/doc/mgddoc14/man.pl
+++ midgard/doc/mgddoc14/man.pl
#!/usr/bin/perl -w
###########################################################
# man.pl #
# docbook (sgml) refentries -> man pages #
# WARNING this only works for very specific docbook files #
###########################################################
use strict;
foreach (@ARGV)
{
my $fichier_entree = $_ ;
my $fichier_sortie = $fichier_entree ;
$fichier_sortie =~ s/.*mgd(.*)\.sgml/.\/man\/mgd$1.1/ ;
refentry2man($fichier_entree, $fichier_sortie) ;
}
#####################################################
# refentry2man #
# Converts one sgml refentry into a man page #
# 2 arguments : docbook (sglm) refentry source file #
# man page resulting file #
#####################################################
sub refentry2man
{
# man 7 man for more information on this
my $header = ".TH " ;
my $section = ".SH " ;
# control variable used throughout the whole function
my $etat = "" ;
# man page header and footer
my $nom_fonction = "" ; # function name
my $num_volume = "" ; # man pages volume number
my $titre = "Midgard" ; # manual title for the man page
# man page NAME section
my $whatis = "" ;
# man page SYNOPSIS section
# we have two synopsises for some functions
# OK this is ugly...
my $valeur_retour1 = "";
my $valeur_retour2 = "";
my @types1 = () ;
my @types2 = () ;
my @parametres1 = () ;
my @parametres2 = () ;
my $count_param_prototype1 = 0 ;
my $count_param_prototype2 = 0 ;
my $nsynopsis = 1 ; # =2 for the 2nd synopsis
# man page DESCRIPTION section
my @paragraphe= () ;
my $count_param_paragraphe = 0 ;
# man page EXAMPLE section
my @exemple = () ;
my $count_param_exemple = 0 ;
# man page SEE ALSO section
my @seealso = () ;
my $count_param_seealso = 0 ;
open( ENTREE, $_[0] ) || die "cannot open $_[0]" ;
open( SORTIE, ">$_[1]" ) || die "cannot open $_[1]" ;
while ( <ENTREE> )
{
s/>/>/ ;
if ( /<refentrytitle>/ )
{
chomp ;
s/ *<refentrytitle>(.*)<\/refentrytitle>.*/$1/ ;
$nom_fonction = $_ ;
}
elsif ( /<manvolnum>/ )
{
chomp ;
s/ *<manvolnum>(.*)<\/manvolnum>.*/$1/ ;
$num_volume = $_ ;
}
elsif ( /<refpurpose>/ )
{
chomp ;
s/ *<refpurpose>(.*)<\/refpurpose>.*/$1/ ;
$whatis = $_ ;
}
elsif ( /<funcprototype>/ )
{
if ( $nsynopsis == 1 )
{
$etat = "prototype1" ;
$nsynopsis++ ;
}
elsif ( $nsynopsis == 2 )
{
$etat = "prototype2" ;
$nsynopsis++ ;
}
else
{
die "two many function prototypes" ;
}
}
elsif ( /<\/funcprototype>/ )
{
$etat = "" ;
}
elsif ( /<title>Description/i )
{
$etat = "description" ;
}
elsif ( /<\/refsect1>/ )
{
$etat = "" ;
}
elsif ( /<programlisting>/ )
{
$etat = "example" ;
}
elsif ( /<\/programlisting>/ )
{
$etat = "" ;
}
elsif ( /<title>see also/i )
{
$etat = "seealso" ;
}
elsif ( $etat eq "prototype1" )
{
if ( /<funcdef>/ )
{
chomp ;
s/ *<funcdef>(.*)<function>.*/$1/ ;
$valeur_retour1 = $_ ;
}
elsif ( /<paramdef>/ )
{
chomp ;
s/<optional>/[ / ;
s/<\/optional>/ ] / ;
$types1[$count_param_prototype1] = $parametres1[$count_param_prototype1] = $_ ;
$types1[$count_param_prototype1] =~ s/ *<paramdef>(.*)<parameter>.*/$1/ ;
$parametres1[$count_param_prototype1] =~ s/.*<parameter>(.*)<\/parameter>(.*)<\/paramdef>/$1$2/ ;
$count_param_prototype1++ ;
}
}
elsif ( $etat eq "prototype2" )
{
if ( /<funcdef>/ )
{
chomp ;
s/ *<funcdef>(.*)<function>.*/$1/ ;
$valeur_retour2 = $_ ;
}
elsif ( /<paramdef>/ )
{
chomp ;
s/<optional>/[ / ;
s/<\/optional>/ ] / ;
$types2[$count_param_prototype2] = $parametres2[$count_param_prototype2] = $_ ;
$types2[$count_param_prototype2] =~ s/ *<paramdef>(.*)<parameter>.*/$1/ ;
$parametres2[$count_param_prototype2] =~ s/.*<parameter>(.*)<\/parameter>(.*)<\/paramdef>/$1$2/ ;
$count_param_prototype2++ ;
}
}
elsif ( $etat eq "description" )
{
if ( /<para>/ )
{
$paragraphe[$count_param_paragraphe++] = ".PP\n" ;
}
chomp ;
s/ *// ;
s/<para>// ;
s/<\/.*>// ;
s/<.*>// ;
s/<\/para>// ;
$paragraphe[$count_param_paragraphe++] = $_ ;
}
elsif ( $etat eq "example" )
{
if ( /<!\[CDATA\[/ )
{
$exemple[$count_param_exemple++] = ".nf\n" ;
}
elsif ( /]]>/ )
{
$exemple[$count_param_exemple++] = ".fi\n" ;
}
else
{
s/\\\$/\\\\\$/ ;
s/\\n/\\\\n/ ;
$exemple[$count_param_exemple++] = $_ ;
}
}
elsif ( $etat eq "seealso" )
{
chomp ;
s/ *// ;
s/<\/.*>// ;
s/<.*>// ;
$seealso[$count_param_seealso++] = $_ ;
}
}
# print the man page
select SORTIE ;
# header
print( $header, "\"$nom_fonction\" ", "\"$num_volume\" ", "\"\" ", "\"\" ", "\"$titre\"\n\n") ;
# name section
print("$section\"NAME\"\n") ;
print("$nom_fonction \\- $whatis\n\n") ;
# synopsis
print("$section\"SYNOPSIS\"\n") ;
print(".PP\n$valeur_retour1" . " $nom_fonction(") ;
my $i = 0 ;
for ($i=0; $i < $count_param_prototype1 - 1 ; $i++)
{
print( " $types1[$i]", "$parametres1[$i],") ;
}
print(" $types1[$count_param_prototype1 - 1]", "$parametres1[$count_param_prototype1 - 1]") ;
# print(" ) ;") ;
if ( $nsynopsis == 3 )
{
print("\n.PP\n$valeur_retour2" . " $nom_fonction(") ;
$i = 0 ;
for ($i=0; $i < $count_param_prototype2 - 1 ; $i++)
{
print( " $types2[$i]", "$parametres2[$i],") ;
}
print(" $types2[$count_param_prototype2 - 1]", "$parametres2[$count_param_prototype2 - 1]") ;
}
print(" ) ;\n\n") ;
# description
print("$section\"DESCRIPTION\"\n") ;
foreach( @paragraphe )
{
print "$_\n" ;
}
# example
print("$section\"EXAMPLE\"\n") ;
foreach( @exemple )
{
print ;
}
# see also section
unless ( $count_param_seealso == 0 )
{
print("$section\"SEE ALSO\"\n") ;
foreach( @seealso )
{
print "$_\n" ;
}
}
}
Index: midgard/doc/mgddoc14/man.sh
+++ midgard/doc/mgddoc14/man.sh
rm -f ./man/*
./man.pl functions/*/*.sgml 2>/dev/null
cd man
rm mgd_intro*
rm mgd_record*
rm mgd_object*
rm mgd_functions_parameter*
gzip *
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@midgard-project.org
For additional commands, e-mail: cvs-help@midgard-project.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic