\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} "
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
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
"
end
def process_tex_inlines(s,instring,dirname)
if s.index("
\n"
else
x=str.gsub(/^(=+)\s*(.+)$/){|s|
sectionlevel = $1.length
sectionname = $2
if @@section_counters[sectionlevel]==nil
@@section_counters[sectionlevel]=1
else
@@section_counters[sectionlevel]+=1
end
@@section_counters= @@section_counters[0..sectionlevel]
number_label = @@section_counters[1..sectionlevel].join(".")+"."
sectionname = number_label+ " "+ sectionname if $numbersections
sectionlabel="rdocsect"+@@sectionheadercounter.to_s
@@sectionheaders.push [sectionlabel,sectionlevel,sectionname,filename]
@@sectionheadercounter+= 1
labeltext = sectionname if labeltext==nil
@@section_label_table[labeltext]=sectionlabel
lastsectionnumber=number_label[0,number_label.length-1]
labeltext=nil
# " "+sectionname+ "
\n\n"
"\n "+sectionname+ "
\n"
}
ostring +=x
end
}
ostring
end
@@filefortoc = []
def process_toc(instring,filename)
if instring =~ /^(\s*):tableofcontents:/
instring=instring.gsub(/^(\s*):tableofcontents:/,"TOCTOCTOCTOC")
@@filefortoc.push(filename)
end
instring
end
def process_tex_weblinks(instring)
ostring=instring.gsub(/(\\*)\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 = " \n Up\n "
end
prevtext = "Previous" if prev
nexttext = "Next" if nex
toctext = "ToC" if @@filefortoc[0]
s = <
END
end
def add_links(filename,prev,nex)
navi = navigation_string(prev,nex,filename)
instring = open(filename,"r"){|f| f.gets(nil)}
ostring= navi+ "\n" +instring +navi+ "\n"
open(filename,"w"){|f| f.puts(ostring)}
end
@@stylefilename = ".acsdoc-style.css"
def htmlheader(name)
<<-END
#{prevtext}
#{toctext}
#{toptext}
#{nexttext}
Contents
\n"
currentlevel+= 1
end
while x[1]