]
+ @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
+# @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
+
+ if Options.instance.mathml
+ # TeX inline form
+ @markup.add_special(/(\$(.*?)[^\\]\$)/im, :TEXINLINE)
+
+ # TeX inline delimiter
+ @markup.add_special(/(\\\$)/im, :TEXINLINEDELIMITER)
+
+ # TeX block form
+ @markup.add_special(/(\\\[(.+?)\\\])/im, :TEXBLOCK)
+ end
+
+ end
+ unless defined? @html_formatter
+ @html_formatter = TexParser.new(self.path, self)
+ end
+
+ # Convert leading comment markers to spaces, but only
+ # if all non-blank lines have them
+
+ if str =~ /^(?>\s*)[^\#]/
+ content = str
+ else
+ content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
+ end
+
+ block_exceptions = []
+ if Options.instance.mathml
+ block_exceptions << {
+ 'name' => :texblockform,
+ 'start' => Regexp.new("^\\\\\\["),
+ 'end' => Regexp.new("\\\\\\]$"),
+ 'replaces' => []
+ }
+ block_exceptions[0]['replaces'] << {
+ 'from' => Regexp.new("\\\\\\\\"),
+ 'to' => "\\\\\\\\\\\\\\\\",
+ }
+ end
+
+ res = @markup.convert(content, @html_formatter, block_exceptions)
+ if remove_para
+ res.sub!(/^/, '')
+ res.sub!(/<\/p>$/, '')
+ end
+ res
+ end
+ end
+
+ class XHTMLGenerator < HTMLGenerator
+
+ def XHTMLGenerator.gen_url(path, target)
+ Generators::HTMLGenerator.gen_url(path, target)
+ end
+ def XHTMLGenerator.for(options)
+ AllReferences::reset
+ HtmlMethod::reset
+
+ if options.all_one_file
+ XHTMLGeneratorInOne.new(options)
+ else
+ XHTMLGenerator.new(options)
+ end
+ end
+
+ def generate(toplevels)
+ super(toplevels)
+ copy_xsls
+ end
+
+ private
+
+ def build_indices
+ @toplevels.each do |toplevel|
+ @files << XHtmlFile.new(toplevel, @options, FILE_DIR)
+ end
+
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ build_class_list(cls, @files[0], CLASS_DIR)
+ end
+ end
+
+ def build_class_list(from, html_file, class_dir)
+ @classes << XHtmlClass.new(from, html_file, class_dir, @options)
+ from.each_classmodule do |mod|
+ build_class_list(mod, html_file, class_dir)
+ end
+ end
+
+ def gen_method_index
+ gen_an_index(XHtmlMethod.all_methods, 'Methods',
+ RDoc::Page::METHOD_INDEX,
+ "fr_method_index.html")
+ end
+
+ def gen_an_index(collection, title, template, filename)
+ template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
+ res = []
+ collection.sort.each do |f|
+ if f.document_self
+ res << { "href" => f.path, "name" => f.index_name }
+ end
+ end
+
+ values = {
+ "entries" => res,
+ 'list_title' => CGI.escapeHTML(title),
+ 'index_url' => main_url,
+ 'charset' => @options.charset,
+ 'style_url' => style_url('', @options.css),
+ 'mathml_xsl_url' => style_url('', "mathml.xsl"),
+ }
+
+ File.open(filename, "w") do |f|
+ template.write_html_on(f, values)
+ end
+ end
+
+ def copy_xsls
+ xsl_files = ["mathml.xsl", "pmathmlcss.xsl", "ctop.xsl", "pmathml.xsl"]
+ xsl_dir = "rdoc/generators/template/xhtml"
+ hit = 0
+ $LOAD_PATH.each{ |path|
+ hit = 0
+ xsl_files.each{ |file|
+ hit += 1 if File.exist?(File.join(path, xsl_dir, file))
+ }
+ if hit >= 4
+ xsl_files.each{ |file|
+ File.copy(File.join(path, xsl_dir, file), "./")
+ }
+ break
+ else
+ hit = 0
+ end
+ }
+ if hit < 4
+ $stderr.puts "Couldn't find xsl files (#{xsl_files.join(', ')})\n"
+ exit
+ end
+ end
+
+ end
+
+ class XHTMLGeneratorInOne < HTMLGeneratorInOne
+ def build_class_list(from, html_file, class_dir)
+ @classes << XHtmlClass.new(from, html_file, class_dir, @options)
+ from.each_classmodule do |mod|
+ build_class_list(mod, html_file, class_dir)
+ end
+ end
+
+ def build_indices
+ @toplevels.each do |toplevel|
+ @files << XHtmlFile.new(toplevel, @options, FILE_DIR)
+ end
+
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ build_class_list(cls, @files[0], CLASS_DIR)
+ end
+ end
+
+ def gen_method_index
+ gen_an_index(XHtmlMethod.all_methods, 'Methods')
+ end
+ end
+
+ class XHtmlClass < HtmlClass
+ def value_hash
+ super
+ @values["mathml_xsl_url"] = style_url(path, "mathml.xsl")
+ @values
+ end
+
+ def collect_methods
+ list = @context.method_list
+ unless @options.show_all
+ list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
+ end
+ @methods = list.collect {|m| XHtmlMethod.new(m, self, @options) }
+ end
+
+ end
+
+ class XHtmlFile < HtmlFile
+ def value_hash
+ super
+ @values["mathml_xsl_url"] = style_url(path, "mathml.xsl")
+ @values
+ end
+
+ def collect_methods
+ list = @context.method_list
+ unless @options.show_all
+ list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
+ end
+ @methods = list.collect {|m| XHtmlMethod.new(m, self, @options) }
+ end
+
+ end
+
+ class XHtmlMethod < HtmlMethod
+ def create_source_code_file(code_body)
+ template_regexp = Regexp.new("\\." + @options.template + "$")
+ meth_path = @html_class.path.sub(template_regexp, '.src')
+ File.makedirs(meth_path)
+ file_path = File.join(meth_path, @seq) + '.' + @options.template
+
+ template = TemplatePage.new(RDoc::Page::SRC_PAGE)
+ File.open(file_path, "w") do |f|
+ values = {
+ 'title' => CGI.escapeHTML(index_name),
+ 'code' => code_body,
+ 'style_url' => style_url(file_path, @options.css),
+ 'mathml_xsl_url' => style_url('', "mathml.xsl"),
+ 'charset' => @options.charset
+ }
+ template.write_html_on(f, values)
+ end
+ XHTMLGenerator.gen_url(path, file_path)
+ end
+ end
+
+end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/install.rb ../rdoc-f95-20070109/install.rb
--- ruby-1.8.5-p12/lib/rdoc/install.rb 1970-01-01 09:00:00.000000000 +0900
+++ ../rdoc-f95-20070109/install.rb 2006-08-10 17:31:30.000000000 +0900
@@ -0,0 +1,178 @@
+require 'rbconfig'
+require 'find'
+require 'ftools'
+require 'optparse'
+
+include Config
+
+$ruby = CONFIG['ruby_install_name']
+
+##
+# Install a binary file. We patch in on the way through to
+# insert a #! line. If this is a Unix install, we name
+# the command (for example) 'rdoc' and let the shebang line
+# handle running it. Under windows, we add a '.rb' extension
+# and let file associations to their stuff
+#
+
+def installBIN(from, opfile)
+
+ tmp_dir = nil
+ for t in [".", "/tmp", "c:/temp", $bindir]
+ stat = File.stat(t) rescue next
+ if stat.directory? and stat.writable?
+ tmp_dir = t
+ break
+ end
+ end
+
+ fail "Cannot find a temporary directory" unless tmp_dir
+ tmp_file = File.join(tmp_dir, "_tmp")
+
+
+ File.open(from) do |ip|
+ File.open(tmp_file, "w") do |op|
+ ruby = File.join($realbindir, $ruby)
+# op.puts "#!#{ruby}"
+ op.write ip.read
+ end
+ end
+
+ opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
+ File::install(tmp_file, File.join($bindir, opfile), 0755, true)
+ File::unlink(tmp_file)
+end
+
+# Main Program
+
+opt = OptionParser.new
+OPTS = {}
+opt.summary_width = 23
+opt.summary_indent = ''*1
+opt.on('--bindir=VAL',
+ 'Directory to which the executable file is installed') \
+ {|v| $bindir = v.to_s}
+opt.on('--binname=VAL',
+ 'Name of the executable file (default name is "rdoc")') \
+ {|v| $binname = v.to_s}
+opt.on('--libdir=VAL',
+ 'Directory to which the libraries are installed') \
+ {|v| $libdir = v.to_s}
+opt.on('--help', 'Show help message') {|v| OPTS[:help] = v}
+
+opt.parse!(ARGV)
+
+$bindir = File.expand_path($bindir) if $bindir
+$binname ||= "rdoc"
+$libdir = File.expand_path($libdir) if $libdir
+
+install_opt = ""
+install_opt = "--libdir=#{$libdir}" if $libdir
+
+if $libdir
+ $sitedir = $libdir
+else
+ $sitedir = CONFIG["sitelibdir"]
+ unless $sitedir
+ version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
+ $libdir = File.join(CONFIG["libdir"], "ruby", version)
+ $sitedir = $:.find {|x| x =~ /site_ruby/}
+ if !$sitedir
+ $sitedir = File.join($libdir, "site_ruby")
+ elsif $sitedir !~ Regexp.quote(version)
+ $sitedir = File.join($sitedir, version)
+ end
+ end
+end
+
+$bindir ||= CONFIG["bindir"]
+$realbindir = $bindir
+
+bindir = CONFIG["bindir"]
+
+rdoc_dest = File.join($sitedir, "rdoc")
+dot_dest = File.join(rdoc_dest, "dot")
+rdoc_generators = File.join(rdoc_dest, "generators")
+rdoc_templates = File.join(rdoc_generators, "template")
+rdoc_parsers = File.join(rdoc_dest, "parsers")
+rdoc_ri = File.join(rdoc_dest, "ri")
+
+# help message
+if ARGV[0] || OPTS[:help]
+ print <<-HELP
+
+ This ruby script installs libraries to \"#{rdoc_dest}\",
+ and executables to \"#{$bindir}/#{$binname}\". (See \"rbconfig.rb\")
+
+ If you want to install other directory, use following options.
+
+ OPTIONS: \n#{opt.to_a[1..-1].join("")}
+
+HELP
+ exit
+end
+
+# make directories
+File::makedirs(rdoc_dest,
+ dot_dest,
+ rdoc_generators,
+ rdoc_templates,
+ rdoc_parsers,
+ rdoc_ri,
+ true)
+
+File::chmod(0755, rdoc_dest)
+
+
+
+# The library files
+files = %w{
+ code_objects.rb
+ generators/*_generator.rb
+ options.rb
+ parsers/parserfactory.rb
+ parsers/parse_*.rb
+ template.rb
+ tokenstream.rb
+ diagram.rb
+ rdoc.rb
+ dot/dot.rb
+ ri/ri_*.rb
+}.collect {|f| Dir.glob(f)}.flatten
+
+for template in ["chm", "html", "xml", "xhtml"]
+ File::makedirs(File.join(rdoc_templates, template), true)
+ files.concat Dir.glob("generators/template/#{template}/*.rb")
+ files.concat Dir.glob("generators/template/#{template}/*.xsl")
+end
+
+for aFile in files
+ File::install(aFile, File.join(rdoc_dest, aFile), 0644, true)
+end
+
+# and the executable
+
+installBIN("rdoc", $binname)
+
+# Temporary - we used to install html_generator in the rdoc
+# directory, but now it's moved
+
+File.unlink(File.join(rdoc_dest, "html_generator.rb")) rescue 1;
+
+# and we used to have the templates under html_template
+template = File.join(rdoc_dest, "generators", "html_template")
+File.unlink(File.join(template, "standard.rb")) rescue 1;
+File.unlink(File.join(template, "kilmer.rb")) rescue 1;
+
+# and then they were in template/ ...
+template = File.join(rdoc_dest, "generators", "template")
+File.unlink(File.join(template, "standard.rb")) rescue 1;
+File.unlink(File.join(template, "kilmer.rb")) rescue 1;
+File.unlink(File.join(template, "xml.rb")) rescue 1;
+File.unlink(File.join(template, "rdf.rb")) rescue 1;
+
+
+# 'Markup' will eventually be a separate package, but
+# for now we'll install it automatically
+
+Dir.chdir("markup") && system("#$ruby install.rb #{install_opt}")
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/markup/.document ../rdoc-f95-20070109/markup/.document
--- ruby-1.8.5-p12/lib/rdoc/markup/.document 2006-08-05 07:00:25.000000000 +0900
+++ ../rdoc-f95-20070109/markup/.document 1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-simple_markup
-simple_markup.rb
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/markup/install.rb ../rdoc-f95-20070109/markup/install.rb
--- ruby-1.8.5-p12/lib/rdoc/markup/install.rb 1970-01-01 09:00:00.000000000 +0900
+++ ../rdoc-f95-20070109/markup/install.rb 2005-11-15 19:46:27.000000000 +0900
@@ -0,0 +1,58 @@
+require 'rbconfig'
+require 'find'
+require 'ftools'
+require 'optparse'
+
+include Config
+
+opt = OptionParser.new
+libdir = nil
+opt.on('--libdir=VAL') {|v| libdir = v}
+opt.parse!(ARGV)
+
+libdir = File.expand_path(libdir) if libdir
+
+if libdir
+ sitedir = libdir
+else
+ sitedir = CONFIG["sitelibdir"]
+ unless sitedir
+ version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
+ libdir = File.join(CONFIG["libdir"], "ruby", version)
+ sitedir = $:.find {|x| x =~ /site_ruby/}
+ if !sitedir
+ sitedir = File.join(libdir, "site_ruby")
+ elsif sitedir !~ Regexp.quote(version)
+ sitedir = File.join(sitedir, version)
+ end
+ end
+end
+
+unless /^\// =~ sitedir.strip
+ sitedir = File.join("..", sitedir)
+end
+
+if !File.directory?(sitedir)
+ $stderr.puts "Cannot find sitedir #{sitedir}"
+ exit 1
+end
+
+rdoc_dest = File.join(sitedir, "rdoc")
+
+dest = File.join(rdoc_dest, "markup")
+
+File.mkpath(dest, true)
+
+Find.find("simple_markup.rb",
+ "simple_markup",
+ "sample",
+ "test") do |fname|
+ if File.directory?(fname)
+ next if fname =~ /CVS/
+ File.mkpath(File.join(dest, fname), true)
+ else
+ next unless fname =~ /\.rb$/
+ next if fname =~ /install.rb$/
+ File.install(fname, File.join(dest, fname), 0444, true)
+ end
+end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/markup/simple_markup/inline.rb ../rdoc-f95-20070109/markup/simple_markup/inline.rb
--- ruby-1.8.5-p12/lib/rdoc/markup/simple_markup/inline.rb 2006-06-27 05:44:13.000000000 +0900
+++ ../rdoc-f95-20070109/markup/simple_markup/inline.rb 2006-11-20 02:56:49.000000000 +0900
@@ -295,7 +295,7 @@
# skip leading invisible text
i = 0
- i += 1 while i < str_len and @str[i].zero?
+ i += 1 while i < str_len and @str[i] == "\0"
start_pos = i
# then scan the string, chunking it on attribute changes
@@ -321,7 +321,7 @@
# move on, skipping any invisible characters
begin
i += 1
- end while i < str_len and @str[i].zero?
+ end while i < str_len and @str[i] == "\0"
end
# tidy up trailing text
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/markup/simple_markup/mathml_wrapper.rb ../rdoc-f95-20070109/markup/simple_markup/mathml_wrapper.rb
--- ruby-1.8.5-p12/lib/rdoc/markup/simple_markup/mathml_wrapper.rb 1970-01-01 09:00:00.000000000 +0900
+++ ../rdoc-f95-20070109/markup/simple_markup/mathml_wrapper.rb 2007-01-05 21:02:13.000000000 +0900
@@ -0,0 +1,61 @@
+# This class is MathML module wrapper.
+# If MathML module can not be loaded, methods in this module return
+# raw argument without modification.
+
+class MathMLWrapper
+
+ # Mathml library name
+ MATHML_NAME= "mathml"
+
+ # $LOAD_PATH/MACRO_PATH/* files are parsed as TeX macro
+ MACRO_PATH = "#{MATHML_NAME}/macro"
+
+ @@macro_input_flag = false
+
+ def initialize
+ @load_error_flag = false
+ begin
+ require MATHML_NAME
+ if !@@macro_input_flag
+ @@mathml_formula_macro = MathML::LaTeX::Parser.new
+ @@macro_input_flag = true
+ $LOAD_PATH.each{ |lpath|
+ macro_files = Dir::glob(File.join(lpath, MACRO_PATH, "*"))
+ macro_files.each{ |mfile|
+ if File.file?(mfile)
+ File.open(mfile, "r" ) { |io|
+ io.each{ |line|
+ begin
+ @@mathml_formula_macro.macro.parse(line)
+ rescue MathML::LaTeX::ParseError
+ macroerrormsg = $!.to_s
+ rescue
+ macroerrormsg = $!.to_s
+ end
+ if macroerrormsg
+ $stderr.puts "Warning: in #{mfile}, following TeX macro causes #{macroerrormsg.to_s}\n\n",
+ " #{line}\n\n"
+ end
+ }
+ }
+ end
+ }
+ }
+ end
+ rescue LoadError
+ @load_error_flag = true
+ end
+ end
+ def parse(formula, block=false)
+ return formula if @load_error_flag
+ mathml_formula = @@mathml_formula_macro
+ begin
+ mathml_formula_str = mathml_formula.parse(formula, block).to_s
+ rescue MathML::LaTeX::ParseError
+ return formula, 1
+ rescue
+ return formula, 1
+ end
+ return mathml_formula_str, 0
+ end
+end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/markup/simple_markup.rb ../rdoc-f95-20070109/markup/simple_markup.rb
--- ruby-1.8.5-p12/lib/rdoc/markup/simple_markup.rb 2005-10-25 02:13:42.000000000 +0900
+++ ../rdoc-f95-20070109/markup/simple_markup.rb 2006-08-14 16:13:50.000000000 +0900
@@ -207,6 +207,7 @@
def initialize
@am = AttributeManager.new
@output = nil
+ @block_exceptions = nil
end
##
@@ -246,11 +247,12 @@
# all lines in a paragraph). We then invoke the output formatter
# using a Visitor to display the result
- def convert(str, op)
+ def convert(str, op, block_exceptions=nil)
@lines = Lines.new(str.split(/\r?\n/).collect { |aLine|
Line.new(aLine) })
return "" if @lines.empty?
@lines.normalize
+ @block_exceptions = block_exceptions
assign_types_to_lines
group = group_lines
# call the output formatter to handle the result
@@ -270,8 +272,9 @@
#
def assign_types_to_lines(margin = 0, level = 0)
-
+ now_blocking = false
while line = @lines.next
+
if line.isBlank?
line.stamp(Line::BLANK, level)
next
@@ -291,6 +294,37 @@
active_line = text[margin..-1]
+ #
+ # block_exceptions checking
+ #
+ if @block_exceptions
+ if now_blocking
+ line.stamp(Line::PARAGRAPH, level)
+ @block_exceptions.each{ |be|
+ if now_blocking == be['name']
+ be['replaces'].each{ |rep|
+ line.text.gsub!(rep['from'], rep['to'])
+ }
+ end
+ if now_blocking == be['name'] && line.text =~ be['end']
+ now_blocking = false
+ break
+ end
+ }
+ next
+ else
+ @block_exceptions.each{ |be|
+ if line.text =~ be['start']
+ now_blocking = be['name']
+ line.stamp(Line::PARAGRAPH, level)
+ break
+ end
+ }
+ next if now_blocking
+ end
+ end
+
+
# Rules (horizontal lines) look like
#
# --- (three or more hyphens)
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/options.rb ../rdoc-f95-20070109/options.rb
--- ruby-1.8.5-p12/lib/rdoc/options.rb 2004-11-21 00:02:56.000000000 +0900
+++ ../rdoc-f95-20070109/options.rb 2006-11-14 05:27:56.000000000 +0900
@@ -2,6 +2,7 @@
# object to be queried for option values
require "rdoc/ri/ri_paths"
+require "pathname"
class Options
@@ -56,6 +57,9 @@
# should we draw fileboxes in diagrams
attr_reader :fileboxes
+ # TeX formatted formula is converted to MathML
+ attr_reader :mathml
+
# include the '#' at the front of hyperlinked instance method names
attr_reader :show_hash
@@ -91,6 +95,12 @@
# multiple files
attr_reader :promiscuous
+ # scan newer sources than the flag file if true.
+ attr_reader :force_update
+
+ # The case of names of classes or modules or methods are ignored
+ attr_reader :ignore_case
+
module OptionList
OPTION_LIST = [
@@ -116,6 +126,12 @@
"option correctly. Dot is available from\n"+
"http://www.research.att.com/sw/tools/graphviz/" ],
+ [ "--mathml", "-l", nil,
+ "TeX formatted formula is converted to MathML.\n" +
+ "You need mathml.rb V0.6b to use the --mathml\n" +
+ "option correctly. mathml.rb V0.6b is available from\n"+
+ "http://www.hinet.mydns.jp/~hiraku/data/files/mathml-0.6b.tar.gz" ],
+
[ "--exclude", "-x", "pattern",
"do not process files or directories matching\n" +
"pattern. Files given explicitly on the command\n" +
@@ -134,6 +150,10 @@
"Silently discarded if --diagram is not given\n" +
"Experimental." ],
+ [ "--force-update", "-U", nil,
+ "forces to scan all sources even if newer than\n" +
+ "the flag file." ],
+
[ "--fmt", "-f", "format name",
"set the output formatter (see below)" ],
@@ -143,6 +163,10 @@
[ "--help-output", "-O", nil,
"explain the various output options" ],
+ [ "--ignore-case", "-C", nil,
+ "The case of names of classes or modules\n" +
+ "or methods are ignored" ],
+
[ "--image-format", "-I", "gif/png/jpg/jpeg",
"Sets output image format for diagrams. Can\n" +
"be png, gif, jpeg, jpg. If this option is\n" +
@@ -320,6 +344,8 @@
These files will appear in the directory given by the --op
option (doc/ by default).
+ - XHTML output is the same as HTML.
+
- XML output by default is written to standard output. If a
--opname option is given, the output will instead be written
to a file with that name in the output directory.
@@ -354,6 +380,7 @@
@title = nil
@template = nil
@diagram = false
+ @mathml = false
@fileboxes = false
@show_hash = false
@image_format = 'png'
@@ -363,6 +390,8 @@
@include_line_numbers = false
@extra_accessor_flags = {}
@promiscuous = false
+ @force_update = false
+ @ignore_case = false
@css = nil
@webcvs = nil
@@ -392,17 +421,30 @@
when "--main" then @main_page = arg
when "--merge" then @merge = true
when "--one-file" then @all_one_file = @inline_source = true
- when "--op" then @op_dir = arg
when "--opname" then @op_name = arg
when "--promiscuous" then @promiscuous = true
when "--quiet" then @quiet = true
when "--show-hash" then @show_hash = true
- when "--style" then @css = arg
when "--template" then @template = arg
when "--title" then @title = arg
when "--webcvs" then @webcvs = arg
+ when "--ignore-case" then @ignore_case = true
- when "--accessor"
+ when "--op"
+ if @css && ! (%r{^(https?:/)?/} =~ @css)
+ @css = relative_str(File.join(arg, "."),
+ relative_str(File.join(@op_dir.split("/").fill(".."), ".."), @css))
+ end
+ @op_dir = arg
+
+ when "--style"
+ if %r{^(https?:/)?/} =~ arg
+ @css = arg
+ else
+ @css = relative_str(File.join(@op_dir, "."), arg)
+ end
+
+ when "--accessor"
arg.split(/,/).each do |accessor|
if accessor =~ /^(\w+)(=(.*))?$/
accessors << $1
@@ -417,6 +459,13 @@
when "--fileboxes"
@fileboxes = true if @diagram
+ when "--mathml"
+ check_mathml
+ @mathml = true
+ @generator_name = 'xhtml'
+ @template = @generator_name
+ setup_generator(generators)
+
when "--fmt"
@generator_name = arg.downcase
setup_generator(generators)
@@ -462,6 +511,9 @@
OptionList.error("Unknown extension .#{old} to -E")
end
+ when "--force-update"
+ @force_update = true
+
when "--version"
puts VERSION_STRING
exit
@@ -557,7 +609,49 @@
# exit
end
end
-
+
+ # Check that the right version of 'mathml.rb' is available.
+ #
+ def check_mathml
+ not_found = true
+ fpath = ""
+ $LOAD_PATH.each{ |lpath|
+ fpath = File.join(lpath, "mathml.rb")
+ if File.exist?(fpath)
+ not_found = false
+ break
+ end
+ }
+
+ if not_found
+ $stderr.puts <<-"EOT"
+You need the 'mathml.rb' to convert TeX to MathML.
+(see http://www.hinet.mydns.jp/~hiraku/hiki/, but JAPANESE only.
+ You can download 'mathml.rb' directly from
+ http://www.hinet.mydns.jp/~hiraku/data/files/mathml-0.6b.tar.gz)
+
+EOT
+ exit
+ end
+
+ contents = File.open(fpath, "r") {|f| f.read}
+ num = 1
+ if !(contents =~ /^\s*module\s+MathML/) ||
+ !(contents =~ /^\s*module\s+LaTeX/) ||
+ !(contents =~ /^\s*class\s+Parser/) ||
+ !(contents =~ /^\s*def\s+parse/)
+ $stderr.puts <<-"EOT"
+You need the 'mathml.rb' V0.6b or later to use.
+(see http://www.hinet.mydns.jp/~hiraku/hiki/, but JAPANESE only.
+ You can download 'mathml.rb' directly from
+ http://www.hinet.mydns.jp/~hiraku/data/files/mathml-0.6b.tar.gz)
+
+EOT
+
+ exit
+ end
+ end
+
# Check that the files on the command line exist
def check_files
@@ -572,4 +666,19 @@
exit(1)
end
+ def relative_str(from, target)
+ from_dir = File.dirname(from)
+ target_dir = File.dirname(target)
+ target_base = File.basename(target)
+
+ from_ab_path = Pathname.new(File.expand_path(from_dir))
+ target_ab_path = Pathname.new(File.expand_path(target_dir))
+
+ target_re_path = target_ab_path.relative_path_from(from_ab_path)
+
+ result = target_re_path.to_s + "/" + target_base
+
+ return result
+ end
+
end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/parsers/parse_c.rb ../rdoc-f95-20070109/parsers/parse_c.rb
--- ruby-1.8.5-p12/lib/rdoc/parsers/parse_c.rb 2006-08-23 18:23:11.000000000 +0900
+++ ../rdoc-f95-20070109/parsers/parse_c.rb 2006-11-09 02:05:45.000000000 +0900
@@ -167,8 +167,9 @@
extend ParserFactory
- parse_files_matching(/\.(c|cc|cpp|CC)$/)
+ parse_files_matching(/\.(c|cc|cpp|CC|cxx)$/)
+ @@enclosure_classes = {}
@@known_bodies = {}
# prepare to parse a C file
@@ -230,7 +231,7 @@
parent_name = @known_classes[parent] || parent
if in_module
- enclosure = @classes[in_module]
+ enclosure = @classes[in_module] || @@enclosure_classes[in_module]
unless enclosure
if enclosure = @known_classes[in_module]
handle_class_module(in_module, (/^rb_m/ =~ in_module ? "module" : "class"),
@@ -258,6 +259,7 @@
find_class_comment(cm.full_name, cm)
@classes[var_name] = cm
+ @@enclosure_classes[var_name] = cm
@known_classes[var_name] = cm.full_name
end
@@ -267,7 +269,7 @@
def find_class_comment(class_name, class_meth)
comment = nil
if @body =~ %r{((?>/\*.*?\*/\s+))
- (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)}xmi
+ (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)\)}xmi
comment = $1
elsif @body =~ %r{Document-(class|module):\s#{class_name}\s*?\n((?>.*?\*/))}m
comment = $2
@@ -554,7 +556,7 @@
def find_body(meth_name, meth_obj, body, quiet = false)
case body
when %r{((?>/\*.*?\*/\s*))(?:static\s+)?VALUE\s+#{meth_name}
- \s*(\(.*?\)).*?^}xm
+ \s*(\([^)]*\))\s*\{.*?^\}}xm
comment, params = $1, $2
body_text = $&
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/parsers/parse_f95.rb ../rdoc-f95-20070109/parsers/parse_f95.rb
--- ruby-1.8.5-p12/lib/rdoc/parsers/parse_f95.rb 2006-07-10 10:57:22.000000000 +0900
+++ ../rdoc-f95-20070109/parsers/parse_f95.rb 2007-01-05 18:05:35.000000000 +0900
@@ -1,57 +1,239 @@
-#= parse_f95.rb - Fortran95 Parser
+#= parse_f95.rb - Fortran 90/95 Parser
+#
+#Note that Japanese and English are described in parallel.
+#
+#== ³µÍ×
+#
+#parse_f95.rb ¤Ï³ÈÄ¥»Ò¤¬ f90, F90, f95, F95 ¤Î¥Õ¥¡¥¤¥ë¤ò¹½Ê¸²òÀϤ·¤Þ¤¹.
+#¥½¡¼¥¹¥³¡¼¥É¤Ï Fortran 90 ¤â¤·¤¯¤Ï Fortran 95
+#µ¬³Ê¤Ë±è¤Ã¤Æµ½Ò¤µ¤ì¤Æ¤¤¤ë¤³¤È¤òÁ°Äó¤È¤·¤Æ¤¤¤Þ¤¹.
#
#== Overview
#
-#"parse_f95.rb" parses Fortran95 files with suffixes "f90", "F90", "f95"
-#and "F95". Fortran95 files are expected to be conformed to Fortran95
-#standards.
+#"parse_f95.rb" parses Fortran 90/95 files with suffixes "f90", "F90", "f95"
+#and "F95". These files are expected to conform to Fortran 90 or
+#Fortran 95 standards.
+#
+#== ½ñË¡
+#
+#´ðËÜŪ¤Ê½ñË¡¤Ï{Ruby ¤Î½ñË¡}[http://www.ruby-doc.org/stdlib/libdoc/rdoc/rdoc/index.html]
+#¤ÈƱÍͤǤ¹¤¬, ¥³¥á¥ó¥ÈÉô¤Ï '#' ¤Ç¤Ï¤Ê¤¯ '!' ¤Ç»Ï¤Þ¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤.
#
#== Rules
#
#Fundamental rules are same as that of the Ruby parser.
#But comment markers are '!' not '#'.
#
-#=== Correspondence between RDoc documentation and Fortran95 programs
+#=== RDoc ¥É¥¥å¥á¥ó¥Æ¡¼¥·¥ç¥ó¤È Fortran 90/95 ¥×¥í¥°¥é¥à¤È¤ÎÂбþ
#
-#"parse_f95.rb" parses main programs, modules, subroutines, functions,
-#derived-types, public variables, public constants,
-#defined operators and defined assignments.
-#These components are described in items of RDoc documentation, as follows.
+#parse_f95.rb ¤Ï Fortran 90/95 µ¬³Ê¤Ë¤ª¤±¤ë¸À¸ìÍ×ÁÇ, ¤¹¤Ê¤ï¤Á,
+#¼ç¥×¥í¥°¥é¥à, ¥â¥¸¥å¡¼¥ë, ¥µ¥Ö¥ë¡¼¥Á¥ó, ´Ø¿ô¤Î¾,
+#PUBLIC °À¤ò»ý¤ÄÊÑ¿ô¤äÄê¿ô, ¤½¤·¤ÆÍøÍѼÔÄêµÁ±é»»»Ò,
+#ÍøÍѼÔÄêµÁÂåÆþ¤ò¹½Ê¸²òÀϤ·¤Þ¤¹.
+#¤³¤ì¤é¤Î¸À¸ìÍ×ÁÇ¤Ï RDoc ¥É¥¥å¥á¥ó¥Æ¡¼¥·¥ç¥ó¤Î³Æ¹àÌܤË,
+#°Ê²¼¤Î¤è¤¦¤Ëµ½Ò¤µ¤ì¤Þ¤¹.
+#
+#Files :: ¥Õ¥¡¥¤¥ë (Ruby ¤ÈƱÍͤǤ¹)
+#Classes :: ¥â¥¸¥å¡¼¥ë, NAMELIST ÊÑ¿ô·²Ì¾¥ê¥¹¥È
+#Methods :: ¼ç¥×¥í¥°¥é¥à, ¥µ¥Ö¥ë¡¼¥Á¥ó, ´Ø¿ô, ÊÑ¿ô, Äê¿ô, ¹½Â¤¥Ç¡¼¥¿·¿,
+# ÍøÍѼÔÄêµÁ±é»»»Ò, ÍøÍѼÔÄêµÁÂåÆþ, NAMELIST ÊÑ¿ô·²Ì¾
+#Required files :: »²¾È¤¹¤ë¥â¥¸¥å¡¼¥ë¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë,
+# µÚ¤Ó»²¾È¤¹¤ë³°Éô´Ø¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Î¥ê¥¹¥È
+#Included Modules :: »²¾È¤¹¤ë¥â¥¸¥å¡¼¥ë¤Î¥ê¥¹¥È
+#Attributes :: ¹½Â¤¥Ç¡¼¥¿·¿¤Î¥ê¥¹¥È, »²¾È¤·³î¤Ä¤½¤ÎÁ´¤Æ¤Î¸À¸ìÍ×ÁǤò¸ø³«¤¹¤ë
+# ¥â¥¸¥å¡¼¥ë¤Î¥ê¥¹¥È
+#
+#'Methods' ¤Ë¥ê¥¹¥È¤µ¤ì¤ë¸À¸ìÍ×ÁÇ (¥µ¥Ö¥ë¡¼¥Á¥ó, ´Ø¿ô, ¡Ä) ¤Ï,
+#¥â¥¸¥å¡¼¥ëÆâ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¤¢¤ì¤Ð, 'Classes' ¤Î¹àÌܤ˵½Ò¤µ¤ì¤Þ¤¹.
+#¼ç¥×¥í¥°¥é¥àÆâ¤ÇÄêµÁ¤µ¤ì¤¿¤ê, ³°Éô¼ê³¤¤È¤·¤ÆÄêµÁ¤µ¤ì¤ë¾ì¹ç¤Ë¤Ï
+#'Files' ¤Î¹àÌܤ˵½Ò¤µ¤ì¤Þ¤¹.
+#¼ç¥×¥í¥°¥é¥à¼«ÂΤâ 'Files' ¤Î¹àÌܤ˵½Ò¤µ¤ì¤Þ¤¹.
+#
+#
+#=== Correspondence between RDoc documentation and Fortran 90/95 programs
+#
+#"parse_f95.rb" parses entities of Fortran 90/95 standards, or main programs,
+#modules, subroutines, functions, derived types, public variables,
+#public constants, defined operators and defined assignments.
+#These entities are described in items of RDoc documentation, as follows.
#
#Files :: Files (same as Ruby)
-#Classes :: Modules
-#Methods :: Subroutines, functions, variables, constants, derived-types, defined operators, defined assignments
-#Required files :: Files in which imported modules, external subroutines and external functions are defined.
+#Classes :: Modules, list of NAMELIST group names
+#Methods :: Main programs, subroutines, functions, variables, constants,
+# derived types, defined operators, defined assignments,
+# NAMELIST group names
+#Required files :: Files in which imported modules, external subroutines
+# and external functions are defined.
#Included Modules :: List of imported modules
-#Attributes :: List of derived-types, List of imported modules all of whose components are published again
+#Attributes :: List of derived types, List of imported modules all of
+# whose components are published again
#
-#Components listed in 'Methods' (subroutines, functions, ...)
+#Entities listed in 'Methods' (subroutines, functions, ...)
#defined in modules are described in the item of 'Classes'.
-#On the other hand, components defined in main programs or
+#On the other hand, defined in main programs or
#as external procedures are described in the item of 'Files'.
+#Main programs are described in the item of 'Files', too.
+#
+#=== ¹½Ê¸²òÀϤµ¤ì¤ë¸À¸ìÍ×ÁÇ
#
-#=== Components parsed by default
+#¼ç¥×¥í¥°¥é¥à¤ª¤è¤Ó, ³°Éô¤«¤é»²¾È¤¬²Äǽ¤Ê¥µ¥Ö¥ë¡¼¥Á¥ó,
+#´Ø¿ô, ÊÑ¿ô, Äê¿ô, ¹½Â¤¥Ç¡¼¥¿·¿, ÍøÍѼÔÄêµÁ±é»»»Ò,
+#ÍøÍѼÔÄêµÁÂåÆþ, NAMELIST ÊÑ¿ô·²Ì¾¤¬¥É¥¥å¥á¥ó¥È¤È¤·¤Æ½ÐÎϤµ¤ì¤Þ¤¹. --all
+#¥ª¥×¥·¥ç¥ó¤ò¤Ä¤±¤Æ rdoc ¤ò¼Â¹Ô¤¹¤ë¾ì¹ç¤Ë¤Ï, ³°Éô¤«¤é¤Î»²¾È¤¬µö²Ä¤µ¤ì¤Ê¤¤
+#¸À¸ìÍ×ÁǤâ´Þ¤á, Á´¤Æ¤¬½ÐÎϤµ¤ì¤Þ¤¹.
#
-#By default, documentation on public components (subroutines, functions,
-#variables, constants, derived-types, defined operators,
-#defined assignments) are generated.
-#With "--all" option, documentation on all components
+#
+#=== Parsed entities
+#
+#Documentation on public entities (main programs,
+#subroutines, functions, variables, constants,
+#derived types, defined operators,
+#defined assignments, NAMELIST group names) are generated.
+#With "--all" option, documentation on all entities
#are generated (almost same as the Ruby parser).
#
-#=== Information parsed automatically
+#
+#=== ¹½Ê¸²òÀϤµ¤ì¤ë¾ðÊó
+#
+#°Ê²¼¤Î¾ðÊó¤Ï, ¼«Æ°Åª¤Ë¹½Ê¸²òÀϤµ¤ì¤Æ¥³¥á¥ó¥ÈÉô¤È¤·¤Æ½ÐÎϤµ¤ì¤Þ¤¹.
+#
+#* ¥µ¥Ö¥ë¡¼¥Á¥ó, ´Ø¿ô¤Î°ú¿ô¤Î¥Ç¡¼¥¿·¿, °À
+#* ¸ø³«ÊÑ¿ô, ¸ø³«Äê¿ô¤Î¥Ç¡¼¥¿·¿, °À
+#* ¹½Â¤¥Ç¡¼¥¿·¿¤ÎÍ×ÁǤΥǡ¼¥¿·¿, ½é´üÃÍ, °À
+#* NAMELIST ʸ¤ÇÀë¸À¤µ¤ì¤ëÊÑ¿ô̾ʤӤÎÊÑ¿ô¤Î¥Ç¡¼¥¿·¿, ½é´üÃÍ, °À
+#
+#POINTER, TARGET, ALLOCATE, INTENT, OPTIONAL, SAVE °À¤Ï
+#·¿Àë¸Àʸ¤È¤ÏÊ̤ιԤǻØÄꤹ¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¤¬,
+#¤½¤ì¤é·¿Àë¸Àʸ¤ÈÊ̤˻ØÄꤵ¤ì¤ë°À¤Ï¹½Ê¸²òÀϤµ¤ì¤Þ¤»¤ó.
+#
+#INTERFACE ʸ¤Ë¤è¤Ã¤Æ, ¤¢¤ë¼ê³¤¤Ë´Ø¤·¤Æ¸ÄÊÌ̾¤È¤ÏÊ̤Î̾Á°¤ò
+#Àë¸À¤¹¤ë¾ì¹ç, ¤½¤ÎÊÌ̾¤â 'Methods' ¤ËÄɲä·¤Þ¤¹.
+#
+#»²¾È¤·¤¿Ê̤Υ⥸¥å¡¼¥ëÆâ¤Î¸ø³«¸À¸ìÍ×ÁÇ (¥µ¥Ö¥ë¡¼¥Á¥ó, ´Ø¿ô, ÊÑ¿ô¤Ê¤É)
+#¤ò¼«¿È¤Î¸À¸ìÍ×ÁǤȤ·¤Æ²þ¤á¤Æ¸ø³«¤¹¤ë¾ì¹ç,
+#¤½¤Î¸À¸ìÍ×ÁǤϼ«¿È¤Î¸À¸ìÍ×ÁǤȤ·¤Æ¥â¥¸¥å¡¼¥ë¤Î 'Methods' ¥ê¥¹¥È¤ËÄɲ䵤ì¤Þ¤¹.
+#
+#INTERFACE ʸ¤Ë¤è¤Ã¤Æ³°ÉôÉû¥×¥í¥°¥é¥à¤ò¼«¿È¤ÎÉû¥×¥í¥°¥é¥à¤È¤·¤Æ¸ø³«¤¹¤ë
+#¾ì¹ç, ¤½¤Î³°ÉôÉû¥×¥í¥°¥é¥à¤â¥â¥¸¥å¡¼¥ë¤Î 'Methods' ¥ê¥¹¥È¤ËÄɲä·¤Þ¤¹.
+#
+#
+#=== Parsed information
#
#The following information is automatically parsed.
#
-#* Types of arguments
-#* Types of variables and constants
-#* Types of variables in the derived types, and initial values
-#* NAMELISTs and types of variables in them, and initial values
+#* Data types and attributes of arguments of functions and subprograms
+#* Data types and attributes of public variables and public constants
+#* Data types, initial values, and attributes of variables in the derived types
+#* Data types, initial values, and attributes of variables declared in NAMELIST statement
+#
+#Only attributes specified in type declaration statements are parsed.
+#Attributes specified in POINTER, TARGET, ALLOCATE, INTENT, OPTIONAL, SAVE
+#statements are not parsed.
#
-#Aliases by interface statement are described in the item of 'Methods'.
+#Aliases declared by INTERFACE statements are described in the item
+#of 'Methods'.
#
-#Components which are imported from other modules and published again
+#Entities which are imported from other modules and published again
#are described in the item of 'Methods'.
#
+#
+#=== ¥³¥á¥ó¥ÈÉô¤Î½ñ¤Êý
+#
+#¥³¥á¥ó¥ÈÉô¤Ï°Ê²¼¤Î¤è¤¦¤Ëµ½Ò¤·¤Þ¤¹. ¸¶Â§Åª¤Ë¹ÔËö¤Þ¤¿¤Ï Fortran
+#¤Îʸ¤Î²¼Éô¤Ë¥³¥á¥ó¥È¤òµ½Ò¤·¤Þ¤¹. '!' ¤ò´Þ¤Þ¤Ê¤¤¹Ô¤¬¸½¤ì¤¿»þÅÀ¤Ç,
+#¥³¥á¥ó¥ÈÉô¤Ï½ªÎ»¤·¤¿¤È¸«¤Ê¤µ¤ì¤Þ¤¹.
+#Îã¤Ç¤Ï¥³¥á¥ó¥È¹Ô¤â¥¤¥ó¥Ç¥ó¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬, ¥¤¥ó¥Ç¥ó¥È¤¹¤ë¤³¤È¤Ï
+#ɬ¿Ü¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó.
+#
+# ! (¥Õ¥¡¥¤¥ë¤Î¹ÔƬ)
+# !
+# ! ¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥³¥á¥ó¥È¤Ï¤³¤³¤Ëµ½Ò¤·¤Þ¤¹
+# !
+# !--
+# ! "!--" ¤È "!++" ¤Ë°Ï¤Þ¤ì¤¿Éôʬ¤Ëµ½Ò¤µ¤ì¤¿¥³¥á¥ó¥È¤Ï
+# ! ¥É¥¥å¥á¥ó¥È¤ËÈ¿±Ç¤µ¤ì¤Þ¤»¤ó.
+# !++
+# !
+# module hogehoge
+# !
+# ! ¥â¥¸¥å¡¼¥ë (PROGRAM ʸ¤Î¾ì¹ç¤Ï¼ç¥×¥í¥°¥é¥à)
+# ! ¤ËÂФ¹¤ë¥³¥á¥ó¥È¤Ï¤³¤³¤Ëµ½Ò¤·¤Þ¤¹
+# !
+#
+# private
+#
+# logical :: a ! Èó¸ø³«ÊÑ¿ô
+# real, public :: b ! ¸ø³«ÊÑ¿ô
+# integer, parameter :: c = 0 ! ¸ø³«Äê¿ô
+#
+# public :: c
+# public :: MULTI_ARRAY
+# public :: hoge, foo
+#
+# type MULTI_ARRAY
+# !
+# ! ¹½Â¤¥Ç¡¼¥¿·¿¤ËÂФ¹¤ë¥³¥á¥ó¥È¤Ï¤³¤³¤Ëµ½Ò¤·¤Þ¤¹.
+# !
+# real, pointer :: var(:) =>null() ! ÊÑ¿ô¤ËÂФ¹¤ë¥³¥á¥ó¥È
+# integer :: num = 0
+# end type MULTI_ARRAY
+#
+# contains
+#
+# subroutine hoge( in, & ! ·Ñ³¹ÔÃæ¤Î¥³¥á¥ó¥È¤Ï̵»ë¤µ¤ì¤Þ¤¹.
+# & out )
+# !
+# ! ¥µ¥Ö¥ë¡¼¥Á¥ó¤ä´Ø¿ô¤ËÂФ¹¤ë¥³¥á¥ó¥È¤Ï¤³¤³¤Ëµ½Ò¤·¤Þ¤¹
+# !
+# character(*),intent(in):: in ! °ú¿ô¤ËÂФ¹¤ë¥³¥á¥ó¥È
+# character(*),intent(out),allocatable,target :: in
+# ! ²¼¤Î¹Ô¤Ëµ½Ò¤¹¤ë
+# ! ¤³¤È¤â²Äǽ¤Ç¤¹.
+#
+# character(32) :: file ! NAMELIST ʸ¤ÎÊÑ¿ô¤È¤·¤Æ¹½Ê¸²òÀϤµ¤ì¤Þ¤¹
+# integer :: id
+#
+# namelist /varinfo_nml/ file, id
+# !
+# ! NAMELIST ʸ¤Ë´Ø¤¹¤ë¾ðÊó¤Ï¤³¤³¤Ëµ½Ò¤·¤Þ¤¹. ÊÑ¿ô¤Ë
+# ! ´Ø¤¹¤ë¾ðÊó¤Ï, ÊÑ¿ôÄêµÁÉôʬ¤ò»²¾È¤·¤Þ¤¹.
+# !
+#
+# ....
+#
+# end subroutine hoge
+#
+# integer function foo( in )
+# !
+# ! ¤³¤ÎÉôʬ¤Ï¥³¥á¥ó¥È¤È¤·¤Æ¼±Ê̤µ¤ì¤Þ¤¹.
+#
+# ! '!' ¤Î´Ö³Ö¤ò¶õ¤±¤ë¤È°Ê¹ß¤Ï¥³¥á¥ó¥È¤È¤·¤Æ°·¤ï¤ì¤Þ¤»¤ó.
+# ! ¤Ä¤Þ¤ê¤³¤Î 2 ¹Ô¤Ï¥³¥á¥ó¥È¤È¤·¤Æ°·¤ï¤ì¤Þ¤»¤ó.
+# !
+# integer, intent(in):: inA ! ¥³¥á¥ó¥È¤È¤·¤Æ¼±Ê̤µ¤ì¤Þ¤¹
+#
+# ! ¥³¥á¥ó¥È¤È¤·¤Æ¼±Ê̤µ¤ì¤Þ¤»¤ó.
+#
+# end function foo
+#
+# subroutine hide( in, &
+# & out ) !:nodoc:
+# !
+# ! ¾åµ¤Î¤è¤¦¤Ë, SUBROUTINE ʸ¤ÎËöÈø¤Ë
+# ! '!:nodoc:' ¤Èµ½Ò¤¹¤ë¤³¤È¤Ç, ¤½¤Î¥µ¥Ö¥ë¡¼¥Á¥ó
+# ! ¤Ï¥É¥¥å¥á¥ó¥È¤ËÈ¿±Ç¤µ¤ì¤Ê¤¯¤Ê¤ê¤Þ¤¹.
+# ! ¤³¤Î»ØÄê¤Ï, ¼ç¥×¥í¥°¥é¥à, ¥â¥¸¥å¡¼¥ë, ¥µ¥Ö¥ë¡¼¥Á¥ó,
+# ! ´Ø¿ô, ÊÑ¿ô, Äê¿ô, ¹½Â¤¥Ç¡¼¥¿·¿, ÍøÍѼÔÄêµÁ±é»»»Ò,
+# ! ÍøÍѼÔÄêµÁÂåÆþ, »²¾È¤¹¤ë¥â¥¸¥å¡¼¥ë¤Î¥ê¥¹¥È (USE ʸ)
+# ! ¤ËÂФ·¤Æ͸ú¤Ç¤¹.
+# !
+#
+# ....
+#
+# end subroutine hide
+#
+# end module hogehoge
+#
#=== Format of comment blocks
#
#Comment blocks should be written as follows.
@@ -70,7 +252,7 @@
# !
# module hogehoge
# !
-# ! Comment blocks for the modules (or the programs).
+# ! Comment blocks for the modules (or the main programs).
# !
#
# private
@@ -85,7 +267,7 @@
#
# type MULTI_ARRAY
# !
-# ! Comment blocks for the derived-types.
+# ! Comment blocks for the derived types.
# !
# real, pointer :: var(:) =>null() ! Comments block for the variables.
# integer :: num = 0
@@ -108,7 +290,7 @@
#
# namelist /varinfo_nml/ file, id
# !
-# ! Comment blocks for the NAMELISTs.
+# ! Comment blocks for the NAMELIST statement.
# ! Information about variables are described above.
# !
#
@@ -131,12 +313,12 @@
# subroutine hide( in, &
# & out ) !:nodoc:
# !
-# ! If "!:nodoc:" is described at end-of-line in subroutine
+# ! If '!:nodoc:' is described at end-of-line in SUBROUTINE
# ! statement as above, the subroutine is ignored.
-# ! This assignment can be used to modules, subroutines,
-# ! functions, variables, constants, derived-types,
+# ! This assignment can be used to main programs, modules,
+# ! subroutines, functions, variables, constants, derived types,
# ! defined operators, defined assignments,
-# ! list of imported modules ("use" statement).
+# ! list of imported modules (USE statement).
# !
#
# ....
@@ -145,7 +327,190 @@
#
# end module hogehoge
#
-
+#
+#=== ÍøÍѼÔÄêµÁ±é»»»Ò, ÍøÍѼÔÄêµÁÂåÆþ¤Î¥¯¥í¥¹¥ê¥Õ¥¡¥ì¥ó¥¹
+#
+#ÍøÍѼÔÄêµÁ±é»»»Ò¤ÈÍøÍѼÔÄêµÁÂåÆþ (operator(*), assignment(=) Åù)
+#¤ò¥¯¥í¥¹¥ê¥Õ¥¡¥ì¥ó¥¹¤Ë¤è¤Ã¤Æ¥Ï¥¤¥Ñ¡¼¥ê¥ó¥¯²½¤¹¤ë¾ì¹ç¤Ë¤Ï,
+#'operator' ¤ä 'assignment' ¤ÎÀèƬ¤Ë '#' ¤òÉÕµ¤·¤Æ²¼¤µ¤¤.
+#¶ñÂÎŪ¤Ë¤Ï,
+#
+# #operator(*)
+# #assignment(=)
+#
+#¤Î¤è¤¦¤Ëµ½Ò¤·¤Æ¤¯¤À¤µ¤¤. ¾¤Î¥â¥¸¥å¡¼¥ëÆâ¤ÎÍøÍѼÔÄêµÁ±é»»»Ò¤ä
+#ÍøÍѼÔÄêµÁÂåÆþ¤Î¥¯¥í¥¹¥ê¥Õ¥¡¥ì¥ó¥¹¤Ë´Ø¤·¤Æ¤Ï, ½¾Íè¤ÈƱÍͤË
+#
+# module#operator(*)
+# module#assignment(=)
+#
+#¤Î¤è¤¦¤Ëµ½Ò¤·¤Æ¤¯¤À¤µ¤¤.
+#
+#=== Cross-reference of defined operators and defined assignments
+#
+#If you use cross-reference about defined operators and defined
+#assignments (for example, operator(*), assignment(=), etc.),
+#add '#' at the head of 'operator' or 'assignment'.
+#Practically, describe as follows.
+#
+# #operator(*)
+# #assignment(=)
+#
+#About defined operators and defined assignments about other modules,
+#describe as in the past.
+#
+# module#operator(*)
+# module#assignment(=)
+#
+#
+#
+#=== ¸À¸ìÍ×ÁǤÎɽ¼¨½ç½ø
+#
+#'Files' ¤ä 'Classes' ¤Î¹àÌܤËɽ¼¨¤µ¤ì¤ë¸À¸ìÍ×ÁǤÏ, ´ðËÜŪ¤Ë
+#ASCII ¥³¡¼¥É½ç¤ËʤӤޤ¹ (A-Z, a-z ¤Î½çÈÖ).
+#INTERFACE ʸ¤ÎÍøÍѤˤè¤Ã¤ÆƱ°ì¤Î 'Files' ¤Þ¤¿¤Ï 'Classes' ¤Ë
+#Ʊ̾¤Î°Û¤Ê¤ë¼ê³¤¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Ï, °ú¿ô¥¡¼¥ï¡¼¥É¤ª¤è¤Ó
+#¥³¥á¥ó¥ÈÉô¤ÎÆâÍƤˤè¤Ã¤Æ½ç½ø¤¬·è¤Þ¤ê¤Þ¤¹.
+#
+#¤â¤·¤âɽ¼¨¤Î½ç½ø¤òÌÀ¼¨Åª¤Ë»ØÄꤷ¤¿¤¤¾ì¹ç¤Ï, ¸À¸ìÍ×ÁǤÎÄêµÁʸ¤Î
+#¹ÔËö¤Ë '!:doc-priority 100:'
+#¤Î¤è¤¦¤Ê¥³¥á¥ó¥È¤òµ½Ò¤·¤Æ¤¯¤À¤µ¤¤.
+#100 ¤ÎÉôʬ¤ÏÍ¥Àè½ç°Ì¤òɽ¤¹¿ôÃͤǤ¹. Í¥Àè½ç°Ì¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹.
+#(¥Ç¥Õ¥©¥ë¥È¤Ï 50 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹).
+#
+#0 °Ê²¼¤ÎÀ°¿ô :: ¸À¸ìÍ×ÁǤò¾åÉô¤Ëɽ¼¨¤·¤Þ¤¹. Ãͤ¬¾®¤µ¤¤¤â¤Î¤Û¤ÉÍ¥ÀèŪ¤Ë¾åÉô¤Ëɽ¼¨¤µ¤ì¤Þ¤¹.
+#1 °Ê¾å 99 °Ê²¼¤ÎÀ°¿ô :: Ʊ̾¤Î¸À¸ìÍ×ÁǤÎÃæ¤Ç¤ÎÍ¥Àè½ç°Ì¤Ç¤¹. Ãͤ¬¾®¤µ¤¤¤â¤Î¤Û¤É¾åÉô¤Ëɽ¼¨¤µ¤ì¤Þ¤¹.
+#100 °Ê¾å¤ÎÀ°¿ô :: ¸À¸ìÍ×ÁǤò²¼Éô¤Ëɽ¼¨¤·¤Þ¤¹. Ãͤ¬Â礤¤¤â¤Î¤Û¤É²¼Éô¤Ëɽ¼¨¤µ¤ì¤Þ¤¹.
+#
+#°Ê²¼¤ËÎã¤ò¼¨¤·¤Þ¤¹. Îã¤Î¤è¤¦¤Ë 'doc-priority' ¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î
+#ɽ¼¨½ç½ø¤Ï
+#
+#* top_display, generic_name_procedures (¼ÂÂÎ: bottom_display),
+# generic_name_procedures (¼ÂÂÎ: top_display), bottom_display
+#
+#¤È¤Ê¤ê¤Þ¤¹. °ìÊý¤Ç, ¤â¤·¤â 'doc-priority' ¤¬»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤
+#¾ì¹ç¤Ë¤Ïɽ¼¨½ç½ø¤Ï
+#
+#* bottom_display, generic_name_procedures (¼ÂÂÎ: top_display),
+# generic_name_procedures (¼ÂÂÎ: bottom_display), top_display
+#
+#¤È¤Ê¤ê¤Þ¤¹. ¾Ü¤·¤¤Íýͳ¤Ï²¼µ¤ÎÎã¤ÎÃæ¤Ëµ½Ò¤µ¤ì¤ë¥³¥á¥ó¥È¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤.
+#
+# module sample1
+# :
+# interface generic_name_procedures
+# !
+# ! ¤³¤Î INTERFACE ʸ¤Ï top_display ¤È bottom_display ¤È¤òÁí¾Î̾¾Î
+# ! generic_name_procedures ¤È¤·¤ÆºÆÄêµÁ¤·¤Æ¤¤¤Þ¤¹.
+# !
+# ! RDoc ¤Ë¤ª¤Þ¤«¤»¤Ë¤¹¤ë¾ì¹ç, ¤³¤Î 2 ¤Ä¤Î
+# ! generic_name_procedures ¤Îɽ¼¨½ç½ø¤Ï¤Þ¤º°ú¿ô¥¡¼¥ï¡¼¥É
+# ! ¤Ë¤è¤Ã¤Æ·è¤Þ¤ê¤Þ¤¹. ½¾¤Ã¤Æ, °ú¿ô¥¡¼¥ï¡¼¥É¤¬ 'c' ¤Ç
+# ! »Ï¤Þ¤ë top_display ¤¬¼ÂÂΤǤ¢¤ë generic_name_procedures
+# ! ¤¬¾å¤Ëɽ¼¨¤µ¤ì¤Þ¤¹. (¼ÂÂΤμê³̾¤Ï¹Í褵¤ì¤Þ¤»¤ó).
+# !
+# ! ²¼µ¤Ç¤Ï 'doc-priority' ¤¬»ØÄꤷ¤Æ¤¢¤ë¤¿¤á, ¿ôÃͤµ¤¤
+# ! bottom_display ¤¬¼ÂÂΤǤ¢¤ë generic_name_procedures ¤ÎÊý¤¬
+# ! ¾å¤Ëɽ¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹.
+# !
+# module procedure bottom_display !:doc-priority 40:
+# module procedure top_display !:doc-priority 60:
+# end interface
+# :
+# contains
+# :
+# subroutine top_display(char) !:doc-priority -10:
+# !
+# ! ËÜÍè¤Ï²¼µ¤Î bottom_display ¤è¤ê¤â²¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¤¬,
+# ! Í¥ÀèÅÙ¤ò -10 ¤ËÀßÄꤷ¤Æ¤¤¤ë¤¿¤á, ¾åÉô¤Ëɽ¼¨¤µ¤ì¤Þ¤¹.
+# !
+# ....
+# end subroutine top_display
+#
+# subroutine bottom_display(real) !:doc-priority 110:
+# !
+# ! ËÜÍè¤Ï¾åµ¤Î top_display ¤è¤ê¤â¾å¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¤¬,
+# ! Í¥ÀèÅÙ¤ò 110 ¤ËÀßÄꤷ¤Æ¤¤¤ë¤¿¤á, ²¼Éô¤Ëɽ¼¨¤µ¤ì¤Þ¤¹.
+# !
+# ....
+# end subroutine bottom_display
+# :
+# end module sample1
+#
+#
+#=== The sequence of displayed entities
+#
+#Entities listed in 'Files' and 'Classes' are displayed in
+#ASCII order usually (in particular, A...Z, a...z, ...).
+#Entities with the same names declared by INTERFACE statements
+#are ordered by argument keywords or contents in comment blocks.
+#
+#If you want to order entities manually, describe a comment
+#like '!:doc-priority 100:' at end-of-line in
+#the statement of the entities.
+#`100` represents priority. Priority level is specified as follows.
+#(Default number is '50').
+#
+#Integer of 0 or less :: Entities are displayed at the head of the document. Entities with more small number go upstairs.
+#Integer from 1 to 99 :: Priority within entities with the same names. Entities with more small number go upstairs.
+#Integer of 100 or more :: Entities are displayed at the foot of the document. Entities with more large number go downstairs.
+#
+#An example is showed as follows. When 'doc-priority' is written as
+#a following example, a sequence of displayed entities is
+#
+#* top_display, generic_name_procedures (an original entity: bottom_display),
+# generic_name_procedures (an original entity: top_display), bottom_display.
+#
+#On the other hand, if 'doc-priority' is not written, the sequence become
+#
+#* bottom_display, generic_name_procedures (an original entity: top_display),
+# generic_name_procedures (an original entity: bottom_display), top_display.
+#
+#The details are given in the following example.
+#
+# module sample1
+# :
+# interface generic_name_procedures
+# !
+# ! This INTERFACE statement redefines "top_display" and
+# ! "bottom_display" as an generic name "generic_name_procedures".
+# !
+# ! RDoc orders two "generic_name_procedures" by argument keywords
+# ! essentially. Therefore "generic_name_procedures" that
+# ! the original entity is "top_display" is displayed above because
+# ! an argument keyword of the procedure begins 'c'.
+# ! (The name of the original entity is ignored).
+# !
+# ! In the following example, because 'doc-priority' is written,
+# ! "generic_name_procedures" that
+# ! the original entity is "bottom_display" is displayed above because
+# ! the numerical value is smaller.
+# !
+# module procedure bottom_display !:doc-priority 40:
+# module procedure top_display !:doc-priority 60:
+# end interface
+# :
+# contains
+# :
+# subroutine top_display(arg) !:doc-priority -10:
+# !
+# ! In a normal situation, this entity is displayed below 'bottom_display'.
+# ! But because priority is -10, this entity is displayed above.
+# !
+# ....
+# end subroutine top_display
+#
+# subroutine bottom_display(arg) !:doc-priority 110:
+# !
+# ! In a normal situation, this entity is displayed above 'top_display'.
+# ! But because priority is 110, this entity is displayed below.
+# !
+# ....
+# end subroutine bottom_display
+# :
+# end module sample1
+#
+#
require "rdoc/code_objects"
@@ -171,8 +536,348 @@
end
- # See rdoc/parsers/parse_f95.rb
+ # Extend Context class for parse_f95.rb
+ # Original class is defined in code_objects.rb.
+ # * The case of names of classes or modules or methods are ignored
+ # * Includes modules can be refered.
+
+ class Context
+
+ def add_method(a_method)
+ if !(a_method.visibility == :public) &&
+ !(a_method.visibility == :private) &&
+ !(a_method.visibility == :protected)
+ a_method.visibility = @visibility
+ end
+ puts "Adding #{a_method.visibility} method #{a_method.name} to #@name" if $DEBUG
+ add_to(@method_list, a_method)
+ end
+
+ def add_alias(an_alias, ignore_case=nil)
+ meth = find_instance_method_named(an_alias.old_name, ignore_case)
+ if meth
+ new_meth = AnyMethod.new(an_alias.text, an_alias.new_name)
+ new_meth.is_alias_for = meth
+ new_meth.singleton = meth.singleton
+ new_meth.params = meth.params
+ new_meth.comment = "Alias for \##{meth.name}"
+ meth.add_alias(new_meth)
+ add_method(new_meth)
+ else
+ add_to(@aliases, an_alias)
+ end
+ end
+
+ # Find a named module
+ def find_module_named(name, ignore_case=nil)
+ res = nil
+ if !ignore_case
+ return self if self.name == name
+ else
+ return self if self.name.upcase == name.upcase
+ end
+ if !ignore_case
+ res = @modules[name] || @classes[name]
+ else
+ @modules.each{ |n, v|
+ if n.upcase == name.upcase
+ res = v ; break
+ end
+ }
+ @classes.each{ |n, v|
+ if n.upcase == name.upcase
+ res = v ; break
+ end
+ } if !res
+ end
+ return res if res
+ find_enclosing_module_named(name, ignore_case)
+ end
+
+ # find a module at a higher scope
+ def find_enclosing_module_named(name, ignore_case=nil)
+ parent && parent.find_module_named(name, ignore_case)
+ end
+
+ def each_includes
+ @includes.each {|i| yield i}
+ end
+
+ # Look up the given filename.
+ def find_file(file, method=nil, ignore_case=nil)
+ find_file_named(file, method, ignore_case)
+ end
+
+ # Look up the given symbol. If method is non-nil, then
+ # we assume the symbol references a module that
+ # contains that method
+ def find_symbol(symbol, method=nil, ignore_case=nil)
+ result = nil
+ case symbol
+ when /^::(.*)/
+ result = toplevel.find_symbol($1, nil, ignore_case)
+ when /::/
+ modules = symbol.split(/::/)
+ unless modules.empty?
+ module_name = modules.shift
+ result = find_module_named(module_name, ignore_case)
+ if result
+ modules.each do |module_name|
+ result = result.find_module_named(module_name, ignore_case)
+ break unless result
+ end
+ end
+ end
+ else
+ # if a method is specified, then we're definitely looking for
+ # a module, otherwise it could be any symbol
+ if method
+ result = find_module_named(symbol, ignore_case)
+ else
+ result = find_local_symbol(symbol, ignore_case)
+ if result.nil?
+ if symbol =~ /^[A-Z]/ ||
+ symbol =~ /^[A-Za-z]/ && ignore_case
+ result = parent
+ while result && result.name != symbol
+ result = result.parent
+ end
+ end
+ end
+ end
+ end
+ if result && method
+ if !result.respond_to?(:find_local_symbol)
+ p result.name
+ p method
+ fail
+ end
+ result = result.find_local_symbol(method, ignore_case)
+ end
+ result
+ end
+
+ def find_local_symbol(symbol, ignore_case=nil)
+ res = find_method_named(symbol, ignore_case) ||
+ find_constant_named(symbol, ignore_case) ||
+ find_attribute_named(symbol, ignore_case) ||
+ find_module_named(symbol, ignore_case)
+ end
+
+ def include_requires?(name, ignore_case=nil)
+ if self.kind_of? TopLevel
+ self.requires.each{|r|
+ if r.name == name ||
+ r.name.upcase == name.upcase && ignore_case
+ return true
+ end
+ }
+ return false
+ else
+ parent.include_requires?(name)
+ end
+ end
+
+ def include_includes?(name, ignore_case=nil)
+ self.includes.each{|i|
+ if i.name == name ||
+ i.name.upcase == name.upcase && ignore_case
+ return true
+ end
+ }
+ return false
+ end
+
+ # Find a named method, or return nil
+ def find_method_named(name, ignore_case=nil)
+ if !ignore_case
+ @method_list.find {|meth| meth.name == name}
+ else
+ @method_list.find {|meth| meth.name.upcase == name.upcase}
+ end
+ end
+
+ # Find a named instance method, or return nil
+ def find_instance_method_named(name, ignore_case=nil)
+ if !ignore_case
+ @method_list.find {|meth| meth.name == name && !meth.singleton}
+ else
+ @method_list.find {|meth|
+ meth.name.upcase == name.upcase && !meth.singleton
+ }
+ end
+ end
+
+ # Find a named constant, or return nil
+ def find_constant_named(name, ignore_case=nil)
+ if !ignore_case
+ @constants.find {|m| m.name == name}
+ else
+ @constants.find {|m| m.name.upcase == name.upcase}
+ end
+ end
+
+ # Find a named attribute, or return nil
+ def find_attribute_named(name, ignore_case=nil)
+ if !ignore_case
+ @attributes.find {|m| m.name == name}
+ else
+ @attributes.find {|m| m.name.upcase == name.upcase}
+ end
+ end
+
+ end
+
+
+
+ # Extend TopLevel class for parse_f95.rb.
+ # Original class is defined in code_objects.rb.
+ # * Cross-reference of files are enabled
+ # * The case of names of classes or modules or methods are ignored
+
+ class TopLevel
+ @@all_files = {}
+
+ def TopLevel::reset
+ @@all_classes = {}
+ @@all_modules = {}
+ @@all_files = {}
+ end
+
+ def initialize(file_name)
+ super()
+ @name = "TopLevel"
+ @file_relative_name = file_name
+ @file_absolute_name = file_name
+ @file_stat = File.stat(file_name)
+ @diagram = nil
+ @@all_files[file_name] = self
+ end
+
+ def TopLevel.all_files
+ @@all_files
+ end
+
+ def find_local_symbol(symbol, ignore_case=nil)
+ find_class_or_module_named(symbol, ignore_case) || super
+ end
+
+ def find_class_or_module_named(symbol, ignore_case=nil)
+ if !ignore_case
+ @@all_classes.each_value {|c| return c if c.name == symbol}
+ @@all_modules.each_value {|m| return m if m.name == symbol}
+ else
+ @@all_classes.each_value {|c| return c if c.name.upcase == symbol.upcase}
+ @@all_modules.each_value {|m| return m if m.name.upcase == symbol.upcase}
+ end
+ nil
+ end
+
+ # Find a named module
+ def find_module_named(name, ignore_case=nil)
+ find_class_or_module_named(name, ignore_case) || find_enclosing_module_named(name, ignore_case)
+ end
+
+ # Find a named file
+ def find_file_named(name, method=nil, ignore_case=nil)
+ return nil unless name
+ result = nil
+ @@all_files.each{|file_name, toplevel|
+ result = toplevel if file_name == name
+ }
+ dir = File.dirname(@file_relative_name)
+ @@all_files.each{|file_name, toplevel|
+ if /^#{dir}\/(.*)/ =~ file_name
+ result = toplevel if $1 == name
+ end
+ }
+ if result
+ if method
+ result_method = result.find_local_symbol(method, ignore_case)
+ return result_method
+ else
+ return result
+ end
+ else
+ return nil
+ end
+ end
+
+ end
+
+
+ # Extend ClassModule class for parse_f95.rb
+ # Original class is defined in code_objects.rb.
+ # * The case of names of classes or modules or methods are ignored
+
+ class ClassModule
+ def find_file_named(name, method=nil, ignore_case=nil)
+ parent.find_file_named(name, method, ignore_case)
+ end
+ end
+
+ # Extend AnyMethod class for parse_f95.rb
+ # Original class is defined in code_objects.rb.
+ # * A method "<=>" is modified.
+
+ class AnyMethod < CodeObject
+
+ attr_reader :doc_priority
+
+ def initialize(text, name)
+ super()
+ @text = text
+ @name = name
+ @token_stream = nil
+ @visibility = :public
+ @dont_rename_initialize = false
+ @block_params = nil
+ @aliases = []
+ @is_alias_for = nil
+ @comment = ""
+ @call_seq = nil
+ @doc_priority = 50
+ end
+
+ def set_priority(doc_priority)
+ if doc_priority.class.to_s == 'Fixnum'
+ @doc_priority = doc_priority
+ end
+ end
+
+ def <=>(other)
+ if @doc_priority < 1 && other.doc_priority < 1
+ t = @doc_priority <=> other.doc_priority
+ return t if t != 0
+ elsif @doc_priority < 1 && other.doc_priority >= 1
+ return -1
+ elsif @doc_priority >= 1 && other.doc_priority < 1
+ return 1
+ end
+
+ if @doc_priority > 99 && other.doc_priority > 99
+ t = @doc_priority <=> other.doc_priority
+ return t if t != 0
+ elsif @doc_priority > 99 && other.doc_priority <= 99
+ return 1
+ elsif @doc_priority <= 99 && other.doc_priority > 99
+ return -1
+ end
+
+ t = @name <=> other.name
+ return t if t != 0
+ t = @doc_priority <=> other.doc_priority
+ return t if t != 0
+ t = @params <=> other.params
+ return t if t != 0
+ t = @comment <=> other.comment
+ end
+ end
+
+
+ #See rdoc/parsers/parse_f95.rb
+ #
class Fortran95parser
extend ParserFactory
@@ -189,7 +894,19 @@
INTERNAL_ALIAS_MES = "Alias for"
# External alias message
- EXTERNAL_ALIAS_MES = "The entity is"
+ EXTERNAL_ALIAS_MES = "Original external subprogram is"
+
+ # Provided modules message
+ PROVIDED_MODULES_MES = "This file provides following module"
+
+ # Repository of NAMELIST statements
+ NAMELIST_REPOSITORY_NAME = "NAMELIST"
+
+ # Ignored marker
+ IGNORED_MARKER_REGEXP = /^:nodoc:/
+
+ # Document priority marker
+ DOC_PRIORITY_REGEXP = /^:doc\-priority\s+([\-\+]?\d+):\s*/
# prepare to parse a Fortran 95 file
def initialize(top_level, file_name, body, options, stats)
@@ -199,6 +916,13 @@
@options = options
@top_level = top_level
@progress = $stderr unless options.quiet
+
+ begin
+ @options_ignore_case = options.ignore_case
+ rescue
+ @options_ignore_case = true
+ end
+
end
# devine code constructs
@@ -279,7 +1003,7 @@
#
module_program_code = block_searching_lines.join("\n")
module_program_code = remove_empty_head_lines(module_program_code)
- if module_program_trailing =~ /^:nodoc:/
+ if module_program_trailing =~ IGNORED_MARKER_REGEXP
# next loop to search next block
level_depth = 0
block_searching_flag = false
@@ -299,38 +1023,109 @@
f9x_module = @top_level.add_module NormalClass, module_name
f9x_module.record_location @top_level
- f9x_comment = COMMENTS_ARE_UPPER ?
- find_comments(pre_comment.join("\n")) + "\n" + module_trailing :
- module_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, ''))
+ #
+ # Add provided modules information to @top_level comment
+ #
+ provided_modules = []
+ provided_mes_line_num = nil
+ top_level_comment_lines = []
+ line_num = 0
+ @top_level.comment.split("\n").each{|line|
+ top_level_comment_lines << line
+ line_num += 1
+ next if line.empty?
+ if !provided_mes_line_num && /^\s?#{PROVIDED_MODULES_MES}/ =~ line
+ provided_mes_line_num = line_num
+ next
+ end
+ if provided_mes_line_num
+ if /^\s?\*\s+(\w+)<\/b>/ =~ line
+ provided_modules << $1
+ else
+ provided_mes_line_num = nil
+ end
+ end
+ }
+ line_num = 0
+ if provided_mes_line_num
+ top_level_comment_lines.collect!{ |line|
+ line_num += 1
+ if line_num < provided_mes_line_num
+ line
+ else
+ nil
+ end
+ }
+ top_level_comment_lines.delete_if{|line| !line }
+ end
+ top_level_comment_lines << "\n" + PROVIDED_MODULES_MES + "."
+ if provided_mes_line_num
+ top_level_comment_lines[-1].sub!(/\.$/, '')
+ top_level_comment_lines[-1] << "s."
+ end
+ provided_modules.each{ |mod|
+ top_level_comment_lines << "* " + mod + ""
+ }
+ top_level_comment_lines << "* " + module_name + ""
+ @top_level.comment = top_level_comment_lines.join("\n")
+
+ #
+ # Information about the module is parsed
+ #
+ f9x_comment = COMMENTS_ARE_UPPER ? find_comments(pre_comment.join("\n")) +
+ "\n" + module_trailing : module_trailing + "\n" +
+ find_comments(module_code.sub(/^.*$\n/i, ''))
f9x_module.comment = f9x_comment
parse_program_or_module(f9x_module, module_code)
TopLevel.all_files.each do |name, toplevel|
- if toplevel.include_includes?(module_name, @options.ignore_case)
- if !toplevel.include_requires?(@file_name, @options.ignore_case)
+ if toplevel.include_includes?(module_name, @options_ignore_case)
+ if !toplevel.include_requires?(@file_name, @options_ignore_case)
toplevel.add_require(Require.new(@file_name, ""))
end
end
toplevel.each_classmodule{|m|
- if m.include_includes?(module_name, @options.ignore_case)
- if !m.include_requires?(@file_name, @options.ignore_case)
+ if m.include_includes?(module_name, @options_ignore_case)
+ if !m.include_requires?(@file_name, @options_ignore_case)
m.add_require(Require.new(@file_name, ""))
end
end
}
end
+
+ namelist_comment =
+ find_namelists(f9x_module, before_contains(module_code))
+ f9x_module.comment << namelist_comment if namelist_comment
+
elsif block_searching_flag == :program
program_name = module_program_name
+ program_name = "main_program" if program_name.empty?
program_code = module_program_code
program_trailing = module_program_trailing
+ program_priority, program_trailing = doc_priority_from_trailing(program_trailing)
+
+ program_comment = COMMENTS_ARE_UPPER ? find_comments(pre_comment.join("\n")) +
+ "\n" + program_trailing : program_trailing + "\n" +
+ find_comments(program_code.sub(/^.*$\n/i, ''))
+
progress "p"
- program_comment = COMMENTS_ARE_UPPER ?
- find_comments(pre_comment.join("\n")) + "\n" + program_trailing :
- program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, ''))
- program_comment = "\n\n= Program #{program_name}\n\n" \
- + program_comment
- @top_level.comment << program_comment
+ @stats.num_methods += 1
+ f9x_mainprogram = AnyMethod.new("main_program", program_name)
+ f9x_mainprogram.singleton = false
+ f9x_mainprogram.comment = " Main Program :: \n"
+ f9x_mainprogram.comment << program_comment
+ f9x_mainprogram.params = ""
+ f9x_mainprogram.set_priority(program_priority) if program_priority
+
+ # For output source code
+ f9x_mainprogram.start_collecting_tokens
+ f9x_mainprogram.add_token Token.new(1,1).set_text(program_code)
+
+ @top_level.add_method f9x_mainprogram
parse_program_or_module(@top_level, program_code, :private)
+
+ namelist_comment = find_namelists(f9x_mainprogram, program_code)
+ f9x_mainprogram.comment << namelist_comment if namelist_comment
end
# next loop to search next block
@@ -347,6 +1142,9 @@
# External subprograms and functions are parsed
#
+ # ñ°ì¤Î¥Õ¥¡¥¤¥ëÆâ¤Ë¤ª¤¤¤Æ program ¤ä module ¤Ë³ÊǼ¤µ¤ì¤Ê¤¤,
+ # ³°Éô¥µ¥Ö¥ë¡¼¥Á¥ó, ³°Éô´Ø¿ôÉôʬ¤Î²òÀÏ.
+ #
parse_program_or_module(@top_level, remaining_lines.join("\n"),
:public, true)
@@ -365,28 +1163,11 @@
#
# Parse variables before "contains" in module
#
- level_depth = 0
- before_contains_lines = []
- before_contains_code = nil
- before_contains_flag = nil
- remaining_lines.each{ |line|
- if !before_contains_flag
- if line =~ /^\s*?module\s+\w+\s*?(!.*?)?$/i
- before_contains_flag = true
- end
- else
- break if line =~ /^\s*?contains\s*?(!.*?)?$/i
- level_depth += 1 if block_start?(line)
- level_depth -= 1 if block_end?(line)
- break if level_depth < 0
- before_contains_lines << line
- end
- }
- before_contains_code = before_contains_lines.join("\n")
- if before_contains_code
- before_contains_code.gsub!(/^\s*?interface\s+.*?\s+end\s+interface.*?$/im, "")
- before_contains_code.gsub!(/^\s*?type[\s\,]+.*?\s+end\s+type.*?$/im, "")
- end
+ # namelist ÊÑ¿ô¤ÎÄêµÁ¤Ë»È¤ï¤ì¤¿¤ê, ¤³¤ì¼«ÂΤ¬Äê¿ô, ÊÑ¿ô
+ # Ä󶡤µ¤ì¤ë¤Î¤ËÍøÍѤµ¤ì¤ë. (ÊÑ¿ô¤äÄê¿ô¤È¤·¤ÆÍøÍѤµ¤ì¤ë¾ì¹ç,
+ # ¤³¤ì¤â¥á¥½¥Ã¥É¤È¤·¤ÆÄ󶡤¹¤ë.
+ #
+ before_contains_code = before_contains(remaining_code)
#
# Parse global "use"
@@ -399,8 +1180,8 @@
used_mod_name = $1.strip.chomp
used_list = $2 || ""
used_trailing = $3 || ""
- next if used_trailing =~ /!:nodoc:/
- if !container.include_includes?(used_mod_name, @options.ignore_case)
+ next if used_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
+ if !container.include_includes?(used_mod_name, @options_ignore_case)
progress "."
container.add_include Include.new(used_mod_name, "")
end
@@ -444,7 +1225,7 @@
@@public_methods.collect!{ |pub_meth|
if local == pub_meth["name"] ||
local.upcase == pub_meth["name"].upcase &&
- @options.ignore_case
+ @options_ignore_case
pub_meth["name"] = org
pub_meth["local_name"] = local
end
@@ -463,8 +1244,8 @@
use_check_code << $~.post_match
used_mod_name = $1.strip.chomp
used_trailing = $3 || ""
- next if used_trailing =~ /!:nodoc:/
- if !container.include_includes?(used_mod_name, @options.ignore_case)
+ next if used_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
+ if !container.include_includes?(used_mod_name, @options_ignore_case)
progress "."
container.add_include Include.new(used_mod_name, "")
end
@@ -473,10 +1254,10 @@
container.each_includes{ |inc|
TopLevel.all_files.each do |name, toplevel|
indicated_mod = toplevel.find_symbol(inc.name,
- nil, @options.ignore_case)
+ nil, @options_ignore_case)
if indicated_mod
indicated_name = indicated_mod.parent.file_relative_name
- if !container.include_requires?(indicated_name, @options.ignore_case)
+ if !container.include_requires?(indicated_name, @options_ignore_case)
container.add_require(Require.new(indicated_name, ""))
end
break
@@ -485,7 +1266,7 @@
}
#
- # Parse derived-types definitions
+ # Parse derived types definitions
#
derived_types_comment = ""
remaining_code = remaining_lines.join("\n")
@@ -501,10 +1282,12 @@
type_elements = $5 || ""
type_code = remove_empty_head_lines($&)
type_trailing = find_comments($4)
- next if type_trailing =~ /^:nodoc:/
type_visibility = $1
+ pre_match = $~.pre_match
+ next if type_trailing =~ IGNORED_MARKER_REGEXP
+ type_priority, type_trailing = doc_priority_from_trailing(type_trailing)
type_comment = COMMENTS_ARE_UPPER ?
- find_comments($~.pre_match) + "\n" + type_trailing :
+ find_comments(pre_match) + "\n" + type_trailing :
type_trailing + "\n" + find_comments(type_code.sub(/^.*$\n/i, ''))
type_element_visibility_public = true
type_code.split("\n").each{ |line|
@@ -537,6 +1320,7 @@
type.comment = " Derived Type :: \n"
type.comment << args_comment if args_comment
type.comment << type_comment if type_comment
+ type.set_priority(type_priority) if type_priority
progress "t"
@stats.num_methods += 1
container.add_method type
@@ -607,6 +1391,7 @@
const_or_var_progress = "c"
end
const_or_var = AnyMethod.new(const_or_var_type, defitem.varname)
+ const_or_var.set_priority(defitem.doc_priority) if defitem.doc_priority
const_or_var.singleton = false
const_or_var.params = ""
self_comment = find_arguments([defitem.varname], before_contains_code)
@@ -708,7 +1493,7 @@
#
procedure_code = block_searching_lines.join("\n")
procedure_code = remove_empty_head_lines(procedure_code)
- if procedure_trailing =~ /^!:nodoc:/
+ if procedure_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
# next loop to search next block
level_depth = 0
block_searching_flag = nil
@@ -734,6 +1519,7 @@
subroutine_params = procedure_params
subroutine_trailing = procedure_trailing
subroutine_code = procedure_code
+ subroutine_priority, subroutine_trailing = doc_priority_from_trailing(subroutine_trailing)
subroutine_comment = COMMENTS_ARE_UPPER ?
pre_comment.join("\n") + "\n" + subroutine_trailing :
@@ -742,11 +1528,16 @@
parse_subprogram(subroutine, subroutine_params,
subroutine_comment, subroutine_code,
before_contains_code, nil, subroutine_prefix)
+ subroutine.set_priority(subroutine_priority) if subroutine_priority
progress "s"
@stats.num_methods += 1
container.add_method subroutine
subroutine_function = subroutine
+ namelist_comment =
+ find_namelists(subroutine, subroutine_code, before_contains_code)
+ subroutine.comment << namelist_comment if namelist_comment
+
elsif block_searching_flag == :function
function_prefix = procedure_prefix
function_type = procedure_type
@@ -755,6 +1546,7 @@
function_result_arg = procedure_result_arg
function_trailing = procedure_trailing
function_code_org = procedure_code
+ function_priority, function_trailing = doc_priority_from_trailing(function_trailing)
function_comment = COMMENTS_ARE_UPPER ?
pre_comment.join("\n") + "\n" + function_trailing :
@@ -772,6 +1564,7 @@
parse_subprogram(function, function_params,
function_comment, function_code,
before_contains_code, true, function_prefix)
+ function.set_priority(function_priority) if function_priority
# Specific modification due to function
function.params.sub!(/\(\s*?#{function_result_arg}\s*?,\s*?/, "\( ")
@@ -784,6 +1577,10 @@
container.add_method function
subroutine_function = function
+ namelist_comment =
+ find_namelists(function, function_code, before_contains_code)
+ function.comment << namelist_comment if namelist_comment
+
end
# The visibility of procedure is specified
@@ -841,7 +1638,7 @@
generic_name = $1 ? $1.strip.chomp : nil
interface_trailing = $2 || "!"
interface_scope = true
- interface_scope = false if interface_trailing =~ /!:nodoc:/
+ interface_scope = false if interface_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
# if generic_name =~ /operator\s*?\((.*?)\)/i
# operator_name = $1
# if operator_name && !operator_name.empty?
@@ -863,12 +1660,14 @@
if interface_scope && /^\s*?module\s+procedure\s+(.*?)(!.*?)?$/i =~ line
procedures = $1.strip.chomp
procedures_trailing = $2 || "!"
- next if procedures_trailing =~ /!:nodoc:/
+ next if procedures_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
+ procedures_priority, procedures_trailing = doc_priority_from_trailing(procedures_trailing)
+
procedures.split(",").each{ |proc|
proc.strip!
proc.chomp!
next if generic_name == proc || !generic_name
- old_meth = container.find_symbol(proc, nil, @options.ignore_case)
+ old_meth = container.find_symbol(proc, nil, @options_ignore_case)
next if !old_meth
nolink = old_meth.visibility == :private ? true : nil
nolink = nil if @options.show_all
@@ -879,6 +1678,7 @@
old_meth.clone.token_stream[0].text,
true, nolink)
new_meth.singleton = old_meth.singleton
+ new_meth.set_priority(procedures_priority) if procedures_priority
progress "i"
@stats.num_methods += 1
@@ -902,7 +1702,7 @@
subroutine\s+(\w+)\s*?(\(.*?\))?\s*?(!.*?)?$
/ix
proc = $2.chomp.strip
- generic_name = proc unless generic_name
+ proc_name = generic_name || proc
params = $3 || ""
procedures_trailing = $4 || "!"
@@ -922,43 +1722,46 @@
(\(.*?\))?(\s+result\((.*?)\))?\s*?(!.*?)?$
/ix
proc = $8.chomp.strip
- generic_name = proc unless generic_name
+ proc_name = generic_name || proc
params = $9 || ""
procedures_trailing = $12 || "!"
else
next
end
- next if procedures_trailing =~ /!:nodoc:/
+ next if procedures_trailing.sub(/^!/, '') =~ IGNORED_MARKER_REGEXP
+ procedures_priority, procedures_trailing = doc_priority_from_trailing(procedures_trailing)
indicated_method = nil
indicated_file = nil
TopLevel.all_files.each do |name, toplevel|
- indicated_method = toplevel.find_local_symbol(proc, @options.ignore_case)
+ indicated_method = toplevel.find_local_symbol(proc, @options_ignore_case)
indicated_file = name
break if indicated_method
end
if indicated_method
external_method =
- initialize_external_method(generic_name, proc,
+ initialize_external_method(proc_name, proc,
indicated_method.params,
indicated_file,
indicated_method.comment)
+ external_method.set_priority(procedures_priority) if procedures_priority
progress "e"
@stats.num_methods += 1
container.add_method external_method
- set_visibility(container, generic_name, visibility_default, @@public_methods)
- if !container.include_requires?(indicated_file, @options.ignore_case)
+ set_visibility(container, proc_name, visibility_default, @@public_methods)
+ if !container.include_requires?(indicated_file, @options_ignore_case)
container.add_require(Require.new(indicated_file, ""))
end
check_public_methods(external_method, container.name)
else
@@external_aliases << {
- "new_name" => generic_name,
+ "new_name" => proc_name,
"old_name" => proc,
"file_or_module" => container,
- "visibility" => find_visibility(container, generic_name, @@public_methods) || visibility_default
+ "visibility" => find_visibility(container, proc_name, @@public_methods) || visibility_default,
+ "doc_priority" => procedures_priority
}
end
end
@@ -969,6 +1772,9 @@
# Already imported methods are removed from @@public_methods.
# Remainders are assumed to be imported from other modules.
#
+ # ´û¤Ë»²¾ÈºÑ¤ß¤Î¥á¥½¥Ã¥É¤Ï @@public_methods ¤«¤é¼è¤ê½ü¤¯.
+ # »Ä¤ê¤Ï³°Éô¥â¥¸¥å¡¼¥ë¤«¤é¤Î»²¾È¤È²¾Äꤹ¤ë.
+ #
@@public_methods.delete_if{ |method| method["entity_is_discovered"]}
@@public_methods.each{ |pub_meth|
@@ -977,11 +1783,11 @@
TopLevel.all_classes_and_modules.each{ |modules|
if modules.name == used_mod ||
modules.name.upcase == used_mod.upcase &&
- @options.ignore_case
+ @options_ignore_case
modules.method_list.each{ |meth|
if meth.name == pub_meth["name"] ||
meth.name.upcase == pub_meth["name"].upcase &&
- @options.ignore_case
+ @options_ignore_case
new_meth = initialize_public_method(meth,
modules.name)
if pub_meth["local_name"]
@@ -1014,7 +1820,6 @@
nil, nil, true)
params_opt = "( " + params_opt + " ) " if params_opt
subprogram.params = params_opt || ""
- namelist_comment = find_namelists(code, before_contains)
block_comment = find_comments comment
if function
@@ -1024,7 +1829,6 @@
end
subprogram.comment << args_comment if args_comment
subprogram.comment << block_comment if block_comment
- subprogram.comment << namelist_comment if namelist_comment
# For output source code
subprogram.start_collecting_tokens
@@ -1033,6 +1837,54 @@
subprogram
end
+ def doc_priority_from_trailing(trailing)
+ prefix = ''
+ if trailing =~ /^(\s*!)(.*)$/
+ prefix = $1
+ trailing = $2
+ end
+ if trailing =~ DOC_PRIORITY_REGEXP
+ priority = $1.to_i
+ trailing.sub!(DOC_PRIORITY_REGEXP, '')
+ else
+ priority = false
+ end
+ trailing = prefix + trailing
+ return priority, trailing
+ end
+
+ #
+ # Return lines before "contains" statement in modules.
+ # "interface", "type" statements are removed.
+ #
+ def before_contains(code)
+ level_depth = 0
+ before_contains_lines = []
+ before_contains_code = nil
+ before_contains_flag = nil
+ code.split("\n").each{ |line|
+ if !before_contains_flag
+ if line =~ /^\s*?module\s+\w+\s*?(!.*?)?$/i
+ before_contains_flag = true
+ end
+ else
+ break if line =~ /^\s*?contains\s*?(!.*?)?$/i
+ level_depth += 1 if block_start?(line)
+ level_depth -= 1 if block_end?(line)
+ break if level_depth < 0
+ before_contains_lines << line
+ end
+
+ }
+ before_contains_code = before_contains_lines.join("\n")
+ if before_contains_code
+ before_contains_code.gsub!(/^\s*?interface\s+.*?\s+end\s+interface.*?$/im, "")
+ before_contains_code.gsub!(/^\s*?type[\s\,]+.*?\s+end\s+type.*?$/im, "")
+ end
+
+ before_contains_code
+ end
+
#
# Collect comment for file entity
#
@@ -1084,7 +1936,7 @@
if arg == defitem.varname.strip.chomp || all
args_rdocforms << <<-"EOF"
-#{indent}#{defitem.varname.chomp.strip}#{defitem.arraysuffix} #{defitem.inivalue} ::
+#{indent}#{defitem.varname.chomp.strip}#{defitem.arraysuffix} #{defitem.inivalue} ::
#{indent} #{defitem.types.chomp.strip}
EOF
if !defitem.comment.chomp.strip.empty?
@@ -1118,27 +1970,88 @@
end
end
- # Return comments of definitions of namelists
#
- def find_namelists(text, before_contains=nil)
+ # Add namelist information to Repository (dummy module of each
+ # @top_level) of NAMELIST statements.
+ # And return comments about namelist group names
+ #
+ def find_namelists(container, text, before_contains=nil)
return nil if !text
- result = ""
+ top_level = find_toplevel(container)
+
+ if text =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)(!.*?)?$/i
+ if top_level.include_includes?(NAMELIST_REPOSITORY_NAME)
+ namelist_module =
+ top_level.find_module_named(NAMELIST_REPOSITORY_NAME)
+ else
+ namelist_module =
+ top_level.add_module NormalClass, NAMELIST_REPOSITORY_NAME
+ namelist_module.record_location top_level
+ namelist_module.comment = <<-"EOF"
+This is not a module but a repository of NAMELIST group names declared
+in all Fortran 90/95 files
+EOF
+ end
+ else
+ return ""
+ end
+
+ nml_group_name_lists = []
lines = "#{text}"
before_contains = "" if !before_contains
- while lines =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)$/i
+ while lines =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)(!.*?)?$/i
lines = $~.post_match
+ pre_match = $~.pre_match ; post_match = $~.post_match
+ nml_group_name = $1
+ trailing_comment = $3 || ""
+ nml_vars_list = $2.split(",")
nml_comment = COMMENTS_ARE_UPPER ?
- find_comments($~.pre_match) : find_comments($~.post_match)
- nml_name = $1
- nml_args = $2.split(",")
- result << "\n\n=== NAMELIST " + nml_name + "\n\n"
- result << nml_comment + "\n" if nml_comment
+ find_comments(pre_match.sub(/\n$/, '')) :
+ find_comments(trailing_comment + post_match)
if lines.split("\n")[0] =~ /^\//i
lines = "namelist " + lines
end
- result << find_arguments(nml_args, "#{text}" + "\n" + before_contains)
+
+ nml_meth = AnyMethod.new("NAMELIST", nml_group_name)
+ nml_meth.singleton = false
+ nml_meth.params = "( " + nml_vars_list.join(", ") + " )"
+ nml_meth.comment = " NAMELIST :: \n"
+ nml_meth.comment << find_arguments(nml_vars_list, "#{text}" + "\n" + before_contains)
+ nml_meth.comment << "\n" + nml_comment if nml_comment
+ if container.parent.parent
+ parent_object = container.parent.name
+ else
+ parent_object = container.parent.file_relative_name
+ end
+ nml_meth.comment << "\n\nThis namelist group name is input/output in "
+ nml_meth.comment << parent_object + "#" + container.name
+
+ progress "n"
+ @stats.num_methods += 1
+ namelist_module.add_method nml_meth
+
+ nml_group_name_lists << NAMELIST_REPOSITORY_NAME + "#" + nml_group_name
+ end
+
+ if !nml_group_name_lists.empty?
+ comments_in_procedures = "\n\nThis procedure input/output "
+ comments_in_procedures << nml_group_name_lists.join(", ") + " . "
+ else
+ comments_in_procedures = ""
end
- return result
+
+ comments_in_procedures
+ end
+
+ #
+ # Return toplevel class of container
+ #
+ def find_toplevel(container)
+ top_level = container
+ while top_level.parent
+ top_level = top_level.parent
+ end
+ top_level
end
#
@@ -1290,7 +2203,7 @@
not_found = true
visibility_info.collect!{ |info|
if info["name"] == subname ||
- @options.ignore_case && info["name"].upcase == subname.upcase
+ @options_ignore_case && info["name"].upcase == subname.upcase
if info["file_or_module"].name == container.name
container.set_visibility_for([subname], info["visibility"])
info["entity_is_discovered"] = true
@@ -1313,7 +2226,7 @@
return nil if !subname || !visibility_info
visibility_info.each{ |info|
if info["name"] == subname ||
- @options.ignore_case && info["name"].upcase == subname.upcase
+ @options_ignore_case && info["name"].upcase == subname.upcase
if info["parent"] == container.name
return info["visibility"]
end
@@ -1325,22 +2238,26 @@
#
# Check external aliases
#
+ # subname ¤È¤¤¤¦¥µ¥Ö¥ë¡¼¥Á¥ó̾, ¤Þ¤¿¤Ï´Ø¿ô̾¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤ò
+ # õºº¤·, ¸ºß¤¹¤ë¾ì¹ç¤Ë¤Ï¤½¤Î¥Õ¥¡¥¤¥ëÆâ¤Ø¥á¥½¥Ã¥É¤òÄɲ乤ë.
+ #
def check_external_aliases(subname, params, comment, test=nil)
@@external_aliases.each{ |alias_item|
if subname == alias_item["old_name"] ||
subname.upcase == alias_item["old_name"].upcase &&
- @options.ignore_case
+ @options_ignore_case
new_meth = initialize_external_method(alias_item["new_name"],
subname, params, @file_name,
comment)
new_meth.visibility = alias_item["visibility"]
+ new_meth.set_priority(alias_item["doc_priority"]) if alias_item["doc_priority"]
progress "e"
@stats.num_methods += 1
alias_item["file_or_module"].add_method(new_meth)
- if !alias_item["file_or_module"].include_requires?(@file_name, @options.ignore_case)
+ if !alias_item["file_or_module"].include_requires?(@file_name, @options_ignore_case)
alias_item["file_or_module"].add_require(Require.new(@file_name, ""))
end
end
@@ -1350,6 +2267,11 @@
#
# Check public_methods
#
+ # use ¤·¤¿¥â¥¸¥å¡¼¥ë¤«¤é¤½¤Î¤Þ¤Þ°ú¤·Ñ¤¤¤Ç public ¤È¤·¤Æ
+ # ¸ø³«¤¹¤ë¾ì¹ç¤Î¥Á¥§¥Ã¥¯¤ò¹Ô¤¦.
+ # subname ¤È¤¤¤¦¥µ¥Ö¥ë¡¼¥Á¥ó̾, ¤Þ¤¿¤Ï´Ø¿ô̾¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤ò
+ # õºº¤·, ¸ºß¤¹¤ë¾ì¹ç¤Ë¤Ï¤½¤Î¥Õ¥¡¥¤¥ëÆâ¤Ø¥á¥½¥Ã¥É¤òÄɲ乤ë.
+ #
def check_public_methods(method, parent)
return if !method || !parent
@@public_methods.each{ |alias_item|
@@ -1357,7 +2279,7 @@
alias_item["used_modules"].each{ |used_module|
if used_module == parent ||
used_module.upcase == parent.upcase &&
- @options.ignore_case
+ @options_ignore_case
parent_is_used_module = true
end
}
@@ -1365,7 +2287,7 @@
if method.name == alias_item["name"] ||
method.name.upcase == alias_item["name"].upcase &&
- @options.ignore_case
+ @options_ignore_case
new_meth = initialize_public_method(method, parent)
if alias_item["local_name"]
@@ -1383,19 +2305,31 @@
# Continuous lines are united.
#
# Comments in continuous lines are removed.
+ # If delete_space=false, spaces around "&" are not deleted.
+ #
+ # Example
+ #
+ # before
+ #
+ # subroutine func(a, b, c, d, e, & ! ignored comments
+ # & f, g, h) ! valid comments
#
- def united_to_one_line(f90src)
+ # after
+ #
+ # subroutine func(a, b, c, d, e, f, g, h) ! valid comments
+ #
+ def united_to_one_line(f90src, delete_space=true)
return "" unless f90src
lines = f90src.split("\n")
previous_continuing = false
now_continuing = false
body = ""
+ squote = false ; dquote = false
lines.each{ |line|
words = line.split("")
next if words.empty? && previous_continuing
commentout = false
brank_flag = true ; brank_char = ""
- squote = false ; dquote = false
ignore = false
words.collect! { |char|
if previous_continuing && brank_flag
@@ -1417,7 +2351,7 @@
end
ignore = false
- if now_continuing
+ if now_continuing && !(squote) && !(dquote)
next ""
elsif !(squote) && !(dquote) && !(commentout)
case char
@@ -1431,25 +2365,32 @@
next char
elsif squote
case char
- when "\'"; squote = false ; next char
+ when "\'"; squote = false ; now_continuing = false ; next char
+ when "&" ; now_continuing = true ; next ""
else next char
end
elsif dquote
case char
- when "\""; dquote = false ; next char
+ when "\""; dquote = false ; now_continuing = false ; next char
+ when "&" ; now_continuing = true ; next ""
else next char
end
end
}
if !ignore && !previous_continuing || !brank_flag
if previous_continuing
- body << words.join("")
+ if delete_space
+ joined_words = words.join("")
+ body = body.rstrip + " " + joined_words.lstrip
+ else
+ body << words.join("")
+ end
else
body << "\n" + words.join("")
end
end
- previous_continuing = now_continuing ? true : nil
- now_continuing = nil
+ previous_continuing = now_continuing ? true : false
+ now_continuing = false
}
return body
end
@@ -1506,6 +2447,10 @@
return "" unless text
lines = text.split("\n")
lines.collect!{ |line|
+ indent_space = ""
+ if line =~ /^(\s+)/
+ indent_space = $1
+ end
words = line.split("")
commentout = false
squote = false ; dquote = false
@@ -1515,7 +2460,7 @@
when "!" ; commentout = true ; next char
when "\""; dquote = true ; next char
when "\'"; squote = true ; next char
- when ";" ; "\n"
+ when ";" ; "\n"+indent_space
else next char
end
elsif commentout
@@ -1634,7 +2579,7 @@
end
def remove_private_comments(body)
- body.gsub!(/^\s*!--\s*?$.*?^\s*!\+\+\s*?$/m, '')
+ body.gsub!(/^(\s*)!--\s*?$.*?^\s*!\+\+\s*?$/m, '\\1!')
return body
end
@@ -1646,36 +2591,48 @@
# Name of variable
#
+ # ÊÑ¿ô̾
attr_reader :varname
# Types of variable
#
+ # ¥Ç¡¼¥¿·¿¾ðÊó
attr_reader :types
# Initial Value
#
+ # ½é´üÃÍ
attr_reader :inivalue
# Suffix of array
#
+ # ÇÛÎóÀÜÈø»ì
attr_reader :arraysuffix
# Comments
#
+ # ¹Ô¤ÎËöÈø¤Ë¤«¤«¤ì¤ë¥³¥á¥ó¥È
attr_accessor :comment
# Flag of non documentation
#
+ # ¥É¥¥å¥á¥ó¥È½ÐÎϤ·¤Ê¤¤¥Õ¥é¥°
attr_accessor :nodoc
+ # Priority of documentation
+ #
+ # ¥É¥¥å¥á¥ó¥È¤ÎÍ¥ÀèÅÙ
+ attr_accessor :doc_priority
+
def initialize(varname, types, inivalue, arraysuffix, comment,
- nodoc=false)
+ nodoc=false, doc_priority=50)
@varname = varname
@types = types
@inivalue = inivalue
@arraysuffix = arraysuffix
@comment = comment
@nodoc = nodoc
+ @doc_priority = doc_priority
end
def to_s
@@ -1822,11 +2779,18 @@
end
}
defs << Fortran95Definition.new(varname, type, inivalue, arraysuffix, comment)
- if trailing_comment =~ /^:nodoc:/
+ if trailing_comment =~ IGNORED_MARKER_REGEXP
defs[start_pos..-1].collect!{ |defitem|
defitem.nodoc = true
}
end
+ if trailing_comment =~ DOC_PRIORITY_REGEXP
+ doc_priority = $1.to_i
+ defs[start_pos..-1].collect!{ |defitem|
+ defitem.doc_priority = doc_priority
+ defitem.comment.sub!(DOC_PRIORITY_REGEXP, '')
+ }
+ end
varname = "" ; arraysuffix = "" ; inivalue = ""
comment = ""
under_comment_valid = true
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/parsers/parse_rb.rb ../rdoc-f95-20070109/parsers/parse_rb.rb
--- ruby-1.8.5-p12/lib/rdoc/parsers/parse_rb.rb 2006-06-15 07:19:36.000000000 +0900
+++ ../rdoc-f95-20070109/parsers/parse_rb.rb 2006-11-09 02:07:16.000000000 +0900
@@ -435,7 +435,7 @@
def_exception(:SyntaxError, "%s")
include RubyToken
- include IRB
+# include IRB # 1.8.2 doesn't support #IRB::SLex
attr_reader :continue
attr_reader :lex_state
@@ -466,11 +466,10 @@
@exception_on_syntax_error = true
end
- attr :skip_space, true
- attr :read_auto_clean_up, true
- attr :exception_on_syntax_error, true
-
- attr :indent
+ attr_accessor :skip_space
+ attr_accessor :read_auto_clean_up
+ attr_accessor :exception_on_syntax_error
+ attr_reader :indent
# io functions
def line_no
@@ -588,6 +587,7 @@
def lex_init()
@OP = SLex.new
+# @OP = IRB::SLex.new # 1.8.2 doesn't support #IRB::SLex
@OP.def_rules("\0", "\004", "\032") do |chars, io|
Token(TkEND_OF_SCRIPT).set_text(chars)
end
@@ -1477,15 +1477,19 @@
if tk.kind_of?(TkSYMBEG)
set_token_position(tk.line_no, tk.char_no)
tk1 = get_tk
- if tk1.kind_of?(TkId) || tk1.kind_of?(TkOp)
- tk = Token(TkSYMBOL).set_text(":" + tk1.name)
+ if tk1.kind_of?(TkId) || tk1.kind_of?(TkOp) || tk1.kind_of?(TkSTRING)
+ if tk1.respond_to?(:name)
+ tk = Token(TkSYMBOL).set_text(":" + tk1.name)
+ else
+ tk = Token(TkSYMBOL).set_text(":" + tk1.text)
+ end
# remove the identifier we just read (we're about to
# replace it with a symbol)
@token_listeners.each do |obj|
obj.pop_token
end if @token_listeners
else
- warn("':' not followed by identified or operator")
+ warn("':' not followed by identifier or operator")
tk = tk1
end
end
@@ -2334,6 +2338,7 @@
when "section"
context.set_current_section(param, comment)
+# comment.clear # ruby 1.9 feature
comment.replace("") # 1.8 doesn't support #clear
break
else
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/rdoc ../rdoc-f95-20070109/rdoc
--- ruby-1.8.5-p12/lib/rdoc/rdoc 1970-01-01 09:00:00.000000000 +0900
+++ ../rdoc-f95-20070109/rdoc 2005-09-22 18:40:11.000000000 +0900
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+#
+# RDoc: Documentation tool for source code
+# (see lib/rdoc/rdoc.rb for more information)
+#
+# Copyright (c) 2003 Dave Thomas
+# Released under the same terms as Ruby
+#
+# $Revision: 1.1 $
+
+## Transitional Hack ####
+#
+# RDoc was initially distributed independently, and installed
+# itself into /lib/ruby/site_ruby//rdoc...
+#
+# Now that RDoc is part of the distribution, it's installed into
+# /lib/ruby/, which unfortunately appears later in the
+# search path. This means that if you have previously installed RDoc,
+# and then install from ruby-lang, you'll pick up the old one by
+# default. This hack checks for the condition, and readjusts the
+# search path if necessary.
+
+#def adjust_for_existing_rdoc(path)
+#
+# $stderr.puts %{
+# It seems as if you have a previously-installed RDoc in
+# the directory #{path}.
+#
+# Because this is now out-of-date, you might want to consider
+# removing the directories:
+#
+# #{File.join(path, "rdoc")}
+#
+# and
+#
+# #{File.join(path, "markup")}
+#
+# }
+#
+# # Move all the site_ruby directories to the end
+# p $:
+# $:.replace($:.partition {|path| /site_ruby/ !~ path}.flatten)
+# p $:
+#end
+#
+# $:.each do |path|
+# if /site_ruby/ =~ path
+# rdoc_path = File.join(path, 'rdoc', 'rdoc.rb')
+# if File.exists?(rdoc_path)
+# adjust_for_existing_rdoc(path)
+# break
+# end
+# end
+#end
+
+## End of Transitional Hack ##
+
+
+require 'rdoc/rdoc'
+
+begin
+ r = RDoc::RDoc.new
+ r.document(ARGV)
+rescue RDoc::RDocError => e
+ $stderr.puts e.message
+ exit(1)
+end
¥Ð¥¤¥Ê¥ê¡¼¡¦¥Õ¥¡¥¤¥ëruby-1.8.5-p12/lib/rdoc/rdoc-f95-mailto.png¤È../rdoc-f95-20070109/rdoc-f95-mailto.png¤Ï°ã¤¤¤Þ¤¹
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/rdoc.rb ../rdoc-f95-20070109/rdoc.rb
--- ruby-1.8.5-p12/lib/rdoc/rdoc.rb 2006-08-05 07:00:25.000000000 +0900
+++ ../rdoc-f95-20070109/rdoc.rb 2006-11-09 00:02:43.000000000 +0900
@@ -2,7 +2,10 @@
#
-VERSION_STRING = %{RDoc V1.0.1 - 20041108}
+VERSION_STRING = <<-"EOF"
+RDoc modified by GFD Dennou Club: Version $Name: rdoc-f95-20070109 $
+ See http://www.gfd-dennou.org/library/dcmodel
+EOF
require 'rdoc/parsers/parse_rb.rb'
@@ -16,6 +19,7 @@
require 'find'
require 'ftools'
+require 'time'
# We put rdoc stuff in the RDoc module to avoid namespace
# clutter.
@@ -106,25 +110,38 @@
# then we refuse to use it, as we may clobber some
# manually generated documentation
- def setup_output_dir(op_dir)
- flag_file = File.join(op_dir, "created.rid")
+ def setup_output_dir(op_dir, force)
+ flag_file = output_flag_file(op_dir)
if File.exist?(op_dir)
unless File.directory?(op_dir)
error "'#{op_dir}' exists, and is not a directory"
end
- unless File.file?(flag_file)
+ begin
+ created = File.read(flag_file)
+ rescue SystemCallError
error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
"destroying any of your existing files, you'll need to\n" +
"specify a different output directory name (using the\n" +
"--op option).\n\n"
+ else
+ last = (Time.parse(created) unless force rescue nil)
end
else
File.makedirs(op_dir)
end
- File.open(flag_file, "w") {|f| f.puts Time.now }
+ last
+ end
+
+ # Update the flag file in an output directory.
+ def update_output_dir(op_dir, time)
+ File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
+ end
+
+ # Return the path name of the flag file in an output directory.
+ def output_flag_file(op_dir)
+ File.join(op_dir, "created.rid")
end
-
# The .document file contains a list of file and directory name
# patterns, representing candidates for documentation. It may
@@ -160,8 +177,10 @@
relative_files.each do |rel_file_name|
next if exclude_pattern && exclude_pattern =~ rel_file_name
- case type = File.stat(rel_file_name).ftype
+ stat = File.stat(rel_file_name)
+ case type = stat.ftype
when "file"
+ next if @last_created and stat.mtime < @last_created
file_list << rel_file_name.sub(/^\.\//, '') if force_doc || ParserFactory.can_parse(rel_file_name)
when "directory"
next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -238,22 +257,25 @@
options = Options.instance
options.parse(argv, GENERATORS)
-
+
+ @last_created = nil
unless options.all_one_file
- setup_output_dir(options.op_dir)
+ @last_created = setup_output_dir(options.op_dir, options.force_update)
end
+ start_time = Time.now
file_info = parse_files(options)
- gen = options.generator
-
- $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
-
- require gen.file_name
-
- gen_class = Generators.const_get(gen.class_name)
-
- unless file_info.empty?
+ if file_info.empty?
+ $stderr.puts "\nNo newer files." unless options.quiet
+ else
+ gen = options.generator
+
+ $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
+
+ require gen.file_name
+
+ gen_class = Generators.const_get(gen.class_name)
gen = gen_class.for(options)
pwd = Dir.pwd
@@ -263,6 +285,7 @@
begin
Diagram.new(file_info, options).draw if options.diagram
gen.generate(file_info)
+ update_output_dir(".", start_time)
ensure
Dir.chdir(pwd)
end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/ri/ri_display.rb ../rdoc-f95-20070109/ri/ri_display.rb
--- ruby-1.8.5-p12/lib/rdoc/ri/ri_display.rb 2006-06-27 05:44:14.000000000 +0900
+++ ../rdoc-f95-20070109/ri/ri_display.rb 2005-09-22 16:49:20.000000000 +0900
@@ -236,6 +236,7 @@
@formatter.break_to_newline
end
end
+
######################################################################
def display_flow(flow)
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/ri/ri_formatter.rb ../rdoc-f95-20070109/ri/ri_formatter.rb
--- ruby-1.8.5-p12/lib/rdoc/ri/ri_formatter.rb 2006-06-27 05:44:14.000000000 +0900
+++ ../rdoc-f95-20070109/ri/ri_formatter.rb 2006-11-20 05:35:28.000000000 +0900
@@ -554,9 +554,7 @@
def display_verbatim_flow_item(item, prefix=@indent)
print("")
- item.body.split(/\n/).each do |line|
- puts conv_html(line)
- end
+ puts item.body
puts("
")
end
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/ri/ri_paths.rb ../rdoc-f95-20070109/ri/ri_paths.rb
--- ruby-1.8.5-p12/lib/rdoc/ri/ri_paths.rb 2006-06-27 05:44:14.000000000 +0900
+++ ../rdoc-f95-20070109/ri/ri_paths.rb 2006-11-20 05:35:56.000000000 +0900
@@ -27,8 +27,10 @@
DOC_DIR = "doc/rdoc"
version = Config::CONFIG['ruby_version']
+# version = RbConfig::CONFIG['ruby_version'] # RbConfig is invalid in Ruby 1.8.2
base = File.join(Config::CONFIG['datadir'], "ri", version)
+# base = File.join(RbConfig::CONFIG['datadir'], "ri", version) # RbConfig is invalid in Ruby 1.8.2
SYSDIR = File.join(base, "system")
SITEDIR = File.join(base, "site")
homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/ri/ri_writer.rb ../rdoc-f95-20070109/ri/ri_writer.rb
--- ruby-1.8.5-p12/lib/rdoc/ri/ri_writer.rb 2003-12-19 06:08:25.000000000 +0900
+++ ../rdoc-f95-20070109/ri/ri_writer.rb 2006-11-20 05:36:22.000000000 +0900
@@ -13,7 +13,7 @@
# by %xx)
def RiWriter.internal_to_external(name)
- name.gsub(/\W/) { sprintf("%%%02x", $&[0]) }
+ name.gsub(/\W/) { "%%%02x" % $&[0].ord }
end
# And the reverse operation
diff -Nur --exclude=doc ruby-1.8.5-p12/lib/rdoc/usage.rb ../rdoc-f95-20070109/usage.rb
--- ruby-1.8.5-p12/lib/rdoc/usage.rb 2006-01-28 07:58:07.000000000 +0900
+++ ../rdoc-f95-20070109/usage.rb 2005-09-22 16:49:18.000000000 +0900
@@ -96,7 +96,7 @@
# Display usage
def RDoc.usage_no_exit(*args)
- main_program_file = caller[-1].sub(/:\d+$/, '')
+ main_program_file, = caller[-1].split(/:\d+/, 2)
comment = File.open(main_program_file) do |file|
find_comment(file)
end