Files
MiniGUI/doc/man3/docmaker
2017-05-29 12:20:05 +08:00

85 lines
3.0 KiB
Perl
Executable File

#! /usr/bin/perl -w
use POSIX;
if ($#ARGV < 0) {
print "Usage: ./docmaker functions.txt\n";
exit -1;
}
open FUNCHANDLE, "<$ARGV[0]" || die;
$i = 0;
while (<FUNCHANDLE>) {
next if /^\n/;
chop;
if (/^(\D.+?) \\-.+$/){
$docfile = "minigui$1.3";
open DOC, ">$docfile" || die;
print DOC ".\\\" This manpage is Copyright (C) 2000, 2001 Wei Yongming\n";
print DOC ".\\\" 2000, 2001 BluePoint Software\n";
print DOC ".\\\"\n";
print DOC ".\\\" Permission is granted to make and distribute verbatim copies of this\n";
print DOC ".\\\" manual provided the copyright notice and this permission notice are\n";
print DOC ".\\\" preserved on all copies.\n";
print DOC ".\\\"\n";
print DOC ".\\\" Permission is granted to copy and distribute modified versions of this\n";
print DOC ".\\\" manual under the conditions for verbatim copying, provided that the\n";
print DOC ".\\\" entire resulting derived work is distributed under the terms of a\n";
print DOC ".\\\" permission notice identical to this one.\n";
print DOC ".\\\"\n";
print DOC ".\\\" Since MiniGUI is constantly changing, this\n";
print DOC ".\\\" manual page may be incorrect or out-of-date. The author(s) assume no\n";
print DOC ".\\\" responsibility for errors or omissions, or for damages resulting from\n";
print DOC ".\\\" the use of the information contained herein. The author(s) may not\n";
print DOC ".\\\" have taken the same level of care in the production of this manual,\n";
print DOC ".\\\" which is licensed free of charge, as they might when working\n";
print DOC ".\\\" professionally.\n";
print DOC ".\\\"\n";
print DOC ".\\\" Formatted or processed versions of this manual, if unaccompanied by\n";
print DOC ".\\\" the source, must acknowledge the copyright and authors of this work.\n";
print DOC ".TH \"$1\" ";
print DOC "\"3\" \"August 2000\" \"MiniGUI\"\n\n";
print DOC ".SH \"NAME\"\n";
print DOC "$_\n\n";
print DOC ".SH \"SYNOPSIS\"\n";
}
elsif (/^#.+?/){
print DOC ".B $_\n";
print DOC ".br\n";
}
else{
$funcname[$i++]=$_;
}
}
print DOC "\n.PP\n";
for ($j = 0; $j < $i; $j++){
$funcname[$j] =~ /(.+?) *(\(.+?\);)/;
$funcname[$j] = $1;
print DOC ".BI \"$1\" \"$2\"\n";
print DOC ".br\n" if ($j != $i - 1);
}
print DOC ".SH \"DESCRIPTION\"\n";
print DOC ".PP\n";
for ($j = 0; $j < $i; $j++){
$funcname[$j] =~ /.+ (.+?)$/;
print DOC "\\fB$1\\fP function description goes here\n";
print DOC ".PP\n" if ($j != $i - 1);
# open FUNCDOC, ">$1.3" || die;
# print FUNCDOC ".so man3/$docfile\n";
# close FUNCDOC;
}
print DOC ".SH \"RETURN VALUE\"\n";
print DOC ".PP\n\n";
print DOC ".SH \"NOTE\"\n";
print DOC ".PP\n\n";
print DOC ".SH \"SEE ALSO\"\n\n";
print DOC ".SH \"AUTHOR\"\n";
print DOC ".PP\n";
print DOC "This manual page was edited by <yourname> <yourid\@minigui.org>.\n";
print DOC "If you have any problems, comments or found some bugs, please send messages to me.\n";
close FUNCHANDLE;
close DOC;