usr_or_ja=$*[0]
-currentdir = Dir.pwd+"/"
-$doxywork = currentdir+"doxywork/"
-$srcman3 = currentdir+usr_or_ja+"/man/man3/"
+#
+# Setting up directory names.
+#
+
+$currentdir = Dir.pwd+"/"
+$doxywork = $currentdir+"doxywork/"
+$srcman3 = $currentdir+usr_or_ja+"/man/man3/"
if usr_or_ja == "usr"
- $dstman3m = currentdir+"/man/man3m/"
+ $dstman3m = $currentdir+"/usr/man3m/"
else
- $dstman3m = currentdir+"/man/ja/man3m/"
+ $dstman3m = $currentdir+"/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.
+#
+
+def nextheader(text,index)
+ header = text[index+1..text.size].find{|i| i =~ /\.S(S|H)/}
+ return header
+ end
+
+grouptext = open($sampledir+"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($sampledir+"SampleStructure.3","r").readlines.reverse
-headertexts = open("doxyhead.txt","r").readlines
- $fdheader = headertexts[0]
- $flheader = headertexts[1]
- $ddheader = headertexts[2]
- $fielddheader = headertexts[3]
- $fieldlheader = headertexts[4]
+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)
+
+#
+# Main work
+#
#### to find data structure documentation files and rewriting them
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
+# 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)
nl = fdline + 1
writedocumentation(buf, text, nl)
end
+
+# File.delete(struct) if FileTest.file?(struct)
return buf
end
def documentfunc2 (dstart, title, func_text, short_text)
#func_text¤ÎºÇ½é¤Î¹ÔÃæ¤Î´Ø¿ô̾
- dstart =~ /\s([a-z_]+)\s\(/
+
+ dstart =~ /\s([a-z0-9_]+)\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]
#¥Ø¥Ã¥À
/^\.TH \"([^"]*)\"\s/ =~ title
oname = $1
- newtitle = title.gsub(oname, fname.chop.chop)
+##????? newtitle = title.gsub(oname, fname.chop.chop)
+ newtitle = title.gsub(oname, fname)
file.puts(newtitle)
#@brief
file.print("@brief ")
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\"/
description == []
print title, ": No description found\n"
else
- buf.push("\n.SH DESCRIPTION\n").push(womanrewrite(desrewrite(description)))
+ descriptiontext = womanrewrite(desrewrite(description))
+ buf.push("\n.SH DESCRIPTION\n").push(descriptiontext)
end
return buf
end
####non-synopsys section of a function
def desrewrite(text)
+ returndescribed = false
+ errordescribed = false
#removing identation
text.grep(/^\\fB.+\\fP/){|line|
text.each_with_index{|line,i|
+### TEST 6/24
+ line.gsub!(".RS 4","")
+
+### letting verbatim end in place
+ line.gsub!(/^.nf/,".NF")
+
#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")
+ if line =~ /Return\svalue:/
+ returndescribed = true
+ end
+ line.gsub!(/^\\fBReturn value:\\fP/,"\n.SH RETURN VALUE\n.PP")
+ if line =~ /Errors:/
+ errordescribed = true
+ end
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/
}
+unless returndescribed == true
+ print (" return not described \n")
+end
+unless errordescribed == true
+ print (" errors not described \n")
+end
+
return text
end
text.each_with_index{|line,i|
line.gsub!(/More.../,"")
+
+ ### let verbatim end in place
+ line.gsub!(/^.nf/,".NF")
# let the library name appear in the header
if line =~ /^.TH/
Dir.chdir($srcman3)
Dir.open(".").each{|filename|
+
if FileTest.directory? filename
next
end
- if filename =~ /\.c\./
- next
- end
+ #if filename =~ /\.c\./
+ # next
+ #end
file = open(filename,"r")
text = file.readlines
Dir.open(".").each{|filename|
unless FileTest.directory? filename
- print "PROCESSING: ", filename, "\n"
+ file = open(filename,"r")
+ text = file.readlines
- file = open(filename,"r")
- text = file.readlines
+ if text.include?($fielddheader)
+ next
+ end
- if /@function/ =~ text[0]
- buf = frewrite(text[1..text.size])
- else buf = orewrite(text)
- end
+ print "PROCESSING: ", filename, "\n"
- filetowrite = open($dstman3m+filename,"w")
- filetowrite.puts(buf)
- filetowrite.flush
+ if /@function/ =~ text[0]
+ buf = frewrite(text[1..text.size])
+ else buf = orewrite(text)
+ end
+ filetowrite = open($dstman3m+filename,"w")
+ filetowrite.puts(headbuf)
+ filetowrite.puts(buf)
+ filetowrite.flush
end
}
-
-Dir.chdir($doxywork)
-
-Dir.open(".").each{|f| File.delete(f) if FileTest.file?(f)}