\n" if new_type == 0 and type==0 and s_prev == "" ostr.push s1 else if type == 4 and new_type==4 and new_indent > vlimit indent = new_indent ostr.push s1 else ostr.push(""+@@listtypes[type][1]+">") instring.unshift(s) return ostr end end s_prev = s end ostr end def post_process_paragraphs(instring) ostr=[] inlisting = false while s=instring.shift if s=~ /\:modestart (\S+)\:$/ ostr.push "<#{@@htmllisttypes[$1]}>" inlisting = ($1 == "verbatim") elsif s=~ /\:modeend (\S+)\:$/ inlisting = false ostr.pop if ($1 == "verbatim") and (ostr.last == "") ostr.push "#{@@htmllisttypes[$1]}>" elsif s=~ /\:item\:$/ ostr.push "
\n" +pp+"
"+namelabel + "
Figure " + @@figure_number.to_s + ": " + caption + "
#{Rdoctotex::authorsforref(authors)}, #{year}, #{refdata}
\n" end retval end def convert_citations(s) @@reference_tag_table.each{|ref| s.gsub!(Regexp.new("(\s*)#{ref[0]}(\s*)<\/cite[pt]>")){ if $1 == "t" ref[1] else ref[2] end } } s end def convert_to_reference(instring) s = instring.split(/\n(\s*)\n/m).map{|s| convert_to_single_reference(s)}.join("\n\n"); ss = <<-END = Reference #{s} END ss end def process_references(instring) instring.gsub(/(.+?)<\/REF>/m){ convert_to_reference($1) } end def process_some_special_characters(instring) instring.gsub!(/\\>/m,">") instring.gsub!(/\\= 0) ofile[segment_level].close else raise "Too many #{s} for file #{infile} line #{ARGF.lineno}" end else for i in 0...segment_level do ofile[i].print s end end end ifile.close end # :segment end: prep_rb def prep_rb_special_comments(infile) begin ifile = open(infile, "r") rescue raise "#{infile} does not exist" end outfile = File.dirname(infile)+"/."+File.basename(infile) ofile = open(outfile,"w+") while s = expand(ifile.gets) case s when /\#(\d+)(.*)/ s = s.gsub(/\#(\d+)(.*)/,'') when /(^|(\s)+)\#(\s*)\:segment / s = nil end ofile.print s if s end ifile.close ofile.close end def prep_rb_special_comments_for_partfiles(file) basename =File.dirname(file)+"/."+File.basename(file) Dir[basename+"{+,-}*"].each{|f| newname =File.dirname(f)+"/."+File.basename(f) prep_rb_special_comments(f) File.rename(newname,f) } end @@hashtypes={ ".rb", /\#(\d+)(.*)/, ".h", /\/\/(\d+)(.*)/, ".c", /\/\/(\d+)(.*)/, ".C", /\/\/(\d+)(.*)/, ".cc", /\/\/(\d+)(.*)/, } def prep_rb_hashes(infile) print "prep_rb_hashes for file #{infile}\n" if $DEBUG begin ifile = open(infile, "r") rescue raise "#{infile} does not exist" end if infile =~ /\.(\w+)$/ extension = "."+$1 else raise "File name #{infile} has no extention part" end hashnames=[] while s = expand(ifile.gets) if s =~ @@hashtypes[extension] segment_name = $1 s = s.gsub(/\#(\d+)(.*)/,'') print segment_name if $DEBUG outfile = File.dirname(infile)+"/."+File.basename(infile) + "-" + segment_name print "prep_rb_hashed outfile = #{outfile}\n" if $DEBUG if hashnames.index(outfile) openmode= "a+" else openmode = "w+" hashnames.push(outfile) end open(outfile,openmode){|f| f.print s} end end ifile.close end def prep_rb_defs(infile) ifile = open(infile, "r") method_level = 0 ofile = Array.new; oname = Array.new; olevel = Array.new; classname = "noname" if infile =~ /\.(\w+)$/ extension = "."+$1 else raise "File name #{infile} has no extention part" end htmloutfilename = File.dirname(infile)+"/."+File.basename(infile) +".html" htmloutfile = open(htmloutfilename, "w+") htmloutfile.print "\n"
while s = expand(ifile.gets)
htmlprintline = true
s.gsub!(/([^\t]{8})|([^\t]*)\t/n){[$+].pack("A8")}
if s.split[0]== "class"
classname = s.split[1]
elsif s.split[0]== "module"
classname = s.split[1]
elsif s.split[0]== "def"
method_name = s.gsub(/\(/," ").split[1]
print method_name if $DEBUG
method_name = "_divide_" if method_name == "/"
outfile = File.dirname(infile)+"/."+File.basename(infile) +
"+" + method_name
outfilelong=outfile+ "+" +classname
if oname[0...method_level].index(outfile) != nil
raise "Too many defs for file #{infile} line #{ARGF.lineno}"
end
oname[method_level]=[outfile,outfilelong]
ofile[method_level] = [open(outfile, "w+"),open(outfilelong, "w+")]
olevel[method_level] = s.index("def")
method_level += 1
htmloutfile.print ""
htmloutfile.print ""
elsif s.split[0] == "end"
loc = s.index("end")
# check if this "end" corresponds to the deepest level "def"
if method_level > 0
lastlevel = method_level-1
if olevel[lastlevel] == loc
ofile[lastlevel].each{|x| x.print s}
ofile[lastlevel].each{|x| x.close}
method_level -= 1
elsif olevel[lastlevel] > loc
raise "Unexpected \"end\" with level #{loc} for expected level "+
"#{olevel[lastlevel]} at line #{ARGF.lineno} of file #{infile}"
end
end
end
for i in 0...method_level do
ofile[i].each{|x| x.print s}
end
s.gsub!(@@hashtypes[extension]){""}
s.gsub!( /^\s*#\s*:segment start:\s*(\S*)\s*\n/){""}
htmlprintline = false if s =~ /#\s*:segment end:/
htmloutfile.print s if htmlprintline
end
ifile.close
htmloutfile.print "\n"
htmloutfile.close
end
def prep_c_defs(infile)
ifile = open(infile, "r")
outfilenamebase = File.dirname(infile)+"/."+File.basename(infile) +
"+"
while s = expand(ifile.gets)
s.gsub!(/([^\t]{8})|([^\t]*)\t/n){[$+].pack("A8")}
if s =~ /\s*typedef\s+(struct|union)\s+(\w\S*)\{$/
name=$2
typedefstring = s
while (s = expand(ifile.gets)) !~ /^\s*\}.*;\s*$/
typedefstring += s
end
typedefstring += s
open(outfilenamebase+name,"w"){|f|f.print typedefstring}
elsif s =~ /^(\w\S*\s+)+(\S+)\(/
name = $2
print "#{infile}: #{s.chomp} : #{name}\n"
functionstring = s
while s !~ /(^\{)|(\);)/
s = expand(ifile.gets)
functionstring += s
end
if $1
while s !~ /^\}/
s = expand(ifile.gets)
functionstring += s
end
open(outfilenamebase+name,"w"){|f|f.print functionstring}
end
end
end
ifile.close
end
def initacs
acsdocinitfile=nil
for fname in [ENV["ACSDOCINITRC"], ".acsdocinitrc", ENV["HOME"]+"/.acsdocinitrc"]
if acsdocinitfile == nil and fname != nil and File.exist?(fname)
acsdocinitfile = fname
end
end
if acsdocinitfile
print "Loading initialization file #{acsdocinitfile}\n"
load acsdocinitfile
else
print "No config file found\n"
end
end
@@toppagefilename= nil
def navigation_string(prev,nex,filename)
prevtext = "Previous"
nexttext = "Next"
toctext = "ToC"
toptext = ""
if @@toppagefilename
toptext = "" currentlevel=0 @@sectionheaders.each{|x| while x[1]>currentlevel s += "
Please update your bookmarks. END } end def movetosubdirectory(cplist, directory_name) if File.exist?(directory_name) and not File.directory?(directory_name) raise "#{directory_name} is a file. Cannot move texts there" end Dir.mkdir(directory_name) unless File.exist?(directory_name) if File.exist?(directory_name+"/.imgs") files = Dir.glob(directory_name+"/.imgs/*") File.delete(*files) if files.size > 0 Dir.rmdir(directory_name+"/.imgs") end system "mv -f #{cplist.join(" ")} .imgs #{@@stylefilename} #{directory_name}" end end # :segment start: acsdoc include Acsdoc ## define some global variables used as options, before reading in ## the initialization file $numbersections=true initacs $texscale= ENV["ACSDOCTEXSCALE"]? ENV["ACSDOCTEXSCALE"]:1900 load_old_aux load_volindex del_flag = true tolatex_flag = false directory_arg = false directory_name = nil cpfiles = [] ARGV.collect! do |a| if a =~ /\.((cp)|(ok))$/ extention = "."+$1 $current_extention=extention if FileTest.size?(a) unless tolatex_flag dot_a = File.dirname(a)+"/"+File.basename(a,extention)+ ".html" else dot_a = File.dirname(a)+"/"+File.basename(a,extention)+ ".tex" end $current_cp_filename = a prep_cp(a, dot_a, tolatex_flag) if File.exist?(dot_a) cpfiles.push([a,dot_a, convert_cpfilename_to_rdoc_htmlfilename(a)]) a = dot_a else a = nil end else a = nil end a elsif a =~ /\.rb$/ if File.exist?(a) prep_rb(a) prep_rb_defs(a) prep_rb_hashes(a) prep_rb_special_comments(a) prep_rb_special_comments_for_partfiles(a) else a = nil end a elsif a =~ /\.(h|C|c|cc)$/ if File.exist?(a) prep_rb(a) prep_c_defs(a) prep_rb_hashes(a) # prep_rb_special_comments(a) # prep_rb_special_comments_for_partfiles(a) else a = nil end a elsif a == "--keep-dot-files" print "Obsolete option ignored: --keep-dot-files\n" a = nil elsif a == "--tolatex" tolatex_flag = true del_flag = false a = nil elsif a == "--reuseoutput" print "reuse flag set\n" setreuseoutput true readin_commandoutputs a = nil elsif a == "--directory" print "Directory arg found\n" directory_arg = true a = nil elsif directory_arg == true directory_name = a print "Directory to store: #{a}\n" directory_arg = false a=nil end a end if (ENV["LANG"] == "ja_JP.eucJP") or ($KCODE == "EUC") coptions = "--charset=EUC-JP" else coptions = " " end ARGV.compact! unless tolatex_flag cplist = cpfiles.collect{|x| x[1]} p cplist if $DEBUG add_toc process_css dump_aux create_navigations_for_cp_files(cplist) add_html_headeretc(cplist) cpfiles.each{|x| make_notice_for_old_page(x[1],x[2])} movetosubdirectory(cplist, directory_name) if directory_name end # :segment end: