From e45bc20064dd8d224f49a02aec2558129977551b Mon Sep 17 00:00:00 2001 From: handa Date: Thu, 19 Jun 2003 13:11:43 +0000 Subject: [PATCH] *** empty log message *** --- configure.ac | 6 +- doxyfile.in | 12 +- sample.c | 26 +++ utils/mkheaderlist.rb | 32 ++++ utils/mkman.rb | 419 +++++++++++++++++++++++++++++++++++++++++++++++++ utils/run-latex.sh | 4 +- 6 files changed, 488 insertions(+), 11 deletions(-) create mode 100644 sample.c create mode 100755 utils/mkheaderlist.rb create mode 100644 utils/mkman.rb diff --git a/configure.ac b/configure.ac index ecdf639..462d7d0 100644 --- a/configure.ac +++ b/configure.ac @@ -25,13 +25,13 @@ fi AC_SUBST(M17NLIB) -AC_CHECK_PROG(DOXYGEN, doxygen, yes, no) +AC_CHECK_PROG(HAVEDOXYGEN, doxygen, yes, no) AC_CHECK_PROG(RUBY, ruby, yes, no) AC_CHECK_PROG(LATEX, platex, yes, no) AC_CHECK_PROG(PLATEX, platex, yes, no) OK=yes -if test "$DOXYGEN" = "no"; then +if test "$HAVEDOXYGEN" = "no"; then echo "Can't find a program \"doxygen\"!" OK=no fi @@ -47,7 +47,7 @@ if test "$PLATEX" = "no"; then echo "Can't find a program \"platex\"!" OK=no fi -if test "$OK" = "no; then +if test "$OK" = "no"; then exit 1 fi diff --git a/doxyfile.in b/doxyfile.in index 82536bf..769c7c0 100644 --- a/doxyfile.in +++ b/doxyfile.in @@ -30,7 +30,7 @@ PROJECT_NUMBER = @PACKAGE_VERSION@ # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = %USR_JA_DEV_MAN% +OUTPUT_DIRECTORY = %USR_JA_DEV% # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this @@ -334,7 +334,7 @@ EXCLUDE = # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = font-flt.c font-ft.c link*.c # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see @@ -520,7 +520,7 @@ EXTRA_PACKAGES = # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = @abs_srcdir@/header.tex +LATEX_HEADER = header.tex # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will @@ -597,7 +597,7 @@ GENERATE_MAN = %GENERATE_MAN% # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. -MAN_OUTPUT = ../tmp +MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) @@ -806,13 +806,13 @@ CGI_URL = http://mule.m17n.org/cgi-bin # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. -DOC_URL = http://mule.m17n.org/m17n-lib/%USR_JA_DEV_MAN%/html/ +DOC_URL = http://mule.m17n.org/m17n-lib/%USR_JA_DEV%/html/ # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. -DOC_ABSPATH = @abs_srcdir@/%USR_JA_DEV_MAN%/html +DOC_ABSPATH = @abs_srcdir@/%USR_JA_DEV%/html # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. diff --git a/sample.c b/sample.c new file mode 100644 index 0000000..cce23bc --- /dev/null +++ b/sample.c @@ -0,0 +1,26 @@ +/** @addtogroup SampleGroup + @brief + + long group document + @{ + */ + +/** @brief + + long structure document */ + +typedef struct + +{ +/** SampleFiledDocument */ + void SampleField; +} SampleStructure; + +/** @brief + + long function document */ + +int +SampleFunction () {} + +/** @} */ diff --git a/utils/mkheaderlist.rb b/utils/mkheaderlist.rb new file mode 100755 index 0000000..b00d46a --- /dev/null +++ b/utils/mkheaderlist.rb @@ -0,0 +1,32 @@ +#! /usr/bin/ruby + +def nextheader(text,index) + header = text[index+1..text.size].find{|i| i =~ /\.S(S|H)/} + return header + end + +grouptext = open("SampleGroup.3","r").readlines.reverse + +fd = grouptext.index(grouptext.find{|i| i =~ /SampleFunction/}) +fdheader = nextheader(grouptext,fd) + +restofthetext = grouptext[fd+1..grouptext.size] + +fl = restofthetext.index(restofthetext.find{|i| i =~ /SampleFunction/}) +flheader = nextheader(restofthetext,fl) + +dd = grouptext.index(grouptext.find{|i| i =~ /long group document/}) +ddheader = nextheader(grouptext,dd) + +#### +structext = open("SampleStructure.3","r").readlines.reverse + +fieldd = structext.index(structext.find{|i| i =~ /SampleField/}) +fielddheader = nextheader(structext,fieldd) + +restofstructext = structext[fieldd+1..structext.size] + +fieldl = restofstructext.index(restofstructext.find{|i| i =~ /SampleField/}) +fieldlheader = nextheader(restofstructext, fieldl) + +print fdheader, flheader, ddheader, fielddheader, fieldlheader diff --git a/utils/mkman.rb b/utils/mkman.rb new file mode 100644 index 0000000..43003af --- /dev/null +++ b/utils/mkman.rb @@ -0,0 +1,419 @@ +#! /usr/local/bin/ruby +#¼Â¹Ô¤¹¤ë¤È/tmp/doxyman¤ò¤Ä¤«¤Ã¤Æ¥Õ¥¡¥¤¥ë¤òʬ¤±¡¢ +#¤â¤È¤Îdirectory¤Ë¤«¤­¤Ê¤ª¤¹¡£ +# see also ¤ÎÃæ¿È¤ò woman ¸þ¤±¤Ë½ñ¤­´¹¤¨¤ë¡£ + +usr_dev_ja=$1 + +currentdir = Dir.pwd +doxywork = currentdir+"doxywork"+usr_dev_ja+"man3" +doxyman3 = currentdir+usr_dev_ja+"man/man3" +doxyman3m = currentdir+usr_dev_ja+"man/man3m" + +headertexts = open("doxyhead.txt","r").readlines + $fdheader = headertexts[0] + $flheader = headertexts[1] + $ddheader = headertexts[2] + $fielddheader = headertexts[3] + $fieldlheader = headertexts[4] + +#### to find data structure documentation files and rewriting them + +def writeuntilsectionheader(buf, text, index) + for line in text[index .. text.size] + if line =~ /^.S(H|S)/ + return + end + buf.push(line) + end + end + +def writedocumentation(buf, text, index) + for line in text[index .. text.size] + if line =~ /^.SH/ + return + end + if + line =~ /^.SS\s"(.+)"/ + buf.push(".PP\n\\fB".concat($1).concat("\\fP\n")) + else + buf.push(line) + end + end + end + + +def datastructure(struct) + + text = open(struct.concat(".3"),"r").readlines + + buf = [] + +# title + if tline = text.index("\.SH NAME\n") + if text[tline+1] =~ /^([\w\s]+)\s\\-\s(.+)$/ + buf.push(".SS ".concat($1).concat("\n")) + buf.push(".PP\n") + buf.push($2.concat("\n")) + nl = tline + 2 + writeuntilsectionheader(buf, text, nl) + else + if + text[tline+1] =~ /^([\w\s]+)\s\\-/ + buf.push(".SS ".concat($1).concat("\n")) + buf.push(".PP\n") + else + buf.push(text[tline+1]) + buf.push(".PP\n") + end + end + end + + if ddline = text.index(text.find{|i| i = $ddheader}) + nl = ddline + 1 + writeuntilsectionheader(buf, text, nl) + end + +# public types + if ptline = text.index("\.SS \"Public Types\"\n") + buf.push("\\fBPublic Types:\\fP\n") + nl = ptline + 1 + writeuntilsectionheader(buf, text, nl) + buf.push(".PP\n") + end + +# member enumeration documentation + if medline = text.index("\.SH \"MEMBER ENUMERATION DOCUMENTATION\"\n") + buf.push("\.PP\n\\fBMEMBER ENUMERATION DOCUMENTATION:\\fP\n") + nl = medline + 1 + writedocumentation(buf, text, nl) + end + +# data fields + if dfline = text.index($fieldlheader) + buf.push("\\fBData Fields:\\fP\n") + nl = dfline + 1 + writeuntilsectionheader(buf, text, nl) + buf.push(".PP\n") + end + +# field documentation + if fdline = text.index($fielddheader) + buf.push("\.PP\n\\fBFIELD DOCUMENTATION:\\fP\n") + nl = fdline + 1 + writedocumentation(buf, text, nl) + end + +return buf +end + +############################### +### ¥Õ¥¡¥¤¥ëʬ¤± + +def documentfunc(title, func_text, short_text) + func_text.grep(/^\.SS/){|i| + #¼«Ê¬¤è¤ê¸å¤í¤À¤± + func_rest = func_text[func_text.index(i)..func_text.size] + documentfunc2(i, title, func_rest, short_text)} +end + +def documentfunc2 (dstart, title, func_text, short_text) + #func_text¤ÎºÇ½é¤Î¹ÔÃæ¤Î´Ø¿ô̾ + dstart =~ /\s([a-z_]+)\s\(/ + return if $1 == nil + fname = $1 + ffname = "\\fB".concat($1.concat("\\fP")) + #short_text¤Î´Ø¿ô̾¤Î£²¹Ô¸å¤¬brief¡£ + brief = short_text[short_text.index(short_text.find{|i| i.index(ffname)}) + 2] + #´Ø¿ô¤´¤È¤Î¥Õ¥¡¥¤¥ë¤òºî¤ë¡£ + file = open(doxywork+fname+".3", "w") + file.puts("@function") + #¥Ø¥Ã¥À + /^\.TH \"([^"]*)\"\s/ =~ title + oname = $1 + newtitle = title.gsub(oname, fname.chop.chop) + file.puts(newtitle) + #@brief + file.print("@brief ") + if /^.RI/ =~ brief + file.puts(brief) + else file.print("\n") + end + #¥í¥ó¥° + file.puts(func_text[0]) + for line in func_text[1 .. func_text.size] + break if /.SS/ =~ line + file.puts(line) + end + file.flush + end + +####rewriting each man file +### rewriting a man file for a function + +def frewrite(text) +# let the library name appear in the header + buf = [text[0].gsub!("\" \"", "\" \"\" \"")] + + title = text[0].split(" ")[1].chop!.reverse.chop!.reverse + + if text.index("\\fBReturns: \\fP\n") == nil + print title, ": Returns not described\n" + end + if text.index("\\fBErrors: \\fP\n") == nil + print title, ": Errors not described\n" + end + + buf.push(".ad l\n.nh\n.SH NAME\n") +# if @brief is given + if text[1] =~ /\"\\fI(.+)\\fP\"/ + buf.push(title.concat(" \- ").concat($1)) + else buf.push(title) + end + + synopsys = text.find{|line| line =~ /\.SS/} + buf.push("\n\n.SH SYNOPSIS").push(formatsynopsys(synopsys)).push("\n") + + description = text[text.index(synopsys)+2..text.size] + if + description == [] + print title, ": No description found\n" + else + buf.push("\n.SH DESCRIPTION\n").push(womanrewrite(desrewrite(description))) + end + return buf +end + +####synopsys section of a function + +def formatsynopsys(line) + line.chop!.chop!.reverse!.chop!.chop!.chop!.chop!.chop!.reverse! + +# line.gsub!(/\\fP\s*/,"\n.ft\n") +# line.gsub!(/\\fB/,"\n.ft B\n") + + line.gsub!(/\s(\w*)\)/){"\n\\fI" << $1 << "\\fP)"} + line.gsub!(/\s(\w*),/){"\n\\fI" << $1 << "\\fP,"} + line.gsub!(/\s(\w*)\s\(/){"\n\\fB" << $1 << "\\fP ("} +end + +####non-synopsys section of a function + +def desrewrite(text) + +#removing identation + text.grep(/^\\fB.+\\fP/){|line| + ind = text.index(line) + text.delete_at(ind+1) if text[ind+1] == (".in +1c\n")} + + + text.each_with_index{|line,i| + +#removing "More..." hyperlink + line.gsub!(/More.../,"") +# ? ad hoc + line.gsub!(/^\.TP/,"") + +#headers + line.gsub!(/^\\fBReturn value:\\fP/,"\n.SH RETURNS\n.PP") + line.gsub!(/^\\fBSee Also:\\fP/,"\n.SH \"SEE ALSO\"\n.PP") + line.gsub!(/^\\fBErrors:\\fP/,"\n.SH ERRORS\n.PP") + + line.gsub!(/^\\fB(.+)\\fP/){"\n.SS " << $1} + +#removing indentation + if text[i - 1] =~ /^.PP/ + if line =~ /^\s./ + line.reverse!.chop!.reverse! + end + end + +# removing the results of doxygen bug +# \fP required for . , ; and <> + line.gsub!(/\s*(\\fP)+\s*(,|\.|;)\s+/){"\\fP" << $2 << "\n.ft R\n"} + + line.gsub!(/(\\fP)+\s*>/,"\\fP>") + line.gsub!(/<\s+\\f(P|I|B|C|)/){"<\\f" << $1} + + + line.gsub!(/\s*(\\fP)+\s+/,"\n.ft R\n") + + line.gsub!(/\s+\\f(I|C)\\fB\s*/,"\n.ft B\n") + line.gsub!(/\s+\\f(B|I)\\fC\s*/,"\n.ft C\n") + line.gsub!(/\s+\\f(B|C)\\fI\s*/,"\n.ft I\n") + line.gsub!(/\s+\\fB\s*/,"\n.ft B\n") + line.gsub!(/\s+\\fC\s*/,"\n.ft C\n") + line.gsub!(/\s+\\fI\s*/,"\n.ft I\n") + + } + +return text +end + +def womanrewrite(text) + + if sasectionstart = text.index(text.find{|line| line =~ /^\.SH\s"SEE ALSO"/}) + aftersasection = text[sasectionstart+1 .. text.size] + if sasectionend = aftersasection.index(aftersasection.find{|line| line =~ /^\.SH/}) + for line in text[sasectionstart+1 .. sasectionend + sasectionstart] + line.gsub!(/(\w*)\\fP\(\)/){ $1 << "(3)\\fP"} + end + else + for line in text[sasectionstart+1 .. text.size] + line.gsub!(/(\w*)\\fP\(\)/){ $1 << "(3)\\fP"} + end + end + end + return text +end + +# rewriting a man file for a non-function + +def orewrite(text) + buf = [] + structures = ["\.SH \"Data Structure Documentation\"\n"] + + if ddind = text.index($ddheader) + if odind = text.index(text.find{|line| line =~ /\.SH\s+.+\s+DOCUMENTATION/}) + unless + text[ddind+1 .. odind-1].find{|line| line =~ /^[^\.]/} + text = text[0 .. ddind-1] + text[odind .. text.size] + end end end + + text.each_with_index{|line,i| + line.gsub!(/More.../,"") + + # let the library name appear in the header + if line =~ /^.TH/ + line = line.gsub!("\" \"", "\" \"\" \"") + end + + # finding structure documentations and merging into "structures" + if line =~ /^\.RI\s\"struct\s\\fB(.*)\\fP\"/ + structures.push(datastructure($1)) + end + + #removing indentation + if text[i - 1] =~ /^.PP/ + if line =~ /^\s./ + line.reverse!.chop!.reverse! + end + end + + #removing extra "-" + if text[i - 1] =~ /^.SH\sNAME/ + if line =~ /\\-/ + unless line =~ /\\-\s./ + line.chop!.chop!.chop!.chop! + end + end + end + + #removing author section + line.gsub!(/^\.SH\s\"AUTHOR\"/,"") + line.gsub!("Generated automatically by Doxygen for m17n_test from the source code.","") + + line.gsub!(/\\fP\s+,/,"\\fP,") + line.gsub!(/\\fP\s+\./,"\\fP.") + line.gsub!(/\\fC\\fB(\w+)\\fP\\fP/){"\\fB" << $1 << "\\fP"} + + buf.push(line) + } + + unless structures == ["\.SH \"Data Structure Documentation\"\n"] + + if dindex = buf.index(buf.find{|line| line =~ /\.SH\s+.+\s+DOCUMENTATION/i}) + buf = buf[0 .. dindex-1] + structures + buf[dindex .. buf.size] + else + buf = buf + structures + end + end + + return buf +end + +#############################dividing files + +Dir.mkdir "doxywork/man3" unless FileTest.directory? "doxywork/man3" +Dir.mkdir "man" unless FileTest.directory? "man" +Dir.mkdir "man/man3m" unless FileTest.directory? "man/man3m" + +Dir.chdir("usr/man/man3") + +Dir.open(".").each{|filename| + if FileTest.directory? filename + next + end + + if filename =~ /\.c\./ + next + end + + file = open(filename,"r") + text = file.readlines + title = text[0] + + if + sfunctionstart = text.index(text.find{|i| i == $flheader}) + if sfunctionend = text.index(text[sfunctionstart+1 .. text.size].find{|i| i =~ /^\.SS|^\.SH/}) + short_text = text[sfunctionstart .. sfunctionend - 1] + else + short_text = text[sfunctionstart .. text.size - 1] + end + + if lfunctionstart = text.index(text.find{|i| i == $fdheader}) + if lfunctionend = text.index(text[lfunctionstart+1 .. text.size].find{|i| i =~ /^\.SH/}) + func_text = text[lfunctionstart .. lfunctionend - 1] + group_text = text[0 .. lfunctionstart - 1] + text[lfunctionend ..text.size] + else + func_text = text[lfunctionstart .. text.size] + group_text = text[0 .. lfunctionstart - 1] + end + else + func_text = [] + group_text = text + end + + documentfunc(title, func_text, short_text) + + else + + group_text = text + + end + + filetowrite = open("../../../doxywork/man3/".concat(filename),"w") + print "filetowrite=", filetowrite + filetowrite.puts(group_text) + filetowrite.flush +} + +Dir.chdir(currentdir) +#############################rewriting files + +Dir.chdir("doxywork/man3") + +Dir.open(".").each{|filename| +unless FileTest.directory? filename + + print "PROCESSING: ", filename, "\n" + + file = open(filename,"r") + text = file.readlines + + if /@function/ =~ text[0] + buf = frewrite(text[1..text.size]) + else buf = orewrite(text) + end + + filetowrite = open("../../man/man3m/".concat(filename).concat("m"),"w") + filetowrite.puts(buf) + filetowrite.flush + +end +} + + +# Dir.chdir("/tmp/doxyman") + +# Dir.open(".").each{|f| File.delete(f) if FileTest.file?(f)} diff --git a/utils/run-latex.sh b/utils/run-latex.sh index 3709dc8..1eff8ef 100755 --- a/utils/run-latex.sh +++ b/utils/run-latex.sh @@ -3,9 +3,9 @@ # $2: ja or usr or dev umask 002 -CURDIR=`pwd` -TEXINPUTS=${CURDIR}/$1/styles:${CURDIR}/$1/data-$2:.: +TEXINPUTS=$1/styles:$1/data-$2:.: export TEXINPUTS +echo ${TEXINPUTS} cd $2/latex if [ "$2" = "ja" ] ; then LATEX=platex -- 1.7.10.4