X-Git-Url: http://git.chise.org/gitweb/?p=m17n%2Fm17n-docs.git;a=blobdiff_plain;f=utils%2Fmkman.rb;h=bad886218a6cc9e05eb087a7ac01851d6bf8af0a;hp=923899c1c4f6ae7733e863265240fc8bebfae528;hb=0a0f8d6a14946c8f55da81b4f310aba9acc850fb;hpb=194a8351a8885db90eddbaab07b2f3e0a55b12f3 diff --git a/utils/mkman.rb b/utils/mkman.rb index 923899c..bad8862 100644 --- a/utils/mkman.rb +++ b/utils/mkman.rb @@ -1,5 +1,5 @@ #! /usr/local/bin/ruby -# Usage: mkman.rb SRCDIR DSTDIR -*- coding: euc-japan; -*- +# Usage: mkman.rb SRCDIR DSTDIR -*- coding: euc-jp; -*- #¼Â¹Ô¤¹¤ë¤È/tmp/doxyman¤ò¤Ä¤«¤Ã¤Æ¥Õ¥¡¥¤¥ë¤òʬ¤±¡¢ #¤â¤È¤Îdirectory¤Ë¤«¤­¤Ê¤ª¤¹¡£ @@ -210,24 +210,65 @@ def documentfunc2 (fname, title, func_desc, brief) # file.puts(line) # end file.flush + file.close +end - end +# Extract documentation for each program and write out manuals. +def documentprog (text) + header = text[0] + progtext = [] + title = "" + brief = "" + text.each_with_index{|line,i| + if line =~ /^\.SH\s*\"(\S+) -- ([^\"]+)\"/ + # Remember the title and short description. It may or may not + # be for a program. + title = $1 + brief = $2 + elsif line =~ /^\.SS\s*"SYNOPSIS"/ + # Only a program has "SYNOPSIS". + progtext.push(header.gsub("m17nExProg",title)) + progtext.push(".ad l\n.nh\n.SH NAME\n") + progtext.push(title + " - " + brief) + progtext.push(".SH SYNOPSIS") + elsif line =~ /^\.PD 0/ + # Don't write this "inter-paragraph vertical distance" command + elsif line =~ /Print this message./ + # This is always the end of description for a program. + if progtext.length > 0 + file = open($doxywork+title+$manext,"w") + file.puts(progtext) + file.puts(line) + file.close + progtext = [] + end + elsif progtext.length > 0 + if line =~ /^\.SS\s*(.*)/ + # Convert ".SS ..." to ".SH ..." + progtext.push(".SH " + $1) + else + progtext.push(line) + end + end + } +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!(/\" \"/, "\" \"\" \"")] + # let the library name appear in the header (for old buggy doxygen) + # buf = [text[0].gsub!(/\" \"/, "\" \"\" \"")] + buf = [text[0]] title = text[0].split(" ")[1].chop!.reverse.chop!.reverse 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) + buf.push(title.concat(" \\- ").concat($1)) + else buf.push(title.concat(" \\- ")) end synopsys = text.find{|line| line =~ /\.SS/} @@ -390,10 +431,10 @@ def orewrite(text) # text[i+2] = "" # end - # let the library name appear in the header - if line =~ /^.TH/ - line = line.gsub!(/\" \"/, "\" \"\" \"") - end + # let the library name appear in the header (for old buggy doxygen) + # if line =~ /^.TH/ + # line = line.gsub!(/\" \"/, "\" \"\" \"") + # end # finding structure documentations and merging into "structures" if line =~ /^\.RI\s\"struct\s\\fB(.*)\\fP\"/ @@ -416,6 +457,18 @@ def orewrite(text) # end # end + if text[i-2] =~ /^.SH\sNAME/ && text[i] =~ /^.PP/ && text[i+1] =~ /./ + # Convert this line sequence: + # .SH NAME + # M-text \- + # .PP + # M-text objects and API for them. + # to: + # .SH NAME + # M-text \- M-text objects and API for them. + prevline = buf.pop.chop!.chop!.chop!.chop!.chop!.gsub(" ","_").concat(" \\- ") + text[i+1] = prevline.concat(text[i+1]) + else #removing author section line.gsub!(/^\.SH\s\"AUTHOR\"/,"") line.gsub!(/Generated automatically by Doxygen for m17n_test from the source code\./,"") @@ -427,8 +480,8 @@ def orewrite(text) line.gsub!(/\\fP\s+,/,"\\fP,") line.gsub!(/\\fP\s+\./,"\\fP.") line.gsub!(/\\fC\\fB(\w+)\\fP\\fP/){"\\fB" << $1 << "\\fP"} - buf.push(line) + end } unless structures == ["\.SH \"Data Structure Documentation\"\n"] @@ -450,62 +503,68 @@ Dir.mkdir $doxywork unless FileTest.directory? $doxywork Dir.chdir($srcdir) Dir.open(".").each{|filename| - - if FileTest.directory? filename - next - end - - if filename =~ /\.[ch]\./ - next - end - - if filename =~ /\.txt\./ - next - end - - print "RUBY DIVIDING: ", filename, "\n" - - 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/}) + + if FileTest.directory? filename + next + end + + if filename =~ /\.[ch]\./ + next + end + + if filename =~ /\.txt\./ + next + end + + print "RUBY DIVIDING: ", filename, "\n" + + file = open(filename,"r") + text = file.readlines + title = text[0] + + if filename =~ /m17nExProg.1/ + documentprog(text) + else + + 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 + 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] + 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 + func_text = text[lfunctionstart .. text.size] + group_text = text[0 .. lfunctionstart - 1] + end else - func_text = [] - group_text = text + func_text = [] + group_text = text + end + + residue = documentfunc(title, func_text, short_text) + + if residue == [] + else + group_text = group_text + [".SH \"Function Documentation\"\n.PP\n"] + residue + end + + else + + group_text = text + end - residue = documentfunc(title, func_text, short_text) - - if residue == [] - else - group_text = group_text + [".SH \"Function Documentation\"\n.PP\n"] + residue - end - - else - - group_text = text - + filetowrite = open($doxywork+filename,"w") + filetowrite.puts(group_text) + filetowrite.flush + filetowrite.close end - - filetowrite = open($doxywork+filename,"w") - filetowrite.puts(group_text) - filetowrite.flush + file.close } #############################rewriting files @@ -538,5 +597,7 @@ unless FileTest.directory? filename filetowrite.puts(buf) filetowrite.puts(footbuf) filetowrite.flush + filetowrite.close + file.close end }