From 6781fdb8e852607c6856979fe955e989c203c1dc Mon Sep 17 00:00:00 2001 From: handa Date: Tue, 17 Jun 2003 13:21:17 +0000 Subject: [PATCH] *** empty log message *** --- Makefile.am | 97 ++++++----- data-usr/introduction.tex | 15 ++ doxyfile.in | 30 ++-- utils/mkman2.rb | 395 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 480 insertions(+), 57 deletions(-) create mode 100644 data-usr/introduction.tex create mode 100755 utils/mkman2.rb diff --git a/Makefile.am b/Makefile.am index e031f4c..4f574b1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,30 +8,28 @@ if MAINTAINER_MODE SRCFILES = $(shell echo @M17NLIB@/src/*.[ch]) -STYLEPATH = @srcdir@/styles -UTILPATH = @srcdir@/utils +STYLEPATH = @abs_srcdir@/styles +UTILPATH = @abs_srcdir@/utils LATEX_JA = ${STYLEPATH}/doxygen-m17n.sty \ - @srcdir@/data-ja/header.tex \ - @srcdir@/data-ja/introduction.tex \ - @srcdir@/data-ja/m17n-basicC.tex \ - @srcdir@/data-ja/m17n-X.tex \ - @srcdir@/data-ja/m17n-database.tex \ - @srcdir@/data-ja/conclusion.tex + @abs_srcdir@/data-ja/header.tex \ + @abs_srcdir@/data-ja/introduction.tex \ + @abs_srcdir@/data-ja/m17n-basicC.tex \ + @abs_srcdir@/data-ja/m17n-X.tex \ + @abs_srcdir@/data-ja/m17n-database.tex \ + @abs_srcdir@/data-ja/conclusion.tex LATEX_USR = ${STYLEPATH}/doxygen-m17n.sty \ - @srcdir@/data-usr/header.tex + @abs_srcdir@/data-usr/header.tex LATEX_DEV = ${STYLEPATH}/doxygen-m17n.sty \ - @srcdir@/data-dev/header.tex + @abs_srcdir@/data-dev/header.tex DOXYGEN = doxygen PROJECT_NAME_EN = "Multilingual Library for Unix/Linux" PROJECT_NAME_JA = "Unix/Linux ÍÑ¿¸À¸ì¥é¥¤¥Ö¥é¥ê" -PROJECT_NUMBER = 1.0 - LATEX_HEADER_JA = header.tex LATEX_HEADER_EN = @@ -42,7 +40,7 @@ notarget: @echo " usr ja dev" @echo " all" -all: usr ja dev +all: usr ja dev man usr-html html-usr: usr/html/index.html ja-html html-ja: ja/html/index.html @@ -55,89 +53,104 @@ dev-latex latex-dev: dev/latex/refman.ps usr: html-usr latex-usr ja: html-ja latex-ja dev: html-dev latex-dev +man: man/man3/m17nIntro.3 -doxyfile-html.usr: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-html.usr: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_EN}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/usr/' \ + -e 's/%USR_JA_DEV_MAN%/usr/' \ + -e 's/%INPUT_FILTER%/usr/' \ -e 's/%OUTPUT_LANGUAGE%/English/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|NO|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ -doxyfile-html.dev: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-html.dev: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_EN}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/dev/' \ + -e 's/%USR_JA_DEV_MAN%/dev/' \ + -e 's/%INPUT_FILTER%/dev/' \ -e 's/%OUTPUT_LANGUAGE%/English/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|NO|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ -doxyfile-html.ja: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-html.ja: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_JA}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/ja/' \ + -e 's/%USR_JA_DEV_MAN%/ja/' \ + -e 's/%INPUT_FILTER%/ja/' \ -e 's/%OUTPUT_LANGUAGE%/Japanese/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|NO|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ -doxyfile-latex.usr: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-html.man: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_EN}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/usr/' \ + -e 's/%USR_JA_DEV_MAN%/man/' \ + -e 's/%INPUT_FILTER%/usr/' \ + -e 's/%OUTPUT_LANGUAGE%/English/' \ + -e 's|%GENERATE_HTML%|NO|' \ + -e 's|%GENERATE_LATEX%|NO|' \ + -e 's|%GENERATE_MAN%|YES|' \ + < $< >$@ + +doxyfile-latex.usr: @abs_srcdir@/doxyfile ${SRCFILES} + sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_EN}|' \ + -e 's/%USR_JA_DEV_MAN%/usr/' \ + -e 's/%INPUT_FILTER%/usr/' \ -e 's/%OUTPUT_LANGUAGE%/English/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|YES|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ -doxyfile-latex.dev: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-latex.dev: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_EN}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/dev/' \ + -e 's/%USR_JA_DEV_MAN%/dev/' \ + -e 's/%INPUT_FILTER%/dev/' \ -e 's/%OUTPUT_LANGUAGE%/English/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|YES|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ -doxyfile-latex.ja: @srcdir@/doxyfile ${SRCFILES} - umask 002; \ +doxyfile-latex.ja: @abs_srcdir@/doxyfile ${SRCFILES} sed -e 's|%PROJECT_NAME%|${PROJECT_NAME_JA}|' \ - -e 's/%PROJECT_NUMBER%/${PROJECT_NUMBER}/' \ - -e 's/%DEV_OR_USR_OR_JA%/ja/' \ + -e 's/%USR_JA_DEV_MAN%/ja/' \ + -e 's/%INPUT_FILTER%/ja/' \ -e 's/%OUTPUT_LANGUAGE%/Japanese/' \ -e 's|%GENERATE_HTML%|YES|' \ -e 's|%GENERATE_LATEX%|YES|' \ + -e 's|%GENERATE_MAN%|NO|' \ < $< >$@ %/html/index.html: doxyfile-html.% - umask 002; \ ${DOXYGEN} $< %/latex/refman.tex: doxyfile-latex.% ${UTILPATH}/refman-filter.awk - umask 002; \ ${DOXYGEN} $<; \ awk -f ${UTILPATH}/refman-filter.awk < $@ > temp; \ mv temp $@ ja/latex/refman.ps: ja/latex/refman.tex ${UTILPATH}/run-latex.sh ${LATEX_JA} - ${UTILPATH}/run-latex.sh @srcdir@ ja + ${UTILPATH}/run-latex.sh @abs_srcdir@ ja emacs -batch -q -l ${UTILPATH}/mokuji.el -f write-mokuji ja usr/latex/refman.ps: usr/latex/refman.tex ${UTILPATH}/run-latex.sh ${LATEX_USR} - ${UTILPATH}/run-latex.sh @srcdir@ usr + ${UTILPATH}/run-latex.sh @abs_srcdir@ usr emacs -batch -q -l ${UTILPATH}/mokuji.el -f write-mokuji usr dev/latex/refman.ps: dev/latex/refman.tex ${UTILPATH}/run-latex.sh ${LATEX_DEV} - ${UTILPATH}/run-latex.sh @srcdir@ dev + ${UTILPATH}/run-latex.sh @abs_srcdir@ dev emacs -batch -q -l ${UTILPATH}/mokuji.el -f write-mokuji dev +tmp/man3/m17nIntro.3: doxyfile-html.man + ${DOXYGEN} $< + +man/man3/m17nIntro.3: tmp/man3/m17nIntro.3 ${UTILPATH}/mkman2.rb + cd tmp/man3; ${UTILPATH}/mkman2.rb + .PRECIOUS: %/latex/refman.tex CLEANFILES = doxyfile doxyfile-latex.* doxyfile-html.* m17n.tag warning \ diff --git a/data-usr/introduction.tex b/data-usr/introduction.tex new file mode 100644 index 0000000..dcd9fb0 --- /dev/null +++ b/data-usr/introduction.tex @@ -0,0 +1,15 @@ +\section{Introduction of the m17n library} + +\subsection{Motivation} +\subsubsection{Background} + +What is the multilingual text processing? + +What is the multilingual library? + +\subsubsection{Position of the library} + +\subsubsection{Characteristics of the library} + +\subsubsection{Strategy} + diff --git a/doxyfile.in b/doxyfile.in index 2257cdc..82536bf 100644 --- a/doxyfile.in +++ b/doxyfile.in @@ -23,14 +23,14 @@ PROJECT_NAME = %PROJECT_NAME% # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = %PROJECT_NUMBER% +PROJECT_NUMBER = @PACKAGE_VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # 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 = %DEV_OR_USR_OR_JA% +OUTPUT_DIRECTORY = %USR_JA_DEV_MAN% # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this @@ -308,14 +308,14 @@ WARN_LOGFILE = warning # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @M17NLIB@/src/ +INPUT = "@M17NLIB@/src/m17n-core.h" "@M17NLIB@/src/m17n.h" "@M17NLIB@/src/m17n-win.h" "@M17NLIB@/src/m17n-X.h" "@M17NLIB@/src/m17n-err.h" "@M17NLIB@/src/" # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -FILE_PATTERNS = *.h *.c +FILE_PATTERNS = *.c # The RECURSIVE tag can be used to turn specify whether or not subdirectories @@ -362,7 +362,7 @@ IMAGE_PATH = /project/mule/m17n-lib/docs/doxygen/images # input file. Doxygen will then use the output that the filter program writes # to standard output. -INPUT_FILTER = @srcdir@/utils/%DEV_OR_USR_OR_JA%_filter.rb +INPUT_FILTER = @abs_srcdir@/utils/%INPUT_FILTER%_filter.rb # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source @@ -412,20 +412,20 @@ HTML_OUTPUT = # each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = @srcdir@/header.html +HTML_HEADER = @abs_srcdir@/header.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = @srcdir@/footer.html +HTML_FOOTER = @abs_srcdir@/footer.html # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet -HTML_STYLESHEET = @srcdir@/m17nlib.css +HTML_STYLESHEET = @abs_srcdir@/m17nlib.css # HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, @@ -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 = @srcdir@/header.tex +LATEX_HEADER = @abs_srcdir@/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 @@ -591,13 +591,13 @@ RTF_EXTENSIONS_FILE = # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages -GENERATE_MAN = no +GENERATE_MAN = %GENERATE_MAN% # The MAN_OUTPUT tag is used to specify where the man pages will be put. # 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 = +MAN_OUTPUT = ../tmp # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) @@ -610,7 +610,7 @@ MAN_EXTENSION = # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. -MAN_LINKS = yes +MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output @@ -671,7 +671,7 @@ INCLUDE_FILE_PATTERNS = # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. -PREDEFINED = +PREDEFINED = FOR_DOXYGEN # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. @@ -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/%DEV_OR_USR_OR_JA%/html/ +DOC_URL = http://mule.m17n.org/m17n-lib/%USR_JA_DEV_MAN%/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 = @srcdir@/%DEV_OR_USR_OR_JA%/html +DOC_ABSPATH = @abs_srcdir@/%USR_JA_DEV_MAN%/html # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. diff --git a/utils/mkman2.rb b/utils/mkman2.rb new file mode 100755 index 0000000..10b9fd5 --- /dev/null +++ b/utils/mkman2.rb @@ -0,0 +1,395 @@ +#! /usr/bin/ruby +#¼Â¹Ô¤¹¤ë¤È../work¤ò¤Ä¤«¤Ã¤Æ¥Õ¥¡¥¤¥ë¤òʬ¤±¡¢ +#¤â¤È¤Îdirectory¤Ë¤«¤­¤Ê¤ª¤¹¡£ +# see also ¤ÎÃæ¿È¤ò woman ¸þ¤±¤Ë½ñ¤­´¹¤¨¤ë¡£ + +#### 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("\.SH \"DETAILED DESCRIPTION\"\n") + 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 fileds + if dfline = text.index("\.SS \"Data Fields\"\n") + buf.push("\\fBData Fields:\\fP\n") + nl = dfline + 1 + writeuntilsectionheader(buf, text, nl) + buf.push(".PP\n") + end + +# field documentation + if fdline = text.index("\.SH \"FIELD DOCUMENTATION\"\n") + 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("../work/".concat(fname.concat(".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) + buf = [text[0]] + 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!(/^\\fBReturns: \\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("\.SH \"DETAILED DESCRIPTION\"\n") + 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.../,"") + + # 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/}) + buf = buf[0 .. dindex-1] + structures + buf[dindex .. buf.size] + else + buf = buf + structures + end + end + + return buf +end + +#############################dividing files + +Dir.mkdir "../work" unless FileTest.directory? "../work" + +Dir.open(".").each{|filename| + if FileTest.directory? filename + next + end + + if filename =~ /\.c\./ +# File.delete(filename) + next + end + + file = open(filename,"r") + text = file.readlines + title = text[0] + + if + sfunctionstart = text.index(text.find{|i| i =~ /^\.SS "Function/}) + 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 =~ /^\.SH "FUNCTION DOCUMENTATION"/}) + 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("../work/".concat(filename),"w") + filetowrite.puts(group_text) + filetowrite.flush +} + + +#############################rewriting files +Dir.mkdir "../../man" unless FileTest.directory? "../../man" +Dir.mkdir "../../man/man3" unless FileTest.directory? "../../man/man3" + + +Dir.open("../work").each{|filename| +unless FileTest.directory? filename + + print "PROCESSING: ", filename, "\n" + + file = open("../work/".concat(filename),"r") + text = file.readlines + + if /@function/ =~ text[0] + buf = frewrite(text[1..text.size]) + else buf = orewrite(text) + end + + filetowrite = open("../../man/man3/".concat(filename),"w") + filetowrite.puts(buf) + filetowrite.flush + +end +} + + +Dir.chdir("../work") + +Dir.open(".").each{|f| File.delete(f) if FileTest.file?(f)} -- 1.7.10.4