X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=utils%2Fmkman.rb;h=b136889fcb04597a2e9ba370fa1677fbfee147bc;hb=5eadba52c9ee305152c88d2d6da29f7be14f69a2;hp=a6567a1ef1cad6f845fa48d5743e61bc4a795ad2;hpb=734e96f6cea5c6bb7548f330497b50575528e272;p=m17n%2Fm17n-docs.git diff --git a/utils/mkman.rb b/utils/mkman.rb index a6567a1..b136889 100644 --- a/utils/mkman.rb +++ b/utils/mkman.rb @@ -1,23 +1,24 @@ #! /usr/local/bin/ruby +# Usage: mkman.rb SRCDIR DSTDIR + #¼Â¹Ô¤¹¤ë¤È/tmp/doxyman¤ò¤Ä¤«¤Ã¤Æ¥Õ¥¡¥¤¥ë¤òʬ¤±¡¢ #¤â¤È¤Îdirectory¤Ë¤«¤­¤Ê¤ª¤¹¡£ # see also ¤ÎÃæ¿È¤ò woman ¸þ¤±¤Ë½ñ¤­´¹¤¨¤ë¡£ -usr_or_ja=$*[0] +$manext="."+$*[0] # # Setting up directory names. # $currentdir = Dir.pwd+"/" +$srcdir=$currentdir+$*[1]+"/" +$dstdir=$currentdir+$*[2]+"/" $doxywork = $currentdir+"doxywork/" -$srcman3 = $currentdir+usr_or_ja+"/man/man3/" -if usr_or_ja == "usr" - $dstman3m = $currentdir+"/man/man3m/" -else - $dstman3m = $currentdir+"/man/ja/man3m/" -end $sampledir="sample/man3/" +$headfile = $currentdir+"manhead" + +headbuf = open($headfile, "r").readlines # # Extra information about header strings Doxygen generates in a man file. @@ -84,7 +85,7 @@ def writedocumentation(buf, text, index) def datastructure(struct) - text = open(struct.concat(".3m"),"r").readlines + text = open(struct.concat($manext),"r").readlines buf = [] @@ -169,7 +170,7 @@ def documentfunc2 (dstart, title, func_text, short_text) #short_text¤Î´Ø¿ô̾¤Î£²¹Ô¸å¤¬brief¡£ brief = short_text[short_text.index(short_text.find{|i| i.index(ffname)}) + 2] #´Ø¿ô¤´¤È¤Î¥Õ¥¡¥¤¥ë¤òºî¤ë¡£ - file = open($doxywork+fname+".3m", "w") + file = open($doxywork+fname+$manext, "w") file.puts("@function") #¥Ø¥Ã¥À /^\.TH \"([^"]*)\"\s/ =~ title @@ -197,7 +198,7 @@ def documentfunc2 (dstart, title, func_text, short_text) def frewrite(text) # let the library name appear in the header - buf = [text[0].gsub!("\" \"", "\" \"\" \"")] + buf = [text[0].gsub!(/\" \"/, "\" \"\" \"")] title = text[0].split(" ")[1].chop!.reverse.chop!.reverse @@ -246,31 +247,45 @@ def desrewrite(text) ind = text.index(line) text.delete_at(ind+1) if text[ind+1] == (".in +1c\n")} +### letting verbatim end in place Part1 + verbatim = false text.each_with_index{|line,i| ### TEST 6/24 - line.gsub!(".RS 4","") + line.gsub!(/^\.RS 4/,"") + +### letting verbatim end in place Part2 + if line =~ /^\.nf/ + verbatim = true + end + + if verbatim == true + if line =~ /^\.PP/ + line.gsub!(/^\.PP/,".fi") + verbatim = false + end + end #removing "More..." hyperlink line.gsub!(/More.../,"") # ? ad hoc line.gsub!(/^\.TP/,"") + #headers if line =~ /Return\svalue:/ - line = "\n.SH RETURNS\n.PP" returndescribed = true end -# line.gsub!(/^\\fBReturn value:\\fP/,"\n.SH RETURNS\n.PP") + line.gsub!(/^\\fBReturn value:\\fP/,"\n.SH RETURN VALUE\n.PP") if line =~ /Errors:/ - line = "\n.SH ERRORS\n.PP" errordescribed = true end -# line.gsub!(/^\\fBErrors:\\fP/,"\n.SH ERRORS\n.PP") + line.gsub!(/^\\fBErrors:\\fP/,"\n.SH ERRORS\n.PP") line.gsub!(/^\\fBSee Also:\\fP/,"\n.SH \"SEE ALSO\"\n.PP") - line.gsub!(/^\\fB(.+)\\fP/){"\n.SS " << $1} + line.gsub!(/^\\fB(.+)[^\)]\\fP/){"\n.SS " << $1} + # [^\)] in the pattern is added to avoid the first function in see also section. #removing indentation if text[i - 1] =~ /^.PP/ @@ -340,10 +355,24 @@ def orewrite(text) text.each_with_index{|line,i| line.gsub!(/More.../,"") + + ### let verbatim end in place + line.gsub!(/^.nf/,".NF") + + ### test1/16/2004 changes the type of list, and indentation + if line =~ /^.IP/ + line = ".TP" + text[i+2] = "" + end + + if line =~ /^.TP/ + text[i+2] = "" + end + ### end of test1/20/2004 # let the library name appear in the header if line =~ /^.TH/ - line = line.gsub!("\" \"", "\" \"\" \"") + line = line.gsub!(/\" \"/, "\" \"\" \"") end # finding structure documentations and merging into "structures" @@ -369,7 +398,7 @@ def orewrite(text) #removing author section line.gsub!(/^\.SH\s\"AUTHOR\"/,"") - line.gsub!("Generated automatically by Doxygen for m17n_test from the source code.","") + line.gsub!(/Generated automatically by Doxygen for m17n_test from the source code\./,"") line.gsub!(/\\fP\s+,/,"\\fP,") line.gsub!(/\\fP\s+\./,"\\fP.") @@ -394,7 +423,7 @@ end Dir.mkdir $doxywork unless FileTest.directory? $doxywork -Dir.chdir($srcman3) +Dir.chdir($srcdir) Dir.open(".").each{|filename| @@ -402,9 +431,13 @@ Dir.open(".").each{|filename| next end - #if filename =~ /\.c\./ - # next - #end + if filename =~ /\.[ch]\./ + next + end + + if filename =~ /\.txt\./ + next + end file = open(filename,"r") text = file.readlines @@ -446,7 +479,7 @@ Dir.open(".").each{|filename| #############################rewriting files -Dir.chdir($dstman3m) +Dir.chdir($dstdir) Dir.open(".").each{|f| File.delete(f) if FileTest.file?(f)} @@ -469,7 +502,8 @@ unless FileTest.directory? filename else buf = orewrite(text) end - filetowrite = open($dstman3m+filename,"w") + filetowrite = open($dstdir+filename,"w") + filetowrite.puts(headbuf) filetowrite.puts(buf) filetowrite.flush end