1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc: Update to RDoc 4.1.0.preview.1

RDoc 4.1.0 contains a number of enhancements including a new default
  style and accessibility support.  You can see the changelog here:

  https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc

* test/rdoc:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-09-18 23:33:36 +00:00
parent fed428007c
commit df7dac9174
118 changed files with 5394 additions and 3600 deletions

View file

@ -1,3 +1,14 @@
Thu Sep 19 08:33:14 2013 Eric Hodel <drbrain@segment7.net>
* lib/rdoc: Update to RDoc 4.1.0.preview.1
RDoc 4.1.0 contains a number of enhancements including a new default
style and accessibility support. You can see the changelog here:
https://github.com/rdoc/rdoc/blob/v4.1.0.preview.1/History.rdoc
* test/rdoc: ditto.
Thu Sep 19 07:16:26 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb: updating Psych version

View file

@ -14,7 +14,7 @@ $DEBUG_RDOC = nil
#
# == Roadmap
#
# If you think you found a bug in RDoc see DEVELOPERS@Bugs
# If you think you found a bug in RDoc see CONTRIBUTING@Bugs
#
# If you want to use RDoc to create documentation for your Ruby source files,
# see RDoc::Markup and refer to <tt>rdoc --help</tt> for command line usage.
@ -42,7 +42,7 @@ $DEBUG_RDOC = nil
#
# If you want to write your own output generator see RDoc::Generator.
#
# If you want an overview of how RDoc works see DEVELOPERS
# If you want an overview of how RDoc works see CONTRIBUTING
#
# == Credits
#
@ -64,7 +64,7 @@ module RDoc
##
# RDoc version you are using
VERSION = '4.0.0'
VERSION = '4.1.0.preview.1'
##
# Method visibilities
@ -174,6 +174,7 @@ module RDoc
autoload :Attr, 'rdoc/attr'
autoload :Constant, 'rdoc/constant'
autoload :Mixin, 'rdoc/mixin'
autoload :Include, 'rdoc/include'
autoload :Extend, 'rdoc/extend'
autoload :Require, 'rdoc/require'

View file

@ -9,8 +9,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
# Added calls_super
# Added parent name and class
# Added section title
# 3::
# RDoc 4.1
# Added is_alias_for
MARSHAL_VERSION = 2 # :nodoc:
MARSHAL_VERSION = 3 # :nodoc:
##
# Don't rename \#initialize to \::new
@ -25,7 +28,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
##
# Different ways to call this method
attr_accessor :call_seq
attr_reader :call_seq
##
# Parameters for this method
@ -89,6 +92,37 @@ class RDoc::AnyMethod < RDoc::MethodAttr
end
end
##
# Sets the different ways you can call this method. If an empty +call_seq+
# is given nil is assumed.
#
# See also #param_seq
def call_seq= call_seq
return if call_seq.empty?
@call_seq = call_seq
end
##
# Loads is_alias_for from the internal name. Returns nil if the alias
# cannot be found.
def is_alias_for # :nodoc:
case @is_alias_for
when RDoc::MethodAttr then
@is_alias_for
when Array then
return nil unless @store
klass_name, singleton, method_name = @is_alias_for
return nil unless klass = @store.find_class_or_module(klass_name)
@is_alias_for = klass.find_method method_name, singleton
end
end
##
# Dumps this AnyMethod for use by ri. See also #marshal_load
@ -97,6 +131,12 @@ class RDoc::AnyMethod < RDoc::MethodAttr
[a.name, parse(a.comment)]
end
is_alias_for = [
@is_alias_for.parent.full_name,
@is_alias_for.singleton,
@is_alias_for.name
] if @is_alias_for
[ MARSHAL_VERSION,
@name,
full_name,
@ -112,6 +152,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
@parent.name,
@parent.class,
@section.title,
is_alias_for,
]
end
@ -126,7 +167,6 @@ class RDoc::AnyMethod < RDoc::MethodAttr
initialize_visibility
@dont_rename_initialize = nil
@is_alias_for = nil
@token_stream = nil
@aliases = []
@parent = nil
@ -150,6 +190,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
@parent_name = array[12]
@parent_title = array[13]
@section_title = array[14]
@is_alias_for = array[15]
array[8].each do |new_name, comment|
add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)
@ -174,7 +215,10 @@ class RDoc::AnyMethod < RDoc::MethodAttr
def name
return @name if @name
@name = @call_seq[/^.*?\.(\w+)/, 1] || @call_seq if @call_seq
@name =
@call_seq[/^.*?\.(\w+)/, 1] ||
@call_seq[/^.*?(\w+)/, 1] ||
@call_seq if @call_seq
end
##

View file

@ -169,6 +169,18 @@ class RDoc::ClassModule < RDoc::Context
includes.map { |i| i.module }.reverse
end
def aref_prefix # :nodoc:
raise NotImplementedError, "missing aref_prefix for #{self.class}"
end
##
# HTML fragment reference for this module or class. See
# RDoc::NormalClass#aref and RDoc::NormalModule#aref
def aref
"#{aref_prefix}-#{full_name}"
end
##
# Ancestors of this class or module only
@ -224,7 +236,9 @@ class RDoc::ClassModule < RDoc::Context
# #received_nodoc true?
def documented?
super or !@comment_location.empty?
return true if @received_nodoc
return false if @comment_location.empty?
@comment_location.any? { |comment, _| not comment.empty? }
end
##
@ -282,16 +296,18 @@ class RDoc::ClassModule < RDoc::Context
def marshal_dump # :nodoc:
attrs = attributes.sort.map do |attr|
next unless attr.display?
[ attr.name, attr.rw,
attr.visibility, attr.singleton, attr.file_name,
]
end
end.compact
method_types = methods_by_type.map do |type, visibilities|
visibilities = visibilities.map do |visibility, methods|
method_names = methods.map do |method|
next unless method.display?
[method.name, method.file_name]
end
end.compact
[visibility, method_names.uniq]
end
@ -305,14 +321,16 @@ class RDoc::ClassModule < RDoc::Context
@superclass,
parse(@comment_location),
attrs,
constants,
constants.select { |constant| constant.display? },
includes.map do |incl|
next unless incl.display?
[incl.name, parse(incl.comment), incl.file_name]
end,
end.compact,
method_types,
extends.map do |ext|
next unless ext.display?
[ext.name, parse(ext.comment), ext.file_name]
end,
end.compact,
@sections.values,
@in_files.map do |tl|
tl.relative_name

View file

@ -20,8 +20,9 @@
# * RDoc::MetaMethod
# * RDoc::Alias
# * RDoc::Constant
# * RDoc::Require
# * RDoc::Include
# * RDoc::Mixin
# * RDoc::Require
# * RDoc::Include
class RDoc::CodeObject
@ -92,7 +93,7 @@ class RDoc::CodeObject
##
# The RDoc::Store for this object.
attr_accessor :store
attr_reader :store
##
# We are the model of the code, but we know that at some point we will be
@ -105,16 +106,17 @@ class RDoc::CodeObject
# Creates a new CodeObject that will document itself and its children
def initialize
@metadata = {}
@comment = ''
@parent = nil
@parent_name = nil # for loading
@parent_class = nil # for loading
@section = nil
@section_title = nil # for loading
@file = nil
@full_name = nil
@store = nil
@metadata = {}
@comment = ''
@parent = nil
@parent_name = nil # for loading
@parent_class = nil # for loading
@section = nil
@section_title = nil # for loading
@file = nil
@full_name = nil
@store = nil
@track_visibility = true
initialize_visibility
end
@ -129,6 +131,8 @@ class RDoc::CodeObject
@force_documentation = false
@received_nodoc = false
@ignored = false
@suppressed = false
@track_visibility = true
end
##
@ -155,10 +159,17 @@ class RDoc::CodeObject
end
##
# Should this CodeObject be shown in documentation?
# Should this CodeObject be displayed in output?
#
# A code object should be displayed if:
#
# * The item didn't have a nodoc or wasn't in a container that had nodoc
# * The item wasn't ignored
# * The item has documentation and was not suppressed
def display?
@document_self and not @ignored
@document_self and not @ignored and
(documented? or not @suppressed)
end
##
@ -166,6 +177,8 @@ class RDoc::CodeObject
# has been turned off by :enddoc:
def document_children=(document_children)
return unless @track_visibility
@document_children = document_children unless @done_documenting
end
@ -175,6 +188,7 @@ class RDoc::CodeObject
# documentation is turned off by +:nodoc:+.
def document_self=(document_self)
return unless @track_visibility
return if @done_documenting
@document_self = document_self
@ -198,8 +212,9 @@ class RDoc::CodeObject
# will have no effect in the current file.
def done_documenting=(value)
@done_documenting = value
@document_self = !value
return unless @track_visibility
@done_documenting = value
@document_self = !value
@document_children = @document_self
end
@ -249,7 +264,7 @@ class RDoc::CodeObject
##
# Use this to ignore a CodeObject and all its children until found again
# (#record_location is called). An ignored item will not be shown in
# (#record_location is called). An ignored item will not be displayed in
# documentation.
#
# See github issue #55
@ -259,10 +274,13 @@ class RDoc::CodeObject
# and modules to add new documentation to previously created classes.
#
# If a class was ignored (via stopdoc) then reopened later with additional
# documentation it should be shown. If a class was ignored and never
# reopened it should not be shown. The ignore flag allows this to occur.
# documentation it should be displayed. If a class was ignored and never
# reopened it should not be displayed. The ignore flag allows this to
# occur.
def ignore
return unless @track_visibility
@ignored = true
stop_doc
@ -270,11 +288,27 @@ class RDoc::CodeObject
##
# Has this class been ignored?
#
# See also #ignore
def ignored?
@ignored
end
##
# The options instance from the store this CodeObject is attached to, or a
# default options instance if the CodeObject is not attached.
#
# This is used by Text#snippet
def options
if @store and @store.rdoc then
@store.rdoc.options
else
RDoc::Options.new
end
end
##
# Our parent CodeObject. The parent may be missing for classes loaded from
# legacy RI data stores.
@ -316,8 +350,9 @@ class RDoc::CodeObject
# Records the RDoc::TopLevel (file) where this code object was defined
def record_location top_level
@ignored = false
@file = top_level
@ignored = false
@suppressed = false
@file = top_level
end
##
@ -339,16 +374,56 @@ class RDoc::CodeObject
@document_self = true
@document_children = true
@ignored = false
@ignored = false
@suppressed = false
end
##
# Disable capture of documentation
def stop_doc
return unless @track_visibility
@document_self = false
@document_children = false
end
##
# Sets the +store+ that contains this CodeObject
def store= store
@store = store
return unless @track_visibility
if :nodoc == options.visibility then
initialize_visibility
@track_visibility = false
end
end
##
# Use this to suppress a CodeObject and all its children until the next file
# it is seen in or documentation is discovered. A suppressed item with
# documentation will be displayed while an ignored item with documentation
# may not be displayed.
def suppress
return unless @track_visibility
@suppressed = true
stop_doc
end
##
# Has this class been suppressed?
#
# See also #suppress
def suppressed?
@suppressed
end
end

View file

@ -118,9 +118,6 @@ class RDoc::Comment
seq.gsub!(/^\s*/, '')
method.call_seq = seq
end
#elsif @text.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '') then
# method.call_seq = $1.strip
#end
method
end

View file

@ -167,6 +167,24 @@ class RDoc::Context < RDoc::CodeObject
full_name <=> other.full_name
end
##
# Adds an item of type +klass+ with the given +name+ and +comment+ to the
# context.
#
# Currently only RDoc::Extend and RDoc::Include are supported.
def add klass, name, comment
if RDoc::Extend == klass then
ext = RDoc::Extend.new name, comment
add_extend ext
elsif RDoc::Include == klass then
incl = RDoc::Include.new name, comment
add_include incl
else
raise NotImplementedError, "adding a #{klass} is not implemented"
end
end
##
# Adds +an_alias+ that is automatically resolved
@ -1041,8 +1059,8 @@ class RDoc::Context < RDoc::CodeObject
#--
# TODO mark the visibility of attributes in the template (if not public?)
def remove_invisible(min_visibility)
return if min_visibility == :private
def remove_invisible min_visibility
return if [:private, :nodoc].include? min_visibility
remove_invisible_in @method_list, min_visibility
remove_invisible_in @attributes, min_visibility
end

View file

@ -18,7 +18,7 @@ class RDoc::CrossReference
#
# See CLASS_REGEXP_STR
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===)(?:\([\w.+*/=<>-]*\))?'
METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>)(?:\([\w.+*/=<>-]*\))?'
##
# Regular expressions matching text that should potentially have

View file

@ -1,117 +1,9 @@
##
# A Module extension in a class with \#extend
# A Module extension to a class with \#extend
#
# RDoc::Extend.new 'Enumerable', 'comment ...'
class RDoc::Extend < RDoc::CodeObject
##
# Name of extension module
attr_accessor :name
##
# Creates a new Extend for +name+ with +comment+
def initialize(name, comment)
super()
@name = name
self.comment = comment
@module = nil # cache for module if found
end
##
# Extends are sorted by name
def <=> other
return unless self.class === other
name <=> other.name
end
def == other # :nodoc:
self.class === other and @name == other.name
end
alias eql? ==
##
# Full name based on #module
def full_name
m = self.module
RDoc::ClassModule === m ? m.full_name : @name
end
def hash # :nodoc:
[@name, self.module].hash
end
def inspect # :nodoc:
"#<%s:0x%x %s.extend %s>" % [
self.class,
object_id,
parent_name, @name,
]
end
##
# Attempts to locate the extend module object. Returns the name if not
# known.
#
# The scoping rules of Ruby to resolve the name of an extension module are:
# - first look into the children of the current context;
# - if not found, look into the children of extension modules,
# in reverse extend order;
# - if still not found, go up the hierarchy of names.
#
# This method has <code>O(n!)</code> behavior when the module calling
# extend is referencing nonexistent modules. Avoid calling #module until
# after all the files are parsed. This behavior is due to ruby's constant
# lookup behavior.
def module
return @module if @module
# search the current context
return @name unless parent
full_name = parent.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
return @name if @name =~ /^::/
# search the includes before this one, in reverse order
searched = parent.extends.take_while { |i| i != self }.reverse
searched.each do |i|
ext = i.module
next if String === ext
full_name = ext.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
end
# go up the hierarchy of names
up = parent.parent
while up
full_name = up.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
up = up.parent
end
@name
end
##
# Sets the store for this class or module and its contained code objects.
def store= store
super
@file = @store.add_file @file.full_name if @file
end
def to_s # :nodoc:
"extend #@name in: #{parent}"
end
class RDoc::Extend < RDoc::Mixin
end

View file

@ -57,6 +57,21 @@ class RDoc::Generator::Darkfish
include ERB::Util
##
# Stylesheets, fonts, etc. that are included in RDoc.
BUILTIN_STYLE_ITEMS = # :nodoc:
%w[
fonts.css
fonts/Lato-Light.ttf
fonts/Lato-LightItalic.ttf
fonts/Lato-Regular.ttf
fonts/Lato-RegularItalic.ttf
fonts/SourceCodePro-Bold.ttf
fonts/SourceCodePro-Regular.ttf
rdoc.css
]
##
# Path to this file's parent directory. Used to find templates and other
# resources.
@ -127,6 +142,11 @@ class RDoc::Generator::Darkfish
attr_reader :store
##
# The directory where the template files live
attr_reader :template_dir # :nodoc:
##
# The output directory
@ -195,7 +215,13 @@ class RDoc::Generator::Darkfish
debug_msg "Copying static files"
options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
FileUtils.cp @template_dir + 'rdoc.css', '.', options
BUILTIN_STYLE_ITEMS.each do |item|
install_rdoc_static_file @template_dir + item, "./#{item}", options
end
@options.template_stylesheets.each do |stylesheet|
FileUtils.cp stylesheet, '.', options
end
Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
next if File.directory? path
@ -203,11 +229,7 @@ class RDoc::Generator::Darkfish
dst = Pathname.new(path).relative_path_from @template_dir
# I suck at glob
dst_dir = dst.dirname
FileUtils.mkdir_p dst_dir, options unless File.exist? dst_dir
FileUtils.cp @template_dir + path, dst, options
install_rdoc_static_file @template_dir + path, dst, options
end
end
@ -447,7 +469,7 @@ class RDoc::Generator::Darkfish
##
# Generates the 404 page for the RDoc servlet
def generate_servlet_not_found path
def generate_servlet_not_found message
setup
template_file = @template_dir + 'servlet_not_found.rhtml'
@ -530,6 +552,23 @@ class RDoc::Generator::Darkfish
raise error
end
def install_rdoc_static_file source, destination, options # :nodoc:
return unless source.exist?
begin
FileUtils.mkdir_p File.dirname(destination), options
begin
FileUtils.ln source, destination, options
rescue Errno::EEXIST
FileUtils.rm destination
retry
end
rescue
FileUtils.cp source, destination, options
end
end
##
# Prepares for generation of output from the current directory

View file

@ -1,5 +1,5 @@
<footer id="validator-badges">
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> <%= RDoc::VERSION %>.
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> <%= RDoc::Generator::Darkfish::VERSION %>.
<footer id="validator-badges" role="contentinfo">
<p><a href="http://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> <%= RDoc::VERSION %>.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

View file

@ -1,16 +1,22 @@
<meta content="text/html; charset=<%= @options.charset %>" http-equiv="Content-Type">
<meta charset="<%= @options.charset %>">
<title><%= h @title %></title>
<link type="text/css" media="screen" href="<%= asset_rel_prefix %>/rdoc.css" rel="stylesheet">
<link href="<%= asset_rel_prefix %>/fonts.css" rel="stylesheet">
<link href="<%= asset_rel_prefix %>/rdoc.css" rel="stylesheet">
<% if @options.template_stylesheets.flatten.any? then %>
<% @options.template_stylesheets.flatten.each do |stylesheet| %>
<link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
<% end %>
<% end %>
<script type="text/javascript">
var rdoc_rel_prefix = "<%= rel_prefix %>/";
</script>
<script type="text/javascript" charset="utf-8" src="<%= asset_rel_prefix %>/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="<%= asset_rel_prefix %>/js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="<%= search_index_rel_prefix %>/js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="<%= asset_rel_prefix %>/js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="<%= asset_rel_prefix %>/js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="<%= asset_rel_prefix %>/js/darkfish.js"></script>
<script src="<%= asset_rel_prefix %>/js/jquery.js"></script>
<script src="<%= asset_rel_prefix %>/js/navigation.js"></script>
<script src="<%= search_index_rel_prefix %>/js/search_index.js"></script>
<script src="<%= asset_rel_prefix %>/js/search.js"></script>
<script src="<%= asset_rel_prefix %>/js/searcher.js"></script>
<script src="<%= asset_rel_prefix %>/js/darkfish.js"></script>

View file

@ -1,6 +1,7 @@
<% if !svninfo.empty? then %>
<nav id="file-svninfo-section" class="section">
<h3 class="section-header">VCS Info</h3>
<div id="file-svninfo-section" class="nav-section">
<h3>VCS Info</h3>
<div class="section-body">
<dl class="svninfo">
<dt>Rev
@ -14,5 +15,5 @@
<dd><%= svninfo[:committer] %>
</dl>
</div>
</nav>
</div>
<% end %>

View file

@ -1,9 +1,9 @@
<nav id="classindex-section" class="section project-section">
<h3 class="section-header">Class and Module Index</h3>
<div id="classindex-section" class="nav-section">
<h3>Class and Module Index</h3>
<ul class="link-list">
<% @modsort.each do |index_klass| %>
<li><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.full_name %></a>
<% end %>
</ul>
</nav>
</div>

View file

@ -1,7 +1,6 @@
<% unless klass.extends.empty? then %>
<!-- Extension Modules -->
<nav id="extends-section" class="section">
<h3 class="section-header">Extended With Modules</h3>
<div id="extends-section" class="nav-section">
<h3>Extended With Modules</h3>
<ul class="link-list">
<% klass.each_extend do |ext| %>
@ -12,5 +11,5 @@
<% end %>
<% end %>
</ul>
</nav>
</div>
<% end %>

View file

@ -1,8 +1,9 @@
<nav id="file-list-section" class="section">
<h3 class="section-header">Defined In</h3>
<div id="file-list-section" class="nav-section">
<h3>Defined In</h3>
<ul>
<% klass.in_files.each do |tl| %>
<li><%= h tl.relative_name %>
<% end %>
</ul>
</nav>
</div>

View file

@ -1,7 +1,6 @@
<% unless klass.includes.empty? then %>
<!-- Included Modules -->
<nav id="includes-section" class="section">
<h3 class="section-header">Included Modules</h3>
<div id="includes-section" class="nav-section">
<h3>Included Modules</h3>
<ul class="link-list">
<% klass.each_include do |inc| %>
@ -12,5 +11,5 @@
<% end %>
<% end %>
</ul>
</nav>
</div>
<% end %>

View file

@ -1,8 +1,9 @@
<nav id="home-section" class="section">
<h3 class="section-header">Documentation</h3>
<div id="home-section" class="nav-section">
<h3>Documentation</h3>
<ul>
<% installed.each do |name, href, exists| %>
<% installed.each do |name, href, exists, type, _| %>
<% next if type == :extra %>
<li class="folder">
<% if exists then %>
<a href="<%= href %>"><%= h name %></a>
@ -11,4 +12,4 @@
<% end %>
<% end %>
</ul>
</nav>
</div>

View file

@ -1,12 +1,12 @@
<% unless klass.method_list.empty? then %>
<!-- Method Quickref -->
<nav id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list">
<ul class="link-list" role="directory">
<% klass.each_method do |meth| %>
<li <% if meth.calls_super %>class="calls-super" <% end %>><a href="#<%= meth.aref %>"><%= meth.singleton ? '::' : '#' %><%= h meth.name %></a>
<% end %>
</ul>
</nav>
</div>
<% end %>

View file

@ -1,7 +1,11 @@
<nav id="home-section" class="section">
<h3 class="section-header">
<a href="<%= rel_prefix %>/index.html">Home</a>
<div id="home-section" role="banner" class="nav-section">
<h2>
<a href="<%= rel_prefix %>/index.html" rel="home">Home</a>
</h2>
<h3>
<a href="<%= rel_prefix %>/table_of_contents.html#pages">Pages</a>
<a href="<%= rel_prefix %>/table_of_contents.html#classes">Classes</a>
<a href="<%= rel_prefix %>/table_of_contents.html#methods">Methods</a>
</h3>
</nav>
</div>

View file

@ -1,12 +1,12 @@
<% simple_files = @files.select { |f| f.text? } %>
<% unless simple_files.empty? then %>
<nav id="fileindex-section" class="section project-section">
<h3 class="section-header">Pages</h3>
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>
<ul>
<ul class="link-list">
<% simple_files.each do |f| %>
<li class="file"><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
<% end %>
</ul>
</nav>
</div>
<% end %>

View file

@ -1,10 +1,11 @@
<% if klass.type == 'class' then %>
<nav id="parent-class-section" class="section">
<h3 class="section-header">Parent</h3>
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<% if klass.superclass and not String === klass.superclass then %>
<p class="link"><a href="<%= klass.aref_to klass.superclass.path %>"><%= klass.superclass.full_name %></a>
<% else %>
<p class="link"><%= klass.superclass %>
<% end %>
</nav>
</div>
<% end %>

View file

@ -1,10 +1,15 @@
<nav id="search-section" class="section project-section" class="initially-hidden">
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<h3 class="section-header">
<input type="text" name="search" placeholder="Search" id="search-field"
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search"
title="Type to search, Up and Down to navigate, Enter to load">
</h3>
</form>
</div>
<ul id="search-results" class="initially-hidden"></ul>
</nav>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" aria-live="polite"
aria-relevant="all" class="initially-hidden"></ul>
</form>
</div>

View file

@ -1,10 +1,11 @@
<% unless klass.sections.length == 1 then %>
<nav id="sections-section" class="section">
<h3 class="section-header">Sections</h3>
<ul class="link-list">
<div id="sections-section" class="nav-section">
<h3>Sections</h3>
<ul class="link-list" role="directory">
<% klass.sort_sections.each do |section| %>
<li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
<% end %>
</ul>
</nav>
</div>
<% end %>

View file

@ -6,14 +6,13 @@
table = current.parse(comment).table_of_contents
if table.length > 1 then %>
<div id="table-of-contents">
<nav class="section">
<h3 class="section-header">Table of Contents</h3>
<ul>
<div class="nav-section">
<h3>Table of Contents</h3>
<ul class="link-list" role="directory">
<% table.each do |heading| %>
<li><a href="#<%= heading.aref %>"><%= heading.plain_html %></a>
<li><a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
<% end %>
</ul>
</nav>
</ul>
</div>
<% end %>

View file

@ -1,16 +1,12 @@
<body id="top" class="<%= klass.type %>">
<nav id="metadata">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
<body id="top" role="document" class="<%= klass.type %>">
<nav role="navigation">
<div id="project-navigation">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
</div>
<%= render '_sidebar_table_of_contents.rhtml' %>
<div id="file-metadata">
<%= render '_sidebar_in_files.rhtml' %>
<%= render '_sidebar_VCS_info.rhtml' %>
</div>
<div id="class-metadata">
<%= render '_sidebar_sections.rhtml' %>
<%= render '_sidebar_parent.rhtml' %>
@ -18,52 +14,50 @@
<%= render '_sidebar_extends.rhtml' %>
<%= render '_sidebar_methods.rhtml' %>
</div>
<div id="project-metadata">
<%= render '_sidebar_pages.rhtml' %>
<%= render '_sidebar_classes.rhtml' %>
</div>
</nav>
<div id="documentation">
<h1 class="<%= klass.type %>"><%= klass.type %> <%= klass.full_name %></h1>
<main role="main" aria-labelledby="<%=h klass.aref %>">
<h1 id="<%=h klass.aref %>" class="<%= klass.type %>">
<%= klass.type %> <%= klass.full_name %>
</h1>
<div id="description" class="description">
<section class="description">
<%= klass.description %>
</div><!-- description -->
</section>
<% klass.each_section do |section, constants, attributes| %>
<% constants = constants.select { |const| const.display? } %>
<% attributes = attributes.select { |attr| attr.display? } %>
<section id="<%= section.aref %>" class="documentation-section">
<% if section.title then %>
<div class="documentation-section-title">
<h2 class="section-header">
<header class="documentation-section-title">
<h2>
<%= section.title %>
</h2>
<span class="section-click-top">
<a href="#top">&uarr; top</a>
</span>
</div>
</header>
<% end %>
<% if section.comment then %>
<div class="description">
<div>
<%= section.description %>
</div>
<% end %>
<% unless constants.empty? then %>
<!-- Constants -->
<section id="constants-list" class="section">
<h3 class="section-header">Constants</h3>
<section class="constants-list">
<header>
<h3>Constants</h3>
</header>
<dl>
<% constants.each do |const| %>
<dt id="<%= const.name %>"><%= const.name %>
<% if const.comment then %>
<dd class="description"><%= const.description.strip %>
<dd><%= const.description.strip %>
<% else %>
<dd class="description missing-docs">(Not documented)
<dd class="missing-docs">(Not documented)
<% end %>
<% end %>
</dl>
@ -71,9 +65,10 @@
<% end %>
<% unless attributes.empty? then %>
<!-- Attributes -->
<section id="attribute-method-details" class="method-section section">
<h3 class="section-header">Attributes</h3>
<section class="attribute-method-details" class="method-section">
<header>
<h3>Attributes</h3>
</header>
<% attributes.each do |attrib| %>
<div id="<%= attrib.aref %>" class="method-detail">
@ -91,16 +86,17 @@
</div>
</div>
<% end %>
</section><!-- attribute-method-details -->
</section>
<% end %>
<!-- Methods -->
<% klass.methods_by_type(section).each do |type, visibilities|
next if visibilities.empty?
visibilities.each do |visibility, methods|
next if methods.empty? %>
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section section">
<h3 class="section-header"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section">
<header>
<h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
</header>
<% methods.each do |method| %>
<div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
@ -146,7 +142,7 @@
<% if method.token_stream then %>
<div class="method-source-code" id="<%= method.html_name %>-source">
<pre><%= method.markup_code %></pre>
</div><!-- <%= method.html_name %>-source -->
</div>
<% end %>
</div>
@ -167,13 +163,12 @@
Alias for: <a href="<%= klass.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
</div>
<% end %>
</div><!-- <%= method.html_name %>-method -->
</div>
<% end %>
</section><!-- <%= visibility %>-<%= type %>-method-details -->
</section>
<% end
end %>
</section><!-- <%= section.aref %> -->
</section>
<% end %>
</div><!-- documentation -->
</main>

View file

@ -0,0 +1,167 @@
/*
* Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
* with Reserved Font Name "Source". All Rights Reserved. Source is a
* trademark of Adobe Systems Incorporated in the United States and/or other
* countries.
*
* This Font Software is licensed under the SIL Open Font License, Version
* 1.1.
*
* This license is copied below, and is also available with a FAQ at:
* http://scripts.sil.org/OFL
*/
@font-face {
font-family: "Source Code Pro";
font-style: normal;
font-weight: 400;
src: local("Source Code Pro"),
local("SourceCodePro-Regular"),
url("fonts/SourceCodePro-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Source Code Pro";
font-style: normal;
font-weight: 700;
src: local("Source Code Pro Bold"),
local("SourceCodePro-Bold"),
url("fonts/SourceCodePro-Bold.ttf") format("truetype");
}
/*
* Copyright (c) 2010, Łukasz Dziedzic (dziedzic@typoland.com),
* with Reserved Font Name Lato.
*
* This Font Software is licensed under the SIL Open Font License, Version
* 1.1.
*
* This license is copied below, and is also available with a FAQ at:
* http://scripts.sil.org/OFL
*/
@font-face {
font-family: "Lato";
font-style: normal;
font-weight: 300;
src: local("Lato Light"),
local("Lato-Light"),
url("fonts/Lato-Light.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: italic;
font-weight: 300;
src: local("Lato Light Italic"),
local("Lato-LightItalic"),
url("fonts/Lato-LightItalic.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: normal;
font-weight: 700;
src: local("Lato Regular"),
local("Lato-Regular"),
url("fonts/Lato-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: italic;
font-weight: 700;
src: local("Lato Italic"),
local("Lato-Italic"),
url("fonts/Lato-RegularItalic.ttf") format("truetype");
}
/*
* -----------------------------------------------------------
* SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
* -----------------------------------------------------------
*
* PREAMBLE
* The goals of the Open Font License (OFL) are to stimulate worldwide
* development of collaborative font projects, to support the font creation
* efforts of academic and linguistic communities, and to provide a free and
* open framework in which fonts may be shared and improved in partnership
* with others.
*
* The OFL allows the licensed fonts to be used, studied, modified and
* redistributed freely as long as they are not sold by themselves. The
* fonts, including any derivative works, can be bundled, embedded,
* redistributed and/or sold with any software provided that any reserved
* names are not used by derivative works. The fonts and derivatives,
* however, cannot be released under any other type of license. The
* requirement for fonts to remain under this license does not apply
* to any document created using the fonts or their derivatives.
*
* DEFINITIONS
* "Font Software" refers to the set of files released by the Copyright
* Holder(s) under this license and clearly marked as such. This may
* include source files, build scripts and documentation.
*
* "Reserved Font Name" refers to any names specified as such after the
* copyright statement(s).
*
* "Original Version" refers to the collection of Font Software components as
* distributed by the Copyright Holder(s).
*
* "Modified Version" refers to any derivative made by adding to, deleting,
* or substituting -- in part or in whole -- any of the components of the
* Original Version, by changing formats or by porting the Font Software to a
* new environment.
*
* "Author" refers to any designer, engineer, programmer, technical
* writer or other person who contributed to the Font Software.
*
* PERMISSION & CONDITIONS
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of the Font Software, to use, study, copy, merge, embed, modify,
* redistribute, and sell modified and unmodified copies of the Font
* Software, subject to the following conditions:
*
* 1) Neither the Font Software nor any of its individual components,
* in Original or Modified Versions, may be sold by itself.
*
* 2) Original or Modified Versions of the Font Software may be bundled,
* redistributed and/or sold with any software, provided that each copy
* contains the above copyright notice and this license. These can be
* included either as stand-alone text files, human-readable headers or
* in the appropriate machine-readable metadata fields within text or
* binary files as long as those fields can be easily viewed by the user.
*
* 3) No Modified Version of the Font Software may use the Reserved Font
* Name(s) unless explicit written permission is granted by the corresponding
* Copyright Holder. This restriction only applies to the primary font name as
* presented to the users.
*
* 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
* Software shall not be used to promote, endorse or advertise any
* Modified Version, except to acknowledge the contribution(s) of the
* Copyright Holder(s) and the Author(s) or with their explicit written
* permission.
*
* 5) The Font Software, modified or unmodified, in part or in whole,
* must be distributed entirely under this license, and must not be
* distributed under any other license. The requirement for fonts to
* remain under this license does not apply to any document created
* using the Font Software.
*
* TERMINATION
* This license becomes null and void if any of the above conditions are
* not met.
*
* DISCLAIMER
* THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
* OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
* DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
* OTHER DEALINGS IN THE FONT SOFTWARE.
*/

View file

@ -1,8 +1,10 @@
<body>
<nav id="metadata">
<%= render '_sidebar_navigation.rhtml' %>
<body id="top" role="document" class="file">
<nav role="navigation">
<div id="project-navigation">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
</div>
<div id="project-metadata">
<%= render '_sidebar_pages.rhtml' %>
@ -10,10 +12,12 @@
</div>
</nav>
<div id="documentation" class="description">
<% if @options.main_page && main_page = @files.find { |f| f.full_name == @options.main_page } then %>
<main role="main">
<% if @options.main_page and
main_page = @files.find { |f| f.full_name == @options.main_page } then %>
<%= main_page.description %>
<% else %>
<p>This is the API documentation for <%= @title %>.
<% end %>
</div>
</main>

View file

@ -52,20 +52,6 @@ function hookDebuggingToggle() {
$('#debugging-toggle img').click( toggleDebuggingSection );
};
function hookTableOfContentsToggle() {
$('.indexpage li .toc-toggle').each( function() {
$(this).click( function() {
$(this).toggleClass('open');
});
var section = $(this).next();
$(this).click( function() {
section.slideToggle();
});
});
}
function hookSearch() {
var input = $('#search-field').eq(0);
var result = $('#search-results').eq(0);
@ -149,7 +135,6 @@ $(document).ready( function() {
hookDebuggingToggle();
hookSearch();
highlightLocationTarget();
hookTableOfContentsToggle();
$('ul.link-list a').bind( "click", highlightClickTarget );
});

View file

@ -39,9 +39,12 @@ Search.prototype = $.extend({}, Navigation, new function() {
if (value == '') {
this.lastQuery = value;
this.$result.empty();
this.$result.attr('aria-expanded', 'false');
this.setNavigationActive(false);
} else if (value != this.lastQuery) {
this.lastQuery = value;
this.$result.attr('aria-busy', 'true');
this.$result.attr('aria-expanded', 'true');
this.firstRun = true;
this.searcher.find(value);
}
@ -55,23 +58,28 @@ Search.prototype = $.extend({}, Navigation, new function() {
}
for (var i=0, l = results.length; i < l; i++) {
target.appendChild(this.renderItem.call(this, results[i]));
var item = this.renderItem.call(this, results[i]);
item.setAttribute('id', 'search-result-' + target.childElementCount);
target.appendChild(item);
};
if (this.firstRun && results.length > 0) {
this.firstRun = false;
this.$current = $(target.firstChild);
this.$current.addClass('current');
this.$current.addClass('search-selected');
}
if (jQuery.browser.msie) this.$element[0].className += '';
if (isLast) this.$result.attr('aria-busy', 'false');
}
this.move = function(isDown) {
if (!this.$current) return;
var $next = this.$current[isDown ? 'next' : 'prev']();
if ($next.length) {
this.$current.removeClass('current');
$next.addClass('current');
this.$current.removeClass('search-selected');
$next.addClass('search-selected');
this.$input.attr('aria-activedescendant', $next.attr('id'));
this.scrollIntoView($next[0], this.$view[0]);
this.$current = $next;
}

View file

@ -1,18 +1,18 @@
<body class="file">
<nav id="metadata">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
<body id="top" role="document" class="file">
<nav role="navigation">
<div id="project-navigation">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
</div>
<%= render '_sidebar_table_of_contents.rhtml' %>
<div id="project-metadata">
<%= render '_sidebar_pages.rhtml' %>
<%= render '_sidebar_classes.rhtml' %>
</div>
</nav>
<div id="documentation" class="description">
<%= file.description %>
</div>
<main role="main" aria-label="Page <%=h file.full_name%>">
<%= file.description %>
</main>

View file

@ -12,21 +12,10 @@
* { padding: 0; margin: 0; }
body {
background: #efefef;
font: 14px "Helvetica Neue", Helvetica, Tahoma, sans-serif;
margin-left: 40px;
background: #fafafa;
font-family: Lato, sans-serif;
font-weight: 300;
}
body.file-popup {
font-size: 90%;
margin-left: 0;
}
h1 {
font-size: 300%;
text-shadow: rgba(135,145,135,0.65) 2px 2px 3px;
color: #6C8C22;
}
h2,h3,h4 { margin-top: 1.5em; }
h1 span,
h2 span,
@ -36,7 +25,7 @@ h5 span,
h6 span {
display: none;
padding-left: 1em;
font-size: 50%;
font-size: 10px;
vertical-align: super;
}
@ -54,24 +43,15 @@ h6:hover span {
color: #6C8C22;
text-decoration: none;
}
:link:hover,
:visited:hover {
border-bottom: 1px dotted #6C8C22;
}
code,
pre {
background: #ddd;
padding: 0.5em 0;
}
blockquote {
background: #ddd;
margin: 1em;
padding: 0.25em;
}
blockquote > :first-child {
margin-top: 0 !important;
font-family: "Source Code Pro", Monaco, monospace;
}
/* @group Generic Classes */
@ -82,10 +62,13 @@ blockquote > :first-child {
#search-field {
width: 98%;
background: #eee;
background: white;
border: none;
height: 1.5em;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
text-align: left;
}
#search-field:focus {
background: #f1edba;
@ -121,44 +104,31 @@ blockquote > :first-child {
/* @end */
/* @group Index Page, Standalone file pages */
.indexpage ul {
line-height: 160%;
.table-of-contents ul {
margin: 1em;
list-style: none;
}
.indexpage ul :link,
.indexpage ul :visited {
.table-of-contents ul ul {
margin-top: 0.25em;
}
.table-of-contents ul :link,
.table-of-contents ul :visited {
font-size: 16px;
}
.indexpage li {
padding-left: 20px;
.table-of-contents li {
margin-bottom: 0.25em;
}
.indexpage ul > li {
background: url(images/bullet_black.png) no-repeat left 4px;
}
.indexpage li.method {
background: url(images/plugin.png) no-repeat left 4px;
}
.indexpage li.module {
background: url(images/package.png) no-repeat left 4px;
}
.indexpage li.class {
background: url(images/ruby.png) no-repeat left 4px;
}
.indexpage li.file {
background: url(images/page_white_text.png) no-repeat left 4px;
}
.indexpage li li {
background: url(images/tag_blue.png) no-repeat left 4px;
}
.indexpage li .toc-toggle {
.table-of-contents li .toc-toggle {
width: 16px;
height: 16px;
background: url(images/add.png) no-repeat;
}
.indexpage li .toc-toggle.open {
.table-of-contents li .toc-toggle.open {
background: url(images/delete.png) no-repeat;
}
@ -166,14 +136,32 @@ blockquote > :first-child {
/* @group Top-Level Structure */
#metadata {
nav {
float: left;
width: 260px;
font-family: Helvetica, sans-serif;
font-size: 14px;
}
#documentation {
margin: 2em 1em 5em 300px;
main {
display: block;
margin: 0 2em 5em 260px;
padding-left: 20px;
min-width: 340px;
font-size: 16px;
}
main h1,
main h2,
main h3,
main h4,
main h5,
main h6 {
font-family: Helvetica, sans-serif;
}
.table-of-contents main {
margin-left: 2em;
}
#validator-badges {
@ -184,67 +172,68 @@ blockquote > :first-child {
/* @end */
/* @group Metadata Section */
#metadata .section {
background-color: #dedede;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #aaa;
margin: 0 8px 8px;
/* @group navigation */
nav {
margin-bottom: 1em;
}
nav .nav-section {
margin-top: 2em;
border-top: 2px solid #aaa;
font-size: 90%;
overflow: hidden;
}
#metadata h3.section-header {
nav h2 {
margin: 0;
padding: 2px 8px;
background: #ccc;
color: #666;
-moz-border-radius-topleft: 4px;
-moz-border-radius-topright: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
border-bottom: 1px solid #aaa;
}
#metadata #home-section h3.section-header {
border-bottom: 0;
padding: 2px 8px 2px 8px;
background-color: #e8e8e8;
color: #555;
font-size: 125%;
text-align: center;
}
#metadata ul,
#metadata dl,
#metadata p {
padding: 8px;
nav h3 {
margin: 0;
padding: 2px 8px 2px 8px;
text-align: right;
background-color: #e8e8e8;
color: #555;
}
nav ul,
nav dl,
nav p {
padding: 4px 8px 0;
list-style: none;
}
#file-metadata {
margin-top: 2em;
}
#file-metadata ul {
padding-left: 28px;
list-style-image: url(images/page_green.png);
}
#table-of-contents {
margin-top: 2em;
}
#table-of-contents ul {
padding-left: 28px;
list-style-image: url(images/tag_blue.png);
}
dl.svninfo {
color: #666;
#project-navigation .nav-section {
margin: 0;
border-top: 0;
}
dl.svninfo dt {
font-weight: bold;
#home-section h2,
#home-section h3 {
text-align: center;
}
#search-section {
margin-top: 0;
border-top: 0;
}
#search-field-wrapper {
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
padding: 3px 8px;
background-color: #e8e8e8;
color: #555;
}
ul.link-list li {
white-space: nowrap;
line-height: 20px;
line-height: 1.4em;
}
ul.link-list .type {
@ -262,100 +251,119 @@ ul.link-list .type {
/* @end */
/* @group Class Metadata Section */
#class-metadata {
margin-top: 2em;
}
/* @end */
/* @group Project Metadata Section */
#project-metadata {
margin-top: 2em;
}
#project-metadata .section {
border: 1px solid #aaa;
}
#project-metadata h3.section-header {
border-bottom: 1px solid #aaa;
position: relative;
}
#project-metadata form {
color: #777;
background: #ccc;
}
/* @end */
/* @group Documentation Section */
.description {
font-size: 100%;
main {
color: #333;
}
.description p {
margin: 1em 0.4em;
main > h1:first-child,
main > h2:first-child,
main > h3:first-child,
main > h4:first-child,
main > h5:first-child,
main > h6:first-child {
margin-top: 0px;
}
.description li p {
margin: 0;
main sup {
vertical-align: super;
font-size: 0.8em;
}
.description ol,
.description ul {
margin-left: 1.5em;
/* The heading with the class name */
main h1[class] {
margin-top: 0;
margin-bottom: 1em;
font-size: 2em;
color: #6C8C22;
}
.description ol li,
.description ul li {
main h1 {
margin: 2em 0 0.5em;
font-size: 1.7em;
}
main h2 {
margin: 2em 0 0.5em;
font-size: 1.5em;
}
main h3 {
margin: 2em 0 0.5em;
font-size: 1.2em;
}
main h4 {
margin: 2em 0 0.5em;
font-size: 1.1em;
}
main h5 {
margin: 2em 0 0.5em;
font-size: 1em;
}
main h6 {
margin: 2em 0 0.5em;
font-size: 1em;
}
main p {
margin: 0 0 0.5em;
line-height: 1.4em;
}
.note-list {
margin: 8px 0;
main pre {
margin: 1.2em 0.5em;
padding: 1em;
font-size: 0.8em;
}
.label-list {
margin: 8px 1.5em;
border: 1px solid #ccc;
}
.description .label-list {
font-size: 14px;
main hr {
margin: 1.5em 1em;
border: 2px solid #ddd;
}
.note-list dt {
main blockquote {
margin: 0 2em 1.2em 1.2em;
padding-left: 0.5em;
border-left: 2px solid #ddd;
}
main ol,
main ul {
margin: 1em 2em;
}
main li > p {
margin-bottom: 0.5em;
}
main dl {
margin: 1em 0.5em;
}
main dt {
margin-bottom: 0.5em;
font-weight: bold;
}
.note-list dd {
padding: 0 12px;
main dd {
margin: 0 1em 1em 0.5em;
}
.label-list dt {
padding: 2px 4px;
font-weight: bold;
background: #ddd;
}
.label-list dd {
padding: 2px 12px;
}
.label-list dd + dt,
.note-list dd + dt {
margin-top: 0.7em;
main header h2 {
margin-top: 2em;
border-width: 0;
border-top: 4px solid #bbb;
font-size: 130%;
}
#documentation .section {
font-size: 90%;
}
#documentation h2.section-header {
margin-top: 1em;
padding: 0.25em 0.5em;
background: #ccc;
color: #333;
font-size: 175%;
border: 1px solid #bbb;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
main header h3 {
margin: 2em 0 1.5em;
border-width: 0;
border-top: 3px solid #bbb;
font-size: 120%;
}
.documentation-section-title {
@ -364,47 +372,35 @@ ul.link-list .type {
.documentation-section-title .section-click-top {
position: absolute;
top: 6px;
right: 12px;
left: 12px;
font-size: 10px;
color: #9b9877;
visibility: hidden;
padding-right: 0.5px;
padding-left: 0.5px;
}
.documentation-section-title:hover .section-click-top {
visibility: visible;
}
#documentation h3.section-header {
margin-top: 1em;
padding: 0.25em 0.5em;
background-color: #dedede;
color: #333;
font-size: 150%;
border: 1px solid #bbb;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
#constants-list > dl,
#attributes-list > dl {
.constants-list > dl {
margin: 1em 0 2em;
border: 0;
}
#constants-list > dl dt,
#attributes-list > dl dt {
.constants-list > dl dt {
margin-bottom: 0.75em;
padding-left: 0;
font-weight: bold;
font-family: Monaco, "Andale Mono";
background: inherit;
font-family: "Source Code Pro", Monaco, monospace;
font-size: 110%;
}
#constants-list > dl dt a,
#attributes-list > dl dt a {
.constants-list > dl dt a {
color: inherit;
}
#constants-list > dl dd,
#attributes-list > dl dd {
margin: 0 0 1em 0;
.constants-list > dl dd {
margin: 0 0 2em 0;
padding: 0;
color: #666;
}
@ -428,93 +424,77 @@ ul.link-list .type {
/* @group Method Details */
#documentation .method-source-code {
main .method-source-code {
display: none;
}
#documentation .method-description .method-calls-super {
main .method-description .method-calls-super {
color: #333;
font-weight: bolder;
font-weight: bold;
}
#documentation .method-detail {
margin: 0.5em 0;
padding: 0.5em 0;
main .method-detail {
margin-bottom: 2.5em;
cursor: pointer;
}
#documentation .method-detail:hover {
background-color: #f1edba;
main .method-detail:target {
margin-left: -10px;
border-left: 10px solid #f1edba;
}
#documentation .method-heading {
main .method-heading {
position: relative;
padding: 2px 4px 0 20px;
font-size: 125%;
font-family: "Source Code Pro", Monaco, monospace;
font-size: 110%;
font-weight: bold;
color: #333;
background: url(images/brick.png) no-repeat left bottom;
}
#documentation .method-heading :link,
#documentation .method-heading :visited {
main .method-heading :link,
main .method-heading :visited {
color: inherit;
}
#documentation .method-click-advice {
main .method-click-advice {
position: absolute;
top: 2px;
right: 5px;
font-size: 10px;
font-size: 12px;
color: #9b9877;
visibility: hidden;
padding-right: 20px;
line-height: 20px;
background: url(images/zoom.png) no-repeat right top;
}
#documentation .method-heading:hover .method-click-advice {
main .method-heading:hover .method-click-advice {
visibility: visible;
}
#documentation .method-alias .method-heading {
color: #666;
background: url(images/brick_link.png) no-repeat left bottom;
}
#documentation .method-description,
#documentation .aliases {
margin: 0 20px;
main .method-alias .method-heading {
color: #666;
}
#documentation .method-description p,
#documentation .aliases p {
line-height: 1.2em;
main .method-description,
main .aliases {
margin-top: 0.75em;
color: #333;
}
#documentation .aliases {
main .aliases {
padding-top: 4px;
font-style: italic;
cursor: default;
}
#documentation .method-description p {
margin-bottom: 0.5em;
}
#documentation .method-description ul {
main .method-description ul {
margin-left: 1.5em;
}
pre {
margin: 0.5em 0;
}
#documentation .attribute-method-heading {
background: url(images/tag_green.png) no-repeat left bottom;
}
#documentation #attribute-method-details .method-detail:hover {
main #attribute-method-details .method-detail:hover {
background-color: transparent;
cursor: default;
}
#documentation .attribute-access-type {
font-size: 60%;
main .attribute-access-type {
text-transform: uppercase;
vertical-align: super;
padding: 0 2px;
padding: 0 1em;
}
/* @end */
@ -523,15 +503,12 @@ pre {
/* @group Source Code */
pre {
overflow: auto;
background: #262626;
color: white;
margin: 0.5em 0;
border: 1px dashed #999;
padding: 0.5em;
}
.description pre {
margin: 0 0.4em;
background: #262626;
color: white;
overflow: auto;
}
.ruby-constant { color: #7fffd4; background: transparent; }
@ -540,7 +517,7 @@ pre {
.ruby-operator { color: #00ffee; background: transparent; }
.ruby-identifier { color: #ffdead; background: transparent; }
.ruby-node { color: #ffa07a; background: transparent; }
.ruby-comment { color: #dc0000; font-weight: bold; background: transparent; }
.ruby-comment { color: #dc0000; background: transparent; }
.ruby-regexp { color: #ffa07a; background: transparent; }
.ruby-value { color: #7fffd4; background: transparent; }
@ -548,23 +525,24 @@ pre {
/* @group search results */
#search-results h1 {
font-size: 1em;
font-weight: normal;
text-shadow: none;
#search-results {
font-family: Lato, sans-serif;
font-weight: 300;
}
#search-results .current {
background: #ccc;
#search-results .search-match {
font-family: Helvetica, sans-serif;
font-weight: normal;
}
#search-results .search-selected {
background: #e8e8e8;
border-bottom: 1px solid transparent;
}
#search-results li {
list-style: none;
border-bottom: 1px solid #aaa;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
margin-bottom: 0.5em;
}
@ -589,6 +567,7 @@ pre {
#search-results pre {
margin: 0.5em;
font-family: "Source Code Pro", Monaco, monospace;
}
/* @end */

View file

@ -1,5 +1,5 @@
<body>
<nav id="metadata">
<body role="document">
<nav role="navigation">
<%= render '_sidebar_navigation.rhtml' %>
<%= render '_sidebar_search.rhtml' %>
@ -10,9 +10,9 @@
</div>
</nav>
<div id="documentation" class="description">
<main role="main">
<h1>Not Found</h1>
<p>The page <kbd><%=h path %></kbd> was not found
</div>
<p><%= message %>
</main>

View file

@ -1,16 +1,43 @@
<body>
<nav id="metadata">
<%= render '_sidebar_search.rhtml' %>
<body role="document">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" class="nav-section">
<h2>
<a href="<%= rel_prefix %>/" rel="home">Home</a>
</h2>
</div>
<%= render '_sidebar_search.rhtml' %>
</div>
<%= render '_sidebar_installed.rhtml' %>
</nav>
<div id="documentation" class="description">
<main role="main">
<h1>Local RDoc Documentation</h1>
<p>Here you can browse local documentation from the ruby standard library and
your installed gems.
<% extra_dirs = installed.select { |_, _, _, type,| type == :extra } %>
<% unless extra_dirs.empty? %>
<h2>Extra Documentation Directories</h2>
<p>The following additional documentation directories are available:</p>
<ol>
<% extra_dirs.each do |name, href, exists, _, path| %>
<li>
<% if exists %>
<a href="<%= href %>"><%= h name %></a> (<%= h path %>)
<% else %>
<%= h name %> (<%= h path %>; <i>not available</i>)
<% end %>
</li>
<% end %>
</ol>
<% end %>
<% gems = installed.select { |_, _, _, type,| type == :gem } %>
<% missing = gems.reject { |_, _, exists,| exists } %>
<% unless missing.empty? then %>
@ -32,6 +59,5 @@
<% end %>
</ul>
<% end %>
</div>
</main>

View file

@ -1,9 +1,10 @@
<body class="indexpage">
<h1><%= h @title %></h1>
<body id="top" class="table-of-contents">
<main role="main">
<h1 class="class"><%= h @title %></h1>
<% simple_files = @files.select { |f| f.text? } %>
<% unless simple_files.empty? then %>
<h2>Pages</h2>
<h2 id="pages">Pages</h2>
<ul>
<% simple_files.sort.each do |file| %>
<li class="file">
@ -12,8 +13,7 @@
# HACK table_of_contents should not exist on Document
table = file.parse(file.comment).table_of_contents
unless table.empty? then %>
<img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
<ul class="initially-hidden">
<ul>
<% table.each do |heading| %>
<li><a href="<%= file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
<% end %>
@ -24,7 +24,7 @@
</ul>
<% end %>
<h2 id="classes">Classes/Modules</h2>
<h2 id="classes">Classes and Modules</h2>
<ul>
<% @modsort.each do |klass| %>
<li class="<%= klass.type %>">
@ -34,22 +34,25 @@
table.concat klass.section_contents
unless table.empty? then %>
<img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
<ul class="initially-hidden">
<ul>
<% table.each do |item| %>
<li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
<% end %>
</ul>
<% end %>
</li>
<% end %>
<% end %>
</ul>
<h2 id="methods">Methods</h2>
<ul>
<% @store.all_classes_and_modules.map do |mod|
mod.method_list
end.flatten.sort.each do |method| %>
<li class="method"><a href="<%= method.path %>"><%= method.pretty_name %> &mdash; <%= method.parent.full_name %></a>
<% end %>
<% @store.all_classes_and_modules.map do |mod|
mod.method_list
end.flatten.sort.each do |method| %>
<li class="method">
<a href="<%= method.path %>"><%= h method.pretty_name %></a>
&mdash;
<span class="container"><%= method.parent.full_name %></span>
<% end %>
</ul>
</main>

View file

@ -1,119 +1,9 @@
##
# A Module include in a class with \#include
# A Module included in a class with \#include
#
# RDoc::Include.new 'Enumerable', 'comment ...'
class RDoc::Include < RDoc::CodeObject
##
# Name of included module
attr_accessor :name
##
# Creates a new Include for +name+ with +comment+
def initialize(name, comment)
super()
@name = name
self.comment = comment
@module = nil # cache for module if found
end
##
# Includes are sorted by name
def <=> other
return unless self.class === other
name <=> other.name
end
def == other # :nodoc:
self.class === other and @name == other.name
end
alias eql? ==
##
# Full name based on #module
def full_name
m = self.module
RDoc::ClassModule === m ? m.full_name : @name
end
def hash # :nodoc:
[@name, self.module].hash
end
def inspect # :nodoc:
"#<%s:0x%x %s.include %s>" % [
self.class,
object_id,
parent_name, @name,
]
end
##
# Attempts to locate the included module object. Returns the name if not
# known.
#
# The scoping rules of Ruby to resolve the name of an included module are:
# - first look into the children of the current context;
# - if not found, look into the children of included modules,
# in reverse inclusion order;
# - if still not found, go up the hierarchy of names.
#
# This method has <code>O(n!)</code> behavior when the module calling
# include is referencing nonexistent modules. Avoid calling #module until
# after all the files are parsed. This behavior is due to ruby's constant
# lookup behavior.
#
# As of the beginning of October, 2011, no gem includes nonexistent modules.
def module
return @module if @module
# search the current context
return @name unless parent
full_name = parent.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
return @name if @name =~ /^::/
# search the includes before this one, in reverse order
searched = parent.includes.take_while { |i| i != self }.reverse
searched.each do |i|
inc = i.module
next if String === inc
full_name = inc.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
end
# go up the hierarchy of names
up = parent.parent
while up
full_name = up.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
up = up.parent
end
@name
end
##
# Sets the store for this class or module and its contained code objects.
def store= store
super
@file = @store.add_file @file.full_name if @file
end
def to_s # :nodoc:
"include #@name in: #{parent}"
end
class RDoc::Include < RDoc::Mixin
end

View file

@ -62,6 +62,7 @@ module RDoc
"rb_mDL" => "DL",
"rb_mEnumerable" => "Enumerable",
"rb_mErrno" => "Errno",
"rb_mFConst" => "File::Constants",
"rb_mFileTest" => "FileTest",
"rb_mGC" => "GC",
"rb_mKernel" => "Kernel",

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ class RDoc::Markdown::Literals
attr_reader :failing_rule_offset
attr_accessor :result, :pos
def current_column(target=pos)
if c = string.rindex("\n", target-1)
return target - c - 1

View file

@ -59,7 +59,7 @@
#
# require 'rdoc'
#
# h = RDoc::Markup::ToHtml.new
# h = RDoc::Markup::ToHtml.new(RDoc::Options.new)
#
# puts h.convert(input_string)
#
@ -171,22 +171,13 @@
# === Rules
#
# A line starting with three or more hyphens (at the current indent)
# generates a horizontal rule. The more hyphens, the thicker the rule
# (within reason, and if supported by the output device).
#
# In the case of HTML output, three dashes generate a 1-pixel high rule,
# four dashes result in 2 pixels, and so on. The actual height is limited
# to 10 pixels:
# generates a horizontal rule.
#
# ---
# -----
# -----------------------------------------------------
#
# produces:
#
# ---
# -----
# -----------------------------------------------------
#
# === Simple Lists
#
@ -356,12 +347,18 @@
# with <tt>+</tt> like <tt>RDoc::Markup@Escaping+Text+Markup</tt>.
# Punctuation and other special characters must be escaped like CGI.escape.
#
# The <tt>@</tt> can also be used to link to sections. If a section and a
# heading share the same name the section is preferred for the link.
#
# Links can also be of the form <tt>label[url]</tt>, in which case +label+ is
# used in the displayed text, and +url+ is used as the target. If +label+
# contains multiple words, put it in braces: <tt>{multi word label}[url]</tt>.
# The +url+ may be an +http:+-type link or a cross-reference to a class,
# module or method with a label.
#
# Links with the <code>rdoc-image:</code> scheme will create an image tag for
# HTML output. Only fully-qualified URLs are supported.
#
# Links with the <tt>rdoc-ref:</tt> scheme will link to the referenced class,
# module, method, file, etc. If the referenced item is does not exist
# no link will be generated and <tt>rdoc-ref:</tt> will be removed from the
@ -713,7 +710,7 @@
# def some_method
# # ...
#
# See Markup@DEVELOPERS for instructions on adding a new markup format.
# See Markup@CONTRIBUTING for instructions on adding a new markup format.
#
# [+:include:+ _filename_]
# Include the contents of the named file at this point. This directive

View file

@ -186,8 +186,9 @@ class RDoc::Markup::AttributeManager
# protect __send__, __FILE__, etc.
@str.gsub!(/__([a-z]+)__/i,
"_#{PROTECT_ATTR}_#{PROTECT_ATTR}\\1_#{PROTECT_ATTR}_#{PROTECT_ATTR}")
@str.gsub!(/\\([#{Regexp.escape @protectable.join('')}])/,
"\\1#{PROTECT_ATTR}")
@str.gsub!(/(\A|[^\\])\\([#{Regexp.escape @protectable.join}])/m,
"\\1\\2#{PROTECT_ATTR}")
@str.gsub!(/\\(\\[#{Regexp.escape @protectable.join}])/m, "\\1")
end
##

View file

@ -80,7 +80,7 @@ class RDoc::Markup::Formatter
# Adds a special for links of the form rdoc-...:
def add_special_RDOCLINK
@markup.add_special(/rdoc-[a-z]+:\S+/, :RDOCLINK)
@markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
end
##
@ -88,7 +88,7 @@ class RDoc::Markup::Formatter
def add_special_TIDYLINK
@markup.add_special(/(?:
\{.*?\} | # multi-word label
\{.*?\} | # multi-word label
\b[^\s{}]+? # single-word label
)
@ -239,7 +239,7 @@ class RDoc::Markup::Formatter
else
scheme = 'http'
path = url
url = "http://#{url}"
url = url
end
if scheme == 'link' then

View file

@ -47,6 +47,19 @@ RDoc::Markup::Heading =
"label-#{self.class.to_label.convert text.dup}"
end
##
# Creates a fully-qualified label which will include the label from
# +context+. This helps keep ids unique in HTML.
def label context = nil
label = aref
label = [context.aref, label].compact.join '-' if
context and context.respond_to? :aref
label
end
##
# HTML markup of the text of this label without the surrounding header
# element.

View file

@ -389,7 +389,7 @@ class RDoc::Markup::Parser
skip :NEWLINE
when :TEXT then
unget
parent << build_paragraph(indent)
parse_text parent, indent
when *LIST_TOKENS then
unget
parent << build_list(indent)
@ -405,6 +405,13 @@ class RDoc::Markup::Parser
end
##
# Small hook that is overridden by RDoc::TomDoc
def parse_text parent, indent # :nodoc:
parent << build_paragraph(indent)
end
##
# Returns the next token on the stream without modifying the stream

View file

@ -151,7 +151,7 @@ class RDoc::Markup::PreProcess
case directive
when 'arg', 'args' then
return blankline unless code_object
return "#{prefix}:#{directive}: #{param}\n" unless code_object
code_object.params = param

View file

@ -65,6 +65,30 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
#
# These methods handle special markup added by RDoc::Markup#add_special.
def handle_RDOCLINK url # :nodoc:
case url
when /^rdoc-ref:/
$'
when /^rdoc-label:/
text = $'
text = case text
when /\Alabel-/ then $'
when /\Afootmark-/ then $'
when /\Afoottext-/ then $'
else text
end
gen_url url, text
when /^rdoc-image:/
"<img src=\"#{$'}\">"
else
url =~ /\Ardoc-[a-z]+:/
$'
end
end
##
# +special+ is a <code><br></code>
@ -100,27 +124,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
# when creating a link. All other contents will be linked verbatim.
def handle_special_RDOCLINK special
url = special.text
case url
when /\Ardoc-ref:/
$'
when /\Ardoc-label:/
text = $'
text = case text
when /\Alabel-/ then $'
when /\Afootmark-/ then "^#{$'}"
when /\Afoottext-/ then "*#{$'}"
else text
end
gen_url url, text
else
url =~ /\Ardoc-[a-z]+:/
$'
end
handle_RDOCLINK special.text
end
##
@ -130,10 +134,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
def handle_special_TIDYLINK(special)
text = special.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
return text unless
text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
label = $1
url = $2
label = handle_RDOCLINK label if /^rdoc-image:/ =~ label
gen_url url, label
end
@ -176,6 +184,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
def accept_paragraph paragraph
@res << "\n<p>"
text = paragraph.text @hard_break
text = text.gsub(/\r?\n/, ' ')
@res << wrap(to_html(text))
@res << "</p>\n"
end
@ -186,28 +195,33 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
def accept_verbatim verbatim
text = verbatim.text.rstrip
@res << if verbatim.ruby? or parseable? text then
begin
tokens = RDoc::RubyLex.tokenize text, @options
klass = nil
html = RDoc::TokenStream.to_html tokens
content = if verbatim.ruby? or parseable? text then
begin
tokens = RDoc::RubyLex.tokenize text, @options
klass = ' class="ruby"'
"\n<pre class=\"ruby\">#{html}</pre>\n"
rescue RDoc::RubyLex::Error
"\n<pre>#{CGI.escapeHTML text}</pre>\n"
RDoc::TokenStream.to_html tokens
rescue RDoc::RubyLex::Error
CGI.escapeHTML text
end
else
CGI.escapeHTML text
end
else
"\n<pre>#{CGI.escapeHTML text}</pre>\n"
end
if @options.pipe then
@res << "\n<pre><code>#{CGI.escapeHTML text}</code></pre>\n"
else
@res << "\n<pre#{klass}>#{content}</pre>\n"
end
end
##
# Adds +rule+ to the output
def accept_rule(rule)
size = rule.weight
size = 10 if size > 10
@res << "<hr style=\"height: #{size}px\">\n"
def accept_rule rule
@res << "<hr>\n"
end
##
@ -262,11 +276,13 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
def accept_heading heading
level = [6, heading.level].min
label = heading.aref
label = [@code_object.aref, label].compact.join '-' if
@code_object and @code_object.respond_to? :aref
label = heading.label @code_object
@res << "\n<h#{level} id=\"#{label}\">"
@res << if @options.output_decoration
"\n<h#{level} id=\"#{label}\">"
else
"\n<h#{level}>"
end
@res << to_html(heading.text)
unless @options.pipe then
@res << "<span><a href=\"##{label}\">&para;</a>"
@ -302,7 +318,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
"<img src=\"#{url}\" />"
else
"<a#{id} href=\"#{url}\">#{text.sub(%r{^#{scheme}:/*}i, '')}</a>"
text = text.sub %r%^#{scheme}:/*%i, ''
text = text.sub %r%^[*\^](\d+)$%, '\1'
link = "<a#{id} href=\"#{url}\">#{text}</a>"
link = "<sup>#{link}</sup>" if /"foot/ =~ id
link
end
end

View file

@ -145,6 +145,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
if path =~ /#/ then
path << "-label-#{label}"
elsif ref.sections and
ref.sections.any? { |section| label == section.title } then
path << "##{label}"
else
path << "#label-#{label}"
end if label

View file

@ -147,15 +147,17 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
def handle_rdoc_link url
case url
when /\Ardoc-ref:/ then
when /^rdoc-ref:/ then
$'
when /\Ardoc-label:footmark-(\d+)/ then
when /^rdoc-label:footmark-(\d+)/ then
"[^#{$1}]:"
when /\Ardoc-label:foottext-(\d+)/ then
when /^rdoc-label:foottext-(\d+)/ then
"[^#{$1}]"
when /\Ardoc-label:label-/ then
when /^rdoc-label:label-/ then
gen_url url, $'
when /\Ardoc-[a-z]+:/ then
when /^rdoc-image:/ then
"![](#{$'})"
when /^rdoc-[a-z]+:/ then
$'
end
end

View file

@ -94,6 +94,18 @@ class RDoc::MethodAttr < RDoc::CodeObject
@params = nil
end
##
# Resets cached data for the object so it can be rebuilt by accessor methods
def initialize_copy other # :nodoc:
@full_name = nil
end
def initialize_visibility # :nodoc:
super
@see = nil
end
##
# Order by #singleton then #name

120
lib/rdoc/mixin.rb Normal file
View file

@ -0,0 +1,120 @@
##
# A Mixin adds features from a module into another context. RDoc::Include and
# RDoc::Extend are both mixins.
class RDoc::Mixin < RDoc::CodeObject
##
# Name of included module
attr_accessor :name
##
# Creates a new Mixin for +name+ with +comment+
def initialize(name, comment)
super()
@name = name
self.comment = comment
@module = nil # cache for module if found
end
##
# Mixins are sorted by name
def <=> other
return unless self.class === other
name <=> other.name
end
def == other # :nodoc:
self.class === other and @name == other.name
end
alias eql? == # :nodoc:
##
# Full name based on #module
def full_name
m = self.module
RDoc::ClassModule === m ? m.full_name : @name
end
def hash # :nodoc:
[@name, self.module].hash
end
def inspect # :nodoc:
"#<%s:0x%x %s.%s %s>" % [
self.class,
object_id,
parent_name, self.class.name.downcase, @name,
]
end
##
# Attempts to locate the included module object. Returns the name if not
# known.
#
# The scoping rules of Ruby to resolve the name of an included module are:
# - first look into the children of the current context;
# - if not found, look into the children of included modules,
# in reverse inclusion order;
# - if still not found, go up the hierarchy of names.
#
# This method has <code>O(n!)</code> behavior when the module calling
# include is referencing nonexistent modules. Avoid calling #module until
# after all the files are parsed. This behavior is due to ruby's constant
# lookup behavior.
#
# As of the beginning of October, 2011, no gem includes nonexistent modules.
def module
return @module if @module
# search the current context
return @name unless parent
full_name = parent.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
return @name if @name =~ /^::/
# search the includes before this one, in reverse order
searched = parent.includes.take_while { |i| i != self }.reverse
searched.each do |i|
inc = i.module
next if String === inc
full_name = inc.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
end
# go up the hierarchy of names
up = parent.parent
while up
full_name = up.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
up = up.parent
end
@name
end
##
# Sets the store for this class or module and its contained code objects.
def store= store
super
@file = @store.add_file @file.full_name if @file
end
def to_s # :nodoc:
"#{self.class.name.downcase} #@name in: #{parent}"
end
end

View file

@ -20,6 +20,10 @@ class RDoc::NormalClass < RDoc::ClassModule
end
end
def aref_prefix # :nodoc:
'class'
end
##
# The definition of this class, <tt>class MyClassName</tt>

View file

@ -3,6 +3,10 @@
class RDoc::NormalModule < RDoc::ClassModule
def aref_prefix # :nodoc:
'module'
end
def inspect # :nodoc:
"#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
self.class, object_id,

View file

@ -52,6 +52,18 @@ require 'pathname'
# end
# end
#
# Of course, RDoc::Options does not respond to +spell_dictionary+ by default
# so you will need to add it:
#
# class RDoc::Options
#
# ##
# # The spell dictionary used by the spell-checking plugin.
#
# attr_accessor :spell_dictionary
#
# end
#
# == Option Validators
#
# OptionParser validators will validate and cast user input values. In
@ -228,6 +240,10 @@ class RDoc::Options
attr_accessor :option_parser
##
# Output heading decorations?
attr_accessor :output_decoration
##
# Directory where guides, FAQ, and other pages not associated with a class
# live. You may leave this unset if these are at the root of your project.
@ -276,6 +292,11 @@ class RDoc::Options
attr_accessor :template_dir
##
# Additional template stylesheets
attr_accessor :template_stylesheets
##
# Documentation title
@ -297,9 +318,12 @@ class RDoc::Options
attr_accessor :webcvs
##
# Minimum visibility of a documented method. One of +:public+,
# +:protected+, +:private+. May be overridden on a per-method
# basis with the :doc: directive.
# Minimum visibility of a documented method. One of +:public+, +:protected+,
# +:private+ or +:nodoc+.
#
# The +:nodoc+ visibility ignores all directives related to visibility. The
# other visibilities may be overridden on a per-method basis with the :doc:
# directive.
attr_accessor :visibility
@ -325,6 +349,7 @@ class RDoc::Options
@op_dir = nil
@page_dir = nil
@pipe = false
@output_decoration = true
@rdoc_include = []
@root = Pathname(Dir.pwd)
@show_hash = false
@ -333,6 +358,7 @@ class RDoc::Options
@tab_width = 8
@template = nil
@template_dir = nil
@template_stylesheets = []
@title = nil
@update_output_dir = true
@verbosity = 1
@ -466,7 +492,7 @@ class RDoc::Options
@op_dir ||= 'doc'
@rdoc_include << "." if @rdoc_include.empty?
root = @root.to_path
root = @root.to_s
@rdoc_include << root unless @rdoc_include.include?(root)
if @exclude.nil? or Regexp === @exclude then
@ -583,6 +609,7 @@ Usage: #{opt.program_name} [options] [names...]
parsers.sort.each do |parser, regexp|
opt.banner << " - #{parser}: #{regexp.join ', '}\n"
end
opt.banner << " - TomDoc: Only in ruby files\n"
opt.banner << "\n The following options are deprecated:\n\n"
@ -697,17 +724,19 @@ Usage: #{opt.program_name} [options] [names...]
opt.separator nil
opt.on("--tab-width=WIDTH", "-w", OptionParser::DecimalInteger,
opt.on("--tab-width=WIDTH", "-w", Integer,
"Set the width of tab characters.") do |value|
raise OptionParser::InvalidArgument,
"#{value} is an invalid tab width" if value <= 0
@tab_width = value
end
opt.separator nil
opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES,
opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES + [:nodoc],
"Minimum visibility to document a method.",
"One of 'public', 'protected' (the default)",
"or 'private'. Can be abbreviated.") do |value|
"One of 'public', 'protected' (the default),",
"'private' or 'nodoc' (show everything)") do |value|
@visibility = value
end
@ -863,6 +892,14 @@ Usage: #{opt.program_name} [options] [names...]
opt.separator nil
opt.on("--template-stylesheets=FILES", PathArray,
"Set (or add to) the list of files to",
"include with the html template.") do |value|
@template_stylesheets << value
end
opt.separator nil
opt.on("--title=TITLE", "-t",
"Set TITLE as the title for HTML output.") do |value|
@title = value
@ -918,7 +955,7 @@ Usage: #{opt.program_name} [options] [names...]
check_generator
@generator_name = "ri"
@op_dir = RDoc::RI::Paths::SITEDIR
@op_dir = RDoc::RI::Paths.site_dir
setup_generator
end
@ -965,13 +1002,20 @@ Usage: #{opt.program_name} [options] [names...]
opt.separator nil
opt.on("--verbose", "-v",
opt.on("--verbose", "-V",
"Display extra progress as RDoc parses") do |value|
@verbosity = 2
end
opt.separator nil
opt.on("--version", "-v", "print the version") do
puts opt.version
exit
end
opt.separator nil
opt.on("--help",
"Display this help") do
RDoc::RDoc::GENERATORS.each_key do |generator|
@ -993,7 +1037,7 @@ Usage: #{opt.program_name} [options] [names...]
begin
opts.parse! argv
rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
rescue OptionParser::ParseError => e
if DEPRECATED[e.args.first] then
deprecated << e.args.first
elsif %w[--format --ri -r --ri-site -R].include? e.args.first then
@ -1019,18 +1063,22 @@ Usage: #{opt.program_name} [options] [names...]
deprecated.each do |opt|
$stderr.puts 'option ' << opt << ' is deprecated: ' << DEPRECATED[opt]
end
end
unless invalid.empty? then
invalid = "invalid options: #{invalid.join ', '}"
unless invalid.empty? then
invalid = "invalid options: #{invalid.join ', '}"
if ignore_invalid then
if ignore_invalid then
unless quiet then
$stderr.puts invalid
$stderr.puts '(invalid options are ignored)'
else
$stderr.puts opts
$stderr.puts invalid
exit 1
end
else
unless quiet then
$stderr.puts opts
end
$stderr.puts invalid
exit 1
end
end

View file

@ -218,6 +218,8 @@ class RDoc::Parser
return unless parser
content = remove_modeline content
parser.new top_level, file_name, content, options, stats
rescue SystemCallError
nil
@ -232,6 +234,13 @@ class RDoc::Parser
RDoc::Parser.parsers.unshift [regexp, self]
end
##
# Removes an emacs-style modeline from the first line of the document
def self.remove_modeline content
content.sub(/\A.*-\*-\s*(.*?\S)\s*-\*-.*\r?\n/, '')
end
##
# If there is a <tt>markup: parser_name</tt> comment at the front of the
# file, use it to determine the parser. For example:

View file

@ -173,6 +173,9 @@ class RDoc::Parser::C < RDoc::Parser
@classes = load_variable_map :c_class_variables
@singleton_classes = load_variable_map :c_singleton_class_variables
# class_variable => { function => [method, ...] }
@methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }
# missing variable => [handle_class_module arguments]
@missing_dependencies = {}
@ -206,6 +209,47 @@ class RDoc::Parser::C < RDoc::Parser
end
end
##
# Removes duplicate call-seq entries for methods using the same
# implementation.
def deduplicate_call_seq
@methods.each do |var_name, functions|
class_name = @known_classes[var_name]
class_obj = find_class var_name, class_name
functions.each_value do |method_names|
next if method_names.length == 1
method_names.each do |method_name|
deduplicate_method_name class_obj, method_name
end
end
end
end
##
# If two ruby methods share a C implementation (and comment) this
# deduplicates the examples in the call_seq for the method to reduce
# confusion in the output.
def deduplicate_method_name class_obj, method_name # :nodoc:
return unless
method = class_obj.method_list.find { |m| m.name == method_name }
return unless call_seq = method.call_seq
method_name = method_name[0, 1] if method_name =~ /\A\[/
entries = call_seq.split "\n"
matching = entries.select do |entry|
entry =~ /^\w*\.?#{Regexp.escape method_name}/ or
entry =~ /\s#{Regexp.escape method_name}\s/
end
method.call_seq = matching.join "\n"
end
##
# Scans #content for rb_define_alias
@ -422,7 +466,7 @@ class RDoc::Parser::C < RDoc::Parser
)
\s*\(\s*([\w\.]+),
\s*"([^"]+)",
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(METHOD\))?(\w+)\)?,
\s*(-?\w+)\s*\)
(?:;\s*/[*/]\s+in\s+(\w+?\.(?:cpp|c|y)))?
%xm) do |type, var_name, meth_name, function, param_count, source_file|
@ -938,6 +982,8 @@ class RDoc::Parser::C < RDoc::Parser
class_name = @known_classes[var_name]
singleton = @singleton_classes.key? var_name
@methods[var_name][function] << meth_name
return unless class_name
class_obj = find_class var_name, class_name
@ -1172,6 +1218,8 @@ class RDoc::Parser::C < RDoc::Parser
do_aliases
do_attrs
deduplicate_call_seq
@store.add_c_variables self
@top_level

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.9
# from Racc grammar file "".
# from Racc grammer file "".
#
require 'racc/parser.rb'
@ -253,7 +253,7 @@ def next_token # :nodoc:
[:STRINGLINE, line]
end
else
raise "[BUG] parsing error may occurred."
raise "[BUG] parsing error may occured."
end
end
@ -677,54 +677,54 @@ Racc_debug_parser = false
# reduce 0 omitted
def _reduce_1(val, _values, result)
result = RDoc::Markup::Document.new(*val[0])
result = RDoc::Markup::Document.new(*val[0])
result
end
def _reduce_2(val, _values, result)
raise ParseError, "file empty"
raise ParseError, "file empty"
result
end
def _reduce_3(val, _values, result)
result = val[0].concat val[1]
result = val[0].concat val[1]
result
end
def _reduce_4(val, _values, result)
result = val[0]
result = val[0]
result
end
def _reduce_5(val, _values, result)
result = val
result = val
result
end
def _reduce_6(val, _values, result)
result = val
result = val
result
end
# reduce 7 omitted
def _reduce_8(val, _values, result)
result = val
result = val
result
end
def _reduce_9(val, _values, result)
result = val
result = val
result
end
def _reduce_10(val, _values, result)
result = [RDoc::Markup::BlankLine.new]
result = [RDoc::Markup::BlankLine.new]
result
end
def _reduce_11(val, _values, result)
result = val[0].parts
result = val[0].parts
result
end
@ -732,30 +732,30 @@ def _reduce_12(val, _values, result)
# val[0] is like [level, title]
title = @inline_parser.parse(val[0][1])
result = RDoc::Markup::Heading.new(val[0][0], title)
result
end
def _reduce_13(val, _values, result)
result = RDoc::Markup::Include.new val[0], @include_path
result
end
def _reduce_14(val, _values, result)
# val[0] is Array of String
result = paragraph val[0]
result
end
def _reduce_15(val, _values, result)
result << val[1].rstrip
result << val[1].rstrip
result
end
def _reduce_16(val, _values, result)
result = [val[0].rstrip]
result = [val[0].rstrip]
result
end
@ -766,7 +766,7 @@ def _reduce_17(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
@ -777,25 +777,25 @@ def _reduce_18(val, _values, result)
# imform to lexer.
@in_verbatim = false
result
end
def _reduce_19(val, _values, result)
result << val[1]
result
end
def _reduce_20(val, _values, result)
result.concat val[2]
result
end
def _reduce_21(val, _values, result)
result << "\n"
result
end
@ -803,7 +803,7 @@ def _reduce_22(val, _values, result)
result = val
# inform to lexer.
@in_verbatim = true
result
end
@ -817,89 +817,89 @@ end
def _reduce_27(val, _values, result)
result = val[0]
result
end
def _reduce_28(val, _values, result)
result = val[1]
result
end
def _reduce_29(val, _values, result)
result = val[1].push(val[2])
result
end
def _reduce_30(val, _values, result)
result = val[0] << val[1]
result = val[0] << val[1]
result
end
def _reduce_31(val, _values, result)
result = [val[0]]
result = [val[0]]
result
end
def _reduce_32(val, _values, result)
result = RDoc::Markup::List.new :BULLET, *val[0]
result
end
def _reduce_33(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_34(val, _values, result)
result = val
result = val
result
end
def _reduce_35(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_36(val, _values, result)
result = RDoc::Markup::List.new :NUMBER, *val[0]
result
end
def _reduce_37(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_38(val, _values, result)
result = val
result = val
result
end
def _reduce_39(val, _values, result)
result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
result
end
def _reduce_40(val, _values, result)
result = RDoc::Markup::List.new :NOTE, *val[0]
result
end
def _reduce_41(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_42(val, _values, result)
result = val
result = val
result
end
@ -907,77 +907,77 @@ def _reduce_43(val, _values, result)
term = @inline_parser.parse val[0].strip
result = RDoc::Markup::ListItem.new term, *val[1]
result
end
def _reduce_44(val, _values, result)
result = RDoc::Markup::List.new :LABEL, *val[0]
result
end
def _reduce_45(val, _values, result)
result.push(val[1])
result.push(val[1])
result
end
def _reduce_46(val, _values, result)
result = val
result = val
result
end
def _reduce_47(val, _values, result)
result = RDoc::Markup::ListItem.new "<tt>#{val[0].strip}</tt>", *val[1]
result
end
def _reduce_48(val, _values, result)
result = [val[1]].concat(val[2])
result
end
def _reduce_49(val, _values, result)
result = [val[1]]
result
end
def _reduce_50(val, _values, result)
result = val[2]
result
end
def _reduce_51(val, _values, result)
result = []
result
end
def _reduce_52(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
# reduce 53 omitted
def _reduce_54(val, _values, result)
result = val
result = val
result
end
def _reduce_55(val, _values, result)
result = val
result = val
result
end
# reduce 56 omitted
def _reduce_57(val, _values, result)
result = []
result = []
result
end
@ -991,58 +991,58 @@ end
def _reduce_62(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_63(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_64(val, _values, result)
result = paragraph [val[0]].concat(val[1])
result
end
def _reduce_65(val, _values, result)
result = paragraph [val[0]]
result
end
def _reduce_66(val, _values, result)
result = [val[0]].concat(val[1])
result
end
def _reduce_67(val, _values, result)
result.concat val[1]
result.concat val[1]
result
end
def _reduce_68(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_69(val, _values, result)
result = val
result = val
result
end
# reduce 70 omitted
def _reduce_71(val, _values, result)
result = []
result = []
result
end
def _reduce_72(val, _values, result)
result = []
result = []
result
end

View file

@ -1,7 +1,7 @@
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.9
# from Racc grammar file "".
# from Racc grammer file "".
#
require 'racc/parser.rb'
@ -732,12 +732,12 @@ Racc_debug_parser = false
# reduce 1 omitted
def _reduce_2(val, _values, result)
result.append val[1]
result.append val[1]
result
end
def _reduce_3(val, _values, result)
result = val[0]
result = val[0]
result
end
@ -762,28 +762,28 @@ end
def _reduce_13(val, _values, result)
content = val[1]
result = inline "<em>#{content}</em>", content
result
end
def _reduce_14(val, _values, result)
content = val[1]
result = inline "<code>#{content}</code>", content
result
end
def _reduce_15(val, _values, result)
content = val[1]
result = inline "+#{content}+", content
result
end
def _reduce_16(val, _values, result)
content = val[1]
result = inline "<tt>#{content}</tt>", content
result
end
@ -791,13 +791,13 @@ def _reduce_17(val, _values, result)
label = val[1]
@block_parser.add_label label.reference
result = "<span id=\"label-#{label}\">#{label}</span>"
result
end
def _reduce_18(val, _values, result)
result = "{#{val[1]}}[#{val[2].join}]"
result
end
@ -805,13 +805,13 @@ def _reduce_19(val, _values, result)
scheme, inline = val[1]
result = "{#{inline}}[#{scheme}#{inline.reference}]"
result
end
def _reduce_20(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -820,25 +820,25 @@ def _reduce_21(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_22(val, _values, result)
result = ['rdoc-label:', val[0].reference]
result
end
def _reduce_23(val, _values, result)
result = ['rdoc-label:', "#{val[0].reference}/"]
result
end
def _reduce_24(val, _values, result)
result = [nil, inline(val[1])]
result
end
@ -847,92 +847,92 @@ def _reduce_25(val, _values, result)
'rdoc-label:',
inline("#{val[0].reference}/#{val[1].reference}")
]
result
end
def _reduce_26(val, _values, result)
result = ['rdoc-label:', val[0]]
result
end
def _reduce_27(val, _values, result)
ref = val[0].reference
result = ['rdoc-label:', inline(ref, "#{ref}/")]
result
end
# reduce 28 omitted
def _reduce_29(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_30(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_31(val, _values, result)
result = inline val[0]
result
end
def _reduce_32(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
def _reduce_33(val, _values, result)
result = inline val[0]
result
end
def _reduce_34(val, _values, result)
result = inline "\"#{val[1]}\""
result
end
# reduce 35 omitted
def _reduce_36(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_37(val, _values, result)
result = inline val[1]
result = inline val[1]
result
end
def _reduce_38(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_39(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_40(val, _values, result)
result = val[0]
result
end
def _reduce_41(val, _values, result)
result = inline val[0]
result
end
@ -940,25 +940,25 @@ end
def _reduce_43(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_44(val, _values, result)
result = inline val[0]
result
end
def _reduce_45(val, _values, result)
result = val[0].append val[1]
result
end
def _reduce_46(val, _values, result)
result = val[0]
result
end
@ -984,24 +984,24 @@ end
def _reduce_57(val, _values, result)
result = val[0]
result
end
def _reduce_58(val, _values, result)
result = inline val[0]
result
end
def _reduce_59(val, _values, result)
result = inline val[0]
result
end
def _reduce_60(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1009,7 +1009,7 @@ end
def _reduce_62(val, _values, result)
result << val[1]
result
end
@ -1017,7 +1017,7 @@ end
def _reduce_64(val, _values, result)
result << val[1]
result
end
@ -1048,7 +1048,7 @@ end
# reduce 77 omitted
def _reduce_78(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1099,13 +1099,13 @@ end
def _reduce_101(val, _values, result)
index = @block_parser.add_footnote val[1].rdoc
result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]"
result
end
def _reduce_102(val, _values, result)
result = inline "<tt>#{val[1]}</tt>", val[1]
result
end
@ -1122,7 +1122,7 @@ end
# reduce 108 omitted
def _reduce_109(val, _values, result)
result << val[1]
result << val[1]
result
end
@ -1130,24 +1130,24 @@ end
def _reduce_111(val, _values, result)
result = inline val[0]
result
end
# reduce 112 omitted
def _reduce_113(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_114(val, _values, result)
result = val[1]
result = val[1]
result
end
def _reduce_115(val, _values, result)
result = val[1]
result = val[1]
result
end
@ -1192,7 +1192,7 @@ end
# reduce 135 omitted
def _reduce_136(val, _values, result)
result << val[1]
result << val[1]
result
end

View file

@ -217,7 +217,7 @@ option)
end unless @options.force_output
else
FileUtils.mkdir_p dir
FileUtils.touch output_flag_file dir
FileUtils.touch flag_file
end
last
@ -289,6 +289,7 @@ option)
file_list = []
relative_files.each do |rel_file_name|
next if rel_file_name.end_with? 'created.rid'
next if exclude_pattern && exclude_pattern =~ rel_file_name
stat = File.stat rel_file_name rescue next
@ -342,6 +343,8 @@ option)
@stats.add_file filename
return if RDoc::Parser.binary? filename
content = RDoc::Encoding.read_file filename, encoding
return unless content
@ -493,7 +496,7 @@ The internal error was:
if @options.coverage_report then
puts
puts @stats.report
puts @stats.report.accept RDoc::Markup::ToRdoc.new
elsif file_info.empty? then
$stderr.puts "\nNo newer files." unless @options.quiet
else
@ -506,7 +509,7 @@ The internal error was:
if @stats and (@options.coverage_report or not @options.quiet) then
puts
puts @stats.summary
puts @stats.summary.accept RDoc::Markup::ToRdoc.new
end
exit @stats.fully_documented? if @options.coverage_report

View file

@ -197,7 +197,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
opt.separator nil
opt.on("--[no-]pager", "-T",
opt.on("--[no-]pager",
"Send output directly to stdout,",
"rather than to a pager.") do |use_pager|
options[:use_stdout] = !use_pager
@ -205,6 +205,13 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
opt.separator nil
opt.on("-T",
"Synonym for --no-pager") do
options[:use_stdout] = true
end
opt.separator nil
opt.on("--width=WIDTH", "-w", OptionParser::DecimalInteger,
"Set the width of the output.") do |width|
options[:width] = width
@ -459,41 +466,54 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
extensions.each do |modules, store|
if modules.length == 1 then
include = modules.first
name = include.name
path = store.friendly_path
out << RDoc::Markup::Paragraph.new("#{name} (from #{path})")
if include.comment then
out << RDoc::Markup::BlankLine.new
out << include.comment
end
add_extension_modules_single out, store, modules.first
else
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
wout, with = modules.partition { |incl| incl.comment.empty? }
out << RDoc::Markup::BlankLine.new unless with.empty?
with.each do |incl|
out << RDoc::Markup::Paragraph.new(incl.name)
out << RDoc::Markup::BlankLine.new
out << incl.comment
end
unless wout.empty? then
verb = RDoc::Markup::Verbatim.new
wout.each do |incl|
verb.push incl.name, "\n"
end
out << verb
end
add_extension_modules_multiple out, store, modules
end
end
end
##
# Renders multiple included +modules+ from +store+ to +out+.
def add_extension_modules_multiple out, store, modules # :nodoc:
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
wout, with = modules.partition { |incl| incl.comment.empty? }
out << RDoc::Markup::BlankLine.new unless with.empty?
with.each do |incl|
out << RDoc::Markup::Paragraph.new(incl.name)
out << RDoc::Markup::BlankLine.new
out << incl.comment
end
unless wout.empty? then
verb = RDoc::Markup::Verbatim.new
wout.each do |incl|
verb.push incl.name, "\n"
end
out << verb
end
end
##
# Adds a single extension module +include+ from +store+ to +out+
def add_extension_modules_single out, store, include # :nodoc:
name = include.name
path = store.friendly_path
out << RDoc::Markup::Paragraph.new("#{name} (from #{path})")
if include.comment then
out << RDoc::Markup::BlankLine.new
out << include.comment
end
end
##
# Adds +includes+ to +out+
@ -596,63 +616,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
add_extends out, extends
found.each do |store, klass|
comment = klass.comment
# TODO the store's cache should always return an empty Array
class_methods = store.class_methods[klass.full_name] || []
instance_methods = store.instance_methods[klass.full_name] || []
attributes = store.attributes[klass.full_name] || []
if comment.empty? and
instance_methods.empty? and class_methods.empty? then
also_in << store
next
end
add_from out, store
unless comment.empty? then
out << RDoc::Markup::Rule.new(1)
if comment.merged? then
parts = comment.parts
parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
parts.flatten!
parts.pop
out.concat parts
else
out << comment
end
end
if class_methods or instance_methods or not klass.constants.empty? then
out << RDoc::Markup::Rule.new(1)
end
unless klass.constants.empty? then
out << RDoc::Markup::Heading.new(1, "Constants:")
out << RDoc::Markup::BlankLine.new
list = RDoc::Markup::List.new :NOTE
constants = klass.constants.sort_by { |constant| constant.name }
list.items.concat constants.map { |constant|
parts = constant.comment.parts if constant.comment
parts << RDoc::Markup::Paragraph.new('[not documented]') if
parts.empty?
RDoc::Markup::ListItem.new(constant.name, *parts)
}
out << list
out << RDoc::Markup::BlankLine.new
end
add_method_list out, class_methods, 'Class methods'
add_method_list out, instance_methods, 'Instance methods'
add_method_list out, attributes, 'Attributes'
add_method_documentation out, klass if @show_all
render_class out, store, klass, also_in
end
add_also_in out, also_in
@ -660,6 +624,50 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
out
end
##
# Adds the class +comment+ to +out+.
def class_document_comment out, comment # :nodoc:
unless comment.empty? then
out << RDoc::Markup::Rule.new(1)
if comment.merged? then
parts = comment.parts
parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
parts.flatten!
parts.pop
out.concat parts
else
out << comment
end
end
end
##
# Adds the constants from +klass+ to the Document +out+.
def class_document_constants out, klass # :nodoc:
return if klass.constants.empty?
out << RDoc::Markup::Heading.new(1, "Constants:")
out << RDoc::Markup::BlankLine.new
list = RDoc::Markup::List.new :NOTE
constants = klass.constants.sort_by { |constant| constant.name }
list.items.concat constants.map { |constant|
parts = constant.comment.parts if constant.comment
parts << RDoc::Markup::Paragraph.new('[not documented]') if
parts.empty?
RDoc::Markup::ListItem.new(constant.name, *parts)
}
out << list
out << RDoc::Markup::BlankLine.new
end
##
# Hash mapping a known class or module to the stores it can be loaded from
@ -709,16 +717,24 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
# Completes +name+ based on the caches. For Readline
def complete name
klasses = classes.keys
completions = []
klass, selector, method = parse_name name
complete_klass name, klass, selector, method, completions
complete_method name, klass, selector, completions
completions.sort.uniq
end
def complete_klass name, klass, selector, method, completions # :nodoc:
klasses = classes.keys
# may need to include Foo when given Foo::
klass_name = method ? name : klass
if name !~ /#|\./ then
completions = klasses.grep(/^#{Regexp.escape klass_name}[^:]*$/)
completions.replace klasses.grep(/^#{Regexp.escape klass_name}[^:]*$/)
completions.concat klasses.grep(/^#{Regexp.escape name}[^:]*$/) if
name =~ /::$/
@ -728,7 +744,9 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
elsif classes.key? klass_name then
completions << klass_name
end
end
def complete_method name, klass, selector, completions # :nodoc:
if completions.include? klass and name =~ /#|\.|::/ then
methods = list_methods_matching name
@ -743,8 +761,6 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
completions.concat methods
end
completions.sort.uniq
end
##
@ -804,7 +820,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
true
rescue NotFoundError
matches = list_methods_matching name if name =~ /::|#|\./
matches = classes.keys.grep(/^#{name}/) if matches.empty?
matches = classes.keys.grep(/^#{Regexp.escape name}/) if matches.empty?
raise if matches.empty?
@ -1183,6 +1199,12 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
return unless method
store.load_method klass, "#{type}#{method}"
rescue RDoc::Store::MissingFileError => e
comment = RDoc::Comment.new("missing documentation at #{e.file}").parse
method = RDoc::AnyMethod.new nil, name
method.comment = comment
method
end
##
@ -1228,30 +1250,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
filtered.each do |store, methods|
methods.each do |method|
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
unless name =~ /^#{Regexp.escape method.parent_name}/ then
out << RDoc::Markup::Heading.new(3, "Implementation from #{method.parent_name}")
end
out << RDoc::Markup::Rule.new(1)
if method.arglists then
arglists = method.arglists.chomp.split "\n"
arglists = arglists.map { |line| line + "\n" }
out << RDoc::Markup::Verbatim.new(*arglists)
out << RDoc::Markup::Rule.new(1)
end
if method.respond_to?(:superclass_method) and method.superclass_method
out << RDoc::Markup::BlankLine.new
out << RDoc::Markup::Heading.new(4, "(Uses superclass method #{method.superclass_method})")
out << RDoc::Markup::Rule.new(1)
end
out << RDoc::Markup::BlankLine.new
out << method.comment
out << RDoc::Markup::BlankLine.new
render_method out, store, method, name
end
end
@ -1345,6 +1344,78 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
[klass, type, meth]
end
##
# Renders the +klass+ from +store+ to +out+. If the klass has no
# documentable items the class is added to +also_in+ instead.
def render_class out, store, klass, also_in # :nodoc:
comment = klass.comment
# TODO the store's cache should always return an empty Array
class_methods = store.class_methods[klass.full_name] || []
instance_methods = store.instance_methods[klass.full_name] || []
attributes = store.attributes[klass.full_name] || []
if comment.empty? and
instance_methods.empty? and class_methods.empty? then
also_in << store
return
end
add_from out, store
class_document_comment out, comment
if class_methods or instance_methods or not klass.constants.empty? then
out << RDoc::Markup::Rule.new(1)
end
class_document_constants out, klass
add_method_list out, class_methods, 'Class methods'
add_method_list out, instance_methods, 'Instance methods'
add_method_list out, attributes, 'Attributes'
add_method_documentation out, klass if @show_all
end
def render_method out, store, method, name # :nodoc:
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
unless name =~ /^#{Regexp.escape method.parent_name}/ then
out << RDoc::Markup::Heading.new(3, "Implementation from #{method.parent_name}")
end
out << RDoc::Markup::Rule.new(1)
render_method_arguments out, method.arglists
render_method_superclass out, method
render_method_comment out, method
end
def render_method_arguments out, arglists # :nodoc:
return unless arglists
arglists = arglists.chomp.split "\n"
arglists = arglists.map { |line| line + "\n" }
out << RDoc::Markup::Verbatim.new(*arglists)
out << RDoc::Markup::Rule.new(1)
end
def render_method_comment out, method # :nodoc:
out << RDoc::Markup::BlankLine.new
out << method.comment
out << RDoc::Markup::BlankLine.new
end
def render_method_superclass out, method # :nodoc:
return unless
method.respond_to?(:superclass_method) and method.superclass_method
out << RDoc::Markup::BlankLine.new
out << RDoc::Markup::Heading.new(4, "(Uses superclass method #{method.superclass_method})")
out << RDoc::Markup::Rule.new(1)
end
##
# Looks up and displays ri data according to the options given.
@ -1412,7 +1483,9 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
server = WEBrick::HTTPServer.new :Port => @server
server.mount '/', RDoc::Servlet
extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact
server.mount '/', RDoc::Servlet, nil, extra_doc_dirs
trap 'INT' do server.shutdown end
trap 'TERM' do server.shutdown end

View file

@ -42,8 +42,8 @@ class RDoc::RubyLex
include RDoc::RubyToken
include IRB
attr_reader :continue
attr_reader :lex_state
attr_accessor :continue
attr_accessor :lex_state
attr_reader :reader
class << self
@ -107,7 +107,7 @@ class RDoc::RubyLex
@here_header = false
@indent = 0
@indent_stack = []
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
@space_seen = false
@continue = false
@ -280,7 +280,7 @@ class RDoc::RubyLex
@quoted = nil
@indent = 0
@indent_stack = []
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
@space_seen = false
@here_header = false
@ -450,11 +450,11 @@ class RDoc::RubyLex
@OP.def_rule("\n") do |op, io|
print "\\n\n" if RDoc::RubyLex.debug?
case @lex_state
when EXPR_BEG, EXPR_FNAME, EXPR_DOT
when :EXPR_BEG, :EXPR_FNAME, :EXPR_DOT
@continue = true
else
@continue = false
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
until (@indent_stack.empty? ||
[TkLPAREN, TkLBRACK, TkLBRACE,
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
@ -473,25 +473,25 @@ class RDoc::RubyLex
">", ">=", ">>") do
|op, io|
case @lex_state
when EXPR_FNAME, EXPR_DOT
@lex_state = EXPR_ARG
when :EXPR_FNAME, :EXPR_DOT
@lex_state = :EXPR_ARG
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
end
Token(op)
end
@OP.def_rules("!", "!=", "!~") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token(op)
end
@OP.def_rules("<<") do
|op, io|
tk = nil
if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
(@lex_state != EXPR_ARG || @space_seen)
if @lex_state != :EXPR_END && @lex_state != :EXPR_CLASS &&
(@lex_state != :EXPR_ARG || @space_seen)
c = peek(0)
if /\S/ =~ c && (/["'`]/ =~ c || /\w/ =~ c || c == "-")
tk = identify_here_document
@ -500,10 +500,10 @@ class RDoc::RubyLex
unless tk
tk = Token(op)
case @lex_state
when EXPR_FNAME, EXPR_DOT
@lex_state = EXPR_ARG
when :EXPR_FNAME, :EXPR_DOT
@lex_state = :EXPR_ARG
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
end
end
tk
@ -516,8 +516,8 @@ class RDoc::RubyLex
@OP.def_rules("`") do
|op, io|
if @lex_state == EXPR_FNAME
@lex_state = EXPR_END
if @lex_state == :EXPR_FNAME
@lex_state = :EXPR_END
Token(op)
else
identify_string(op)
@ -526,61 +526,61 @@ class RDoc::RubyLex
@OP.def_rules('?') do
|op, io|
if @lex_state == EXPR_END
@lex_state = EXPR_BEG
if @lex_state == :EXPR_END
@lex_state = :EXPR_BEG
Token(TkQUESTION)
else
ch = getc
if @lex_state == EXPR_ARG && ch =~ /\s/
if @lex_state == :EXPR_ARG && ch =~ /\s/
ungetc
@lex_state = EXPR_BEG;
@lex_state = :EXPR_BEG;
Token(TkQUESTION)
else
@lex_state = EXPR_END
Token(TkSTRING, ch)
@lex_state = :EXPR_END
Token(TkCHAR, "?#{ch}")
end
end
end
@OP.def_rules("&", "&&", "|", "||") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token(op)
end
@OP.def_rules("+=", "-=", "*=", "**=",
"&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
op =~ /^(.*)=$/
Token(TkOPASGN, $1)
end
@OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("+@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
|op, io|
@lex_state = EXPR_ARG
@lex_state = :EXPR_ARG
Token(op)
end
@OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("-@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
|op, io|
@lex_state = EXPR_ARG
@lex_state = :EXPR_ARG
Token(op)
end
@OP.def_rules("+", "-") do
|op, io|
catch(:RET) do
if @lex_state == EXPR_ARG
if @lex_state == :EXPR_ARG
if @space_seen and peek(0) =~ /[0-9]/
throw :RET, identify_number(op)
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
end
elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
elsif @lex_state != :EXPR_END and peek(0) =~ /[0-9]/
throw :RET, identify_number(op)
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
end
Token(op)
end
@ -588,20 +588,20 @@ class RDoc::RubyLex
@OP.def_rule(".") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
if peek(0) =~ /[0-9]/
ungetc
identify_number
else
# for "obj.if" etc.
@lex_state = EXPR_DOT
@lex_state = :EXPR_DOT
Token(TkDOT)
end
end
@OP.def_rules("..", "...") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token(op)
end
@ -611,7 +611,7 @@ class RDoc::RubyLex
def lex_int2
@OP.def_rules("]", "}", ")") do
|op, io|
@lex_state = EXPR_END
@lex_state = :EXPR_END
@indent -= 1
@indent_stack.pop
Token(op)
@ -619,11 +619,11 @@ class RDoc::RubyLex
@OP.def_rule(":") do
|op, io|
if @lex_state == EXPR_END || peek(0) =~ /\s/
@lex_state = EXPR_BEG
if @lex_state == :EXPR_END || peek(0) =~ /\s/
@lex_state = :EXPR_BEG
Token(TkCOLON)
else
@lex_state = EXPR_FNAME;
@lex_state = :EXPR_FNAME;
Token(TkSYMBEG)
end
end
@ -631,51 +631,51 @@ class RDoc::RubyLex
@OP.def_rule("::") do
|op, io|
# p @lex_state.id2name, @space_seen
if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
@lex_state = EXPR_BEG
if @lex_state == :EXPR_BEG or @lex_state == :EXPR_ARG && @space_seen
@lex_state = :EXPR_BEG
Token(TkCOLON3)
else
@lex_state = EXPR_DOT
@lex_state = :EXPR_DOT
Token(TkCOLON2)
end
end
@OP.def_rule("/") do
|op, io|
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
identify_string(op)
elsif peek(0) == '='
getc
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token(TkOPASGN, "/") #/)
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
elsif @lex_state == :EXPR_ARG and @space_seen and peek(0) !~ /\s/
identify_string(op)
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token("/") #/)
end
end
@OP.def_rules("^") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token("^")
end
# @OP.def_rules("^=") do
# @lex_state = EXPR_BEG
# @lex_state = :EXPR_BEG
# Token(OP_ASGN, :^)
# end
@OP.def_rules(",") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token(op)
end
@OP.def_rules(";") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
until (@indent_stack.empty? ||
[TkLPAREN, TkLBRACK, TkLBRACE,
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
@ -686,56 +686,56 @@ class RDoc::RubyLex
@OP.def_rule("~") do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token("~")
end
@OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("~@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
|op, io|
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token("~")
end
@OP.def_rule("(") do
|op, io|
@indent += 1
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
@lex_state = EXPR_BEG
if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
@lex_state = :EXPR_BEG
tk_c = TkfLPAREN
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
tk_c = TkLPAREN
end
@indent_stack.push tk_c
Token tk_c
end
@OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("[]", proc{|op, io| @lex_state == :EXPR_FNAME}) do
|op, io|
@lex_state = EXPR_ARG
@lex_state = :EXPR_ARG
Token("[]")
end
@OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do
@OP.def_rule("[]=", proc{|op, io| @lex_state == :EXPR_FNAME}) do
|op, io|
@lex_state = EXPR_ARG
@lex_state = :EXPR_ARG
Token("[]=")
end
@OP.def_rule("[") do
|op, io|
@indent += 1
if @lex_state == EXPR_FNAME
if @lex_state == :EXPR_FNAME
tk_c = TkfLBRACK
else
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
tk_c = TkLBRACK
elsif @lex_state == EXPR_ARG && @space_seen
elsif @lex_state == :EXPR_ARG && @space_seen
tk_c = TkLBRACK
else
tk_c = TkfLBRACK
end
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
end
@indent_stack.push tk_c
Token(tk_c)
@ -744,12 +744,12 @@ class RDoc::RubyLex
@OP.def_rule("{") do
|op, io|
@indent += 1
if @lex_state != EXPR_END && @lex_state != EXPR_ARG
if @lex_state != :EXPR_END && @lex_state != :EXPR_ARG
tk_c = TkLBRACE
else
tk_c = TkfLBRACE
end
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
@indent_stack.push tk_c
Token(tk_c)
end
@ -768,15 +768,15 @@ class RDoc::RubyLex
@OP.def_rule('%') do
|op, io|
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
identify_quotation
elsif peek(0) == '='
getc
Token(TkOPASGN, :%)
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
elsif @lex_state == :EXPR_ARG and @space_seen and peek(0) !~ /\s/
identify_quotation
else
@lex_state = EXPR_BEG
@lex_state = :EXPR_BEG
Token("%") #))
end
end
@ -799,15 +799,15 @@ class RDoc::RubyLex
# @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
# |op, io|
# @indent += 1
# @lex_state = EXPR_FNAME
# # @lex_state = EXPR_END
# @lex_state = :EXPR_FNAME
# # @lex_state = :EXPR_END
# # until @rests[0] == "\n" or @rests[0] == ";"
# # rests.shift
# # end
# end
@OP.def_rule("_") do
if peek_match?(/_END__/) and @lex_state == EXPR_BEG then
if peek_match?(/_END__/) and @lex_state == :EXPR_BEG then
6.times { getc }
Token(TkEND_OF_SCRIPT, '__END__')
else
@ -832,7 +832,7 @@ class RDoc::RubyLex
end
def identify_gvar
@lex_state = EXPR_END
@lex_state = :EXPR_END
case ch = getc
when /[~_*$?!@\/\\;,=:<>".]/ #"
@ -888,32 +888,33 @@ class RDoc::RubyLex
when /^\$/
return Token(TkGVAR, token)
when /^\@\@/
@lex_state = EXPR_END
@lex_state = :EXPR_END
# p Token(TkCVAR, token)
return Token(TkCVAR, token)
when /^\@/
@lex_state = EXPR_END
@lex_state = :EXPR_END
return Token(TkIVAR, token)
end
if @lex_state != EXPR_DOT
if @lex_state != :EXPR_DOT
print token, "\n" if RDoc::RubyLex.debug?
token_c, *trans = TkReading2Token[token]
if token_c
# reserved word?
if (@lex_state != EXPR_BEG &&
@lex_state != EXPR_FNAME &&
if (@lex_state != :EXPR_BEG &&
@lex_state != :EXPR_FNAME &&
trans[1])
# modifiers
token_c = TkSymbol2Token[trans[1]]
@lex_state = trans[0]
else
if @lex_state != EXPR_FNAME
if @lex_state != :EXPR_FNAME
if ENINDENT_CLAUSE.include?(token)
valid = peek(0) != ':'
# check for ``class = val'' etc.
valid = true
case token
when "class"
valid = false unless peek_match?(/^\s*(<<|\w|::)/)
@ -925,7 +926,8 @@ class RDoc::RubyLex
valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&|\|)/)
else
# no nothing
end
end if valid
if valid
if token == "do"
if ![TkFOR, TkWHILE, TkUNTIL].include?(@indent_stack.last)
@ -946,23 +948,23 @@ class RDoc::RubyLex
end
@lex_state = trans[0]
else
@lex_state = EXPR_END
@lex_state = :EXPR_END
end
end
return Token(token_c, token)
end
end
if @lex_state == EXPR_FNAME
@lex_state = EXPR_END
if @lex_state == :EXPR_FNAME
@lex_state = :EXPR_END
if peek(0) == '='
token.concat getc
end
elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT ||
@lex_state == EXPR_ARG
@lex_state = EXPR_ARG
elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||
@lex_state == :EXPR_ARG
@lex_state = :EXPR_ARG
else
@lex_state = EXPR_END
@lex_state = :EXPR_END
end
if token[0, 1] =~ /[A-Z]/
@ -1028,6 +1030,8 @@ class RDoc::RubyLex
end
if output_heredoc then
raise Error, "Missing terminating #{quoted} for string" unless l
doc << l.chomp
else
doc << '"'
@ -1041,7 +1045,7 @@ class RDoc::RubyLex
token_class = output_heredoc ? RDoc::RubyLex::TkHEREDOC : Ltype2Token[lt]
@ltype = ltback
@lex_state = EXPR_END
@lex_state = :EXPR_END
Token(token_class, doc)
end
@ -1065,7 +1069,7 @@ class RDoc::RubyLex
end
def identify_number(op = "")
@lex_state = EXPR_END
@lex_state = :EXPR_END
num = op
@ -1240,7 +1244,7 @@ class RDoc::RubyLex
ensure
@ltype = nil
@quoted = nil
@lex_state = EXPR_END
@lex_state = :EXPR_END
end
end
@ -1283,18 +1287,19 @@ class RDoc::RubyLex
def read_escape
escape = ''
ch = getc
escape << ch
case ch
when "\n", "\r", "\f"
escape << ch
when "\\", "n", "t", "r", "f", "v", "a", "e", "b", "s" #"
escape << ch
when /[0-7]/
ungetc ch
3.times do
ch = getc
escape << ch
case ch
when /[0-7]/
escape << ch
when nil
break
else
@ -1304,11 +1309,13 @@ class RDoc::RubyLex
end
when "x"
escape << ch
2.times do
ch = getc
escape << ch
case ch
when /[0-9a-fA-F]/
escape << ch
when nil
break
else
@ -1318,26 +1325,44 @@ class RDoc::RubyLex
end
when "M"
ch = getc
escape << ch
ch = getc
if ch != '-'
ungetc
else
ch = getc
escape << ch
ch = getc
if ch == "\\" #"
ungetc
escape << read_escape
else
escape << ch
end
end
when "C", "c" #, "^"
if ch == "C" and (ch = getc) != "-"
escape << ch
ungetc
escape << ch
if ch == "C"
ch = getc
if ch == "-"
escape << ch
ch = getc
escape << ch
escape << read_escape if ch == "\\"
else
ungetc
end
elsif (ch = getc) == "\\" #"
escape << ch << read_escape
end
else
escape << ch
# other characters
end

View file

@ -276,50 +276,50 @@ module RDoc::RubyToken
end
TokenDefinitions = [
[:TkCLASS, TkKW, "class", EXPR_CLASS],
[:TkMODULE, TkKW, "module", EXPR_BEG],
[:TkDEF, TkKW, "def", EXPR_FNAME],
[:TkUNDEF, TkKW, "undef", EXPR_FNAME],
[:TkBEGIN, TkKW, "begin", EXPR_BEG],
[:TkRESCUE, TkKW, "rescue", EXPR_MID],
[:TkENSURE, TkKW, "ensure", EXPR_BEG],
[:TkEND, TkKW, "end", EXPR_END],
[:TkIF, TkKW, "if", EXPR_BEG, :TkIF_MOD],
[:TkUNLESS, TkKW, "unless", EXPR_BEG, :TkUNLESS_MOD],
[:TkTHEN, TkKW, "then", EXPR_BEG],
[:TkELSIF, TkKW, "elsif", EXPR_BEG],
[:TkELSE, TkKW, "else", EXPR_BEG],
[:TkCASE, TkKW, "case", EXPR_BEG],
[:TkWHEN, TkKW, "when", EXPR_BEG],
[:TkWHILE, TkKW, "while", EXPR_BEG, :TkWHILE_MOD],
[:TkUNTIL, TkKW, "until", EXPR_BEG, :TkUNTIL_MOD],
[:TkFOR, TkKW, "for", EXPR_BEG],
[:TkBREAK, TkKW, "break", EXPR_MID],
[:TkNEXT, TkKW, "next", EXPR_END],
[:TkREDO, TkKW, "redo", EXPR_END],
[:TkRETRY, TkKW, "retry", EXPR_END],
[:TkIN, TkKW, "in", EXPR_BEG],
[:TkDO, TkKW, "do", EXPR_BEG],
[:TkRETURN, TkKW, "return", EXPR_MID],
[:TkYIELD, TkKW, "yield", EXPR_END],
[:TkSUPER, TkKW, "super", EXPR_END],
[:TkSELF, TkKW, "self", EXPR_END],
[:TkNIL, TkKW, "nil", EXPR_END],
[:TkTRUE, TkKW, "true", EXPR_END],
[:TkFALSE, TkKW, "false", EXPR_END],
[:TkAND, TkKW, "and", EXPR_BEG],
[:TkOR, TkKW, "or", EXPR_BEG],
[:TkNOT, TkKW, "not", EXPR_BEG],
[:TkCLASS, TkKW, "class", :EXPR_CLASS],
[:TkMODULE, TkKW, "module", :EXPR_BEG],
[:TkDEF, TkKW, "def", :EXPR_FNAME],
[:TkUNDEF, TkKW, "undef", :EXPR_FNAME],
[:TkBEGIN, TkKW, "begin", :EXPR_BEG],
[:TkRESCUE, TkKW, "rescue", :EXPR_MID],
[:TkENSURE, TkKW, "ensure", :EXPR_BEG],
[:TkEND, TkKW, "end", :EXPR_END],
[:TkIF, TkKW, "if", :EXPR_BEG, :TkIF_MOD],
[:TkUNLESS, TkKW, "unless", :EXPR_BEG, :TkUNLESS_MOD],
[:TkTHEN, TkKW, "then", :EXPR_BEG],
[:TkELSIF, TkKW, "elsif", :EXPR_BEG],
[:TkELSE, TkKW, "else", :EXPR_BEG],
[:TkCASE, TkKW, "case", :EXPR_BEG],
[:TkWHEN, TkKW, "when", :EXPR_BEG],
[:TkWHILE, TkKW, "while", :EXPR_BEG, :TkWHILE_MOD],
[:TkUNTIL, TkKW, "until", :EXPR_BEG, :TkUNTIL_MOD],
[:TkFOR, TkKW, "for", :EXPR_BEG],
[:TkBREAK, TkKW, "break", :EXPR_MID],
[:TkNEXT, TkKW, "next", :EXPR_END],
[:TkREDO, TkKW, "redo", :EXPR_END],
[:TkRETRY, TkKW, "retry", :EXPR_END],
[:TkIN, TkKW, "in", :EXPR_BEG],
[:TkDO, TkKW, "do", :EXPR_BEG],
[:TkRETURN, TkKW, "return", :EXPR_MID],
[:TkYIELD, TkKW, "yield", :EXPR_END],
[:TkSUPER, TkKW, "super", :EXPR_END],
[:TkSELF, TkKW, "self", :EXPR_END],
[:TkNIL, TkKW, "nil", :EXPR_END],
[:TkTRUE, TkKW, "true", :EXPR_END],
[:TkFALSE, TkKW, "false", :EXPR_END],
[:TkAND, TkKW, "and", :EXPR_BEG],
[:TkOR, TkKW, "or", :EXPR_BEG],
[:TkNOT, TkKW, "not", :EXPR_BEG],
[:TkIF_MOD, TkKW],
[:TkUNLESS_MOD, TkKW],
[:TkWHILE_MOD, TkKW],
[:TkUNTIL_MOD, TkKW],
[:TkALIAS, TkKW, "alias", EXPR_FNAME],
[:TkDEFINED, TkKW, "defined?", EXPR_END],
[:TklBEGIN, TkKW, "BEGIN", EXPR_END],
[:TklEND, TkKW, "END", EXPR_END],
[:Tk__LINE__, TkKW, "__LINE__", EXPR_END],
[:Tk__FILE__, TkKW, "__FILE__", EXPR_END],
[:TkALIAS, TkKW, "alias", :EXPR_FNAME],
[:TkDEFINED, TkKW, "defined?", :EXPR_END],
[:TklBEGIN, TkKW, "BEGIN", :EXPR_END],
[:TklEND, TkKW, "END", :EXPR_END],
[:Tk__LINE__, TkKW, "__LINE__", :EXPR_END],
[:Tk__FILE__, TkKW, "__FILE__", :EXPR_END],
[:TkIDENTIFIER, TkId],
[:TkFID, TkId],
@ -335,6 +335,7 @@ module RDoc::RubyToken
[:TkXSTRING, TkVal],
[:TkREGEXP, TkVal],
[:TkSYMBOL, TkVal],
[:TkCHAR, TkVal],
[:TkDSTRING, TkNode],
[:TkDXSTRING, TkNode],

View file

@ -12,6 +12,7 @@ require 'rdoc'
class RDoc::RubygemsHook
include Gem::UserInteraction
extend Gem::UserInteraction
@rdoc_version = nil
@specs = []
@ -45,7 +46,8 @@ class RDoc::RubygemsHook
# +specs+
def self.generation_hook installer, specs
types = installer.document
start = Time.now
types = installer.document
generate_rdoc = types.include? 'rdoc'
generate_ri = types.include? 'ri'
@ -53,6 +55,13 @@ class RDoc::RubygemsHook
specs.each do |spec|
new(spec, generate_rdoc, generate_ri).generate
end
return unless generate_rdoc or generate_ri
duration = (Time.now - start).to_i
names = specs.map(&:name).join ', '
say "Done installing documentation for #{names} after #{duration} seconds"
end
##

View file

@ -53,14 +53,17 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
#
# Use +mount_path+ when mounting the servlet somewhere other than /.
#
# Use +extra_doc_dirs+ for additional documentation directories.
#
# +server+ is provided automatically by WEBrick when mounting. +stores+ and
# +cache+ are provided automatically by the servlet.
def initialize server, stores, cache, mount_path = nil
def initialize server, stores, cache, mount_path = nil, extra_doc_dirs = []
super server
@cache = cache
@mount_path = mount_path
@extra_doc_dirs = extra_doc_dirs
@stores = stores
@options = RDoc::Options.new
@ -121,6 +124,10 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
else
show_documentation req, res
end
rescue WEBrick::HTTPStatus::NotFound => e
generator = generator_for RDoc::Store.new
not_found generator, req, res, e.message
rescue WEBrick::HTTPStatus::Status
raise
rescue => e
@ -270,6 +277,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
# and the filesystem to the RDoc::Store for the documentation.
def installed_docs
extra_counter = 0
ri_paths.map do |path, type|
store = RDoc::Store.new path, type
exists = File.exist? store.cache_path
@ -284,6 +292,11 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
['Site Documentation', 'site/', exists, type, path]
when :home then
['Home Documentation', 'home/', exists, type, path]
when :extra then
extra_counter += 1
store.load_cache if exists
title = store.title || "Extra Documentation"
[title, "extra-#{extra_counter}/", exists, type, path]
end
end
end
@ -291,8 +304,9 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
##
# Returns a 404 page built by +generator+ for +req+ on +res+.
def not_found generator, req, res
res.body = generator.generate_servlet_not_found req.path
def not_found generator, req, res, message = nil
message ||= "The page <kbd>#{ERB::Util.h req.path}</kbd> was not found"
res.body = generator.generate_servlet_not_found message
res.status = 404
end
@ -300,7 +314,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
# Enumerates the ri paths. See RDoc::RI::Paths#each
def ri_paths &block
RDoc::RI::Paths.each true, true, true, :all, &block
RDoc::RI::Paths.each true, true, true, :all, *@extra_doc_dirs, &block #TODO: pass extra_dirs
end
##
@ -344,6 +358,8 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
when :home then
path = 'home'
comment = 'Documentation from your home directory'
when :extra
comment = name
end
info << [name, '', path, '', comment]
@ -397,6 +413,10 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
when 'site' then
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
when /^extra-(\d+)$/ then
index = $1.to_i - 1
ri_dir = installed_docs[index][4]
RDoc::Store.new ri_dir, :extra
else
ri_dir, type = ri_paths.find do |dir, dir_type|
next unless dir_type == :gem
@ -404,11 +424,16 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
source_name == dir[%r%/([^/]*)/ri$%, 1]
end
raise RDoc::Error,
"could not find ri documentation for #{source_name}" unless
ri_dir
raise WEBrick::HTTPStatus::NotFound,
"Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir
store = RDoc::Store.new ri_dir, type
return store if File.exist? store.cache_path
raise WEBrick::HTTPStatus::NotFound,
"Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`"
RDoc::Store.new ri_dir, type
end
end

View file

@ -187,12 +187,12 @@ class RDoc::Stats
# A report that says you did a great job!
def great_job
report = []
report << '100% documentation!'
report << nil
report << 'Great Job!'
report = RDoc::Markup::Document.new
report.join "\n"
report << RDoc::Markup::Paragraph.new('100% documentation!')
report << RDoc::Markup::Paragraph.new('Great Job!')
report
end
##
@ -217,8 +217,6 @@ class RDoc::Stats
extend RDoc::Text
end
report = []
if @coverage_level.zero? then
calculate
@ -227,14 +225,20 @@ class RDoc::Stats
ucm = @store.unique_classes_and_modules
report = RDoc::Markup::Document.new
report << RDoc::Markup::Paragraph.new('The following items are not documented:')
report << RDoc::Markup::BlankLine.new
ucm.sort.each do |cm|
report << report_class_module(cm) {
body = report_class_module(cm) {
[
report_constants(cm),
report_attributes(cm),
report_methods(cm),
].compact
}
report << body if body
end
if @coverage_level > 0 then
@ -243,10 +247,7 @@ class RDoc::Stats
return great_job if @num_items == @doc_items
end
report.unshift nil
report.unshift 'The following items are not documented:'
report.join "\n"
report
end
##
@ -260,7 +261,8 @@ class RDoc::Stats
cm.each_attribute do |attr|
next if attr.documented?
line = attr.line ? ":#{attr.line}" : nil
report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}"
report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n"
report << "\n"
end
report
@ -273,38 +275,47 @@ class RDoc::Stats
return if cm.fully_documented? and @coverage_level.zero?
return unless cm.display?
report = []
report = RDoc::Markup::Document.new
if cm.in_files.empty? then
report << "# #{cm.definition} is referenced but empty."
report << "#"
report << "# It probably came from another project. I'm sorry I'm holding it against you."
report << nil
report << RDoc::Markup::Paragraph.new("#{cm.definition} is referenced but empty.")
report << RDoc::Markup::Paragraph.new("It probably came from another project. I'm sorry I'm holding it against you.")
return report
elsif cm.documented? then
documented = true
report << "#{cm.definition} # is documented"
klass = RDoc::Markup::Verbatim.new("#{cm.definition} # is documented\n")
else
report << '# in files:'
report << RDoc::Markup::Paragraph.new('In files:')
list = RDoc::Markup::List.new :BULLET
cm.in_files.each do |file|
report << "# #{file.full_name}"
para = RDoc::Markup::Paragraph.new file.full_name
list << RDoc::Markup::ListItem.new(nil, para)
end
report << nil
report << list
report << RDoc::Markup::BlankLine.new
report << "#{cm.definition}"
klass = RDoc::Markup::Verbatim.new("#{cm.definition}\n")
end
klass << "\n"
body = yield.flatten # HACK remove #flatten
return if body.empty? and documented
if body.empty? then
return if documented
report << nil << body unless body.empty?
klass.parts.pop
else
klass.parts.concat body
end
report << 'end'
report << nil
klass << "end\n"
report << klass
report
end
@ -323,8 +334,9 @@ class RDoc::Stats
next if constant.documented? || constant.is_alias_for
line = constant.line ? ":#{constant.line}" : line
report << " # in file #{constant.file.full_name}#{line}"
report << " #{constant.name} = nil"
report << " # in file #{constant.file.full_name}#{line}\n"
report << " #{constant.name} = nil\n"
report << "\n"
end
report
@ -350,7 +362,7 @@ class RDoc::Stats
@undoc_params += undoc.length
undoc = undoc.map do |param| "+#{param}+" end
param_report = " # #{undoc.join ', '} is not documented"
param_report = " # #{undoc.join ', '} is not documented\n"
end
end
@ -359,10 +371,10 @@ class RDoc::Stats
line = method.line ? ":#{method.line}" : nil
scope = method.singleton ? 'self.' : nil
report << " # in file #{method.file.full_name}#{line}"
report << " # in file #{method.file.full_name}#{line}\n"
report << param_report if param_report
report << " def #{scope}#{method.name}#{method.params}; end"
report << nil
report << " def #{scope}#{method.name}#{method.params}; end\n"
report << "\n"
end
report
@ -385,35 +397,36 @@ class RDoc::Stats
@undoc_params,
].max.to_s.length
report = []
report << 'Files: %*d' % [num_width, @num_files]
report = RDoc::Markup::Verbatim.new
report << nil
report << "Files: %*d\n" % [num_width, @num_files]
report << 'Classes: %*d (%*d undocumented)' % [
report << "\n"
report << "Classes: %*d (%*d undocumented)\n" % [
num_width, @num_classes, undoc_width, @undoc_classes]
report << 'Modules: %*d (%*d undocumented)' % [
report << "Modules: %*d (%*d undocumented)\n" % [
num_width, @num_modules, undoc_width, @undoc_modules]
report << 'Constants: %*d (%*d undocumented)' % [
report << "Constants: %*d (%*d undocumented)\n" % [
num_width, @num_constants, undoc_width, @undoc_constants]
report << 'Attributes: %*d (%*d undocumented)' % [
report << "Attributes: %*d (%*d undocumented)\n" % [
num_width, @num_attributes, undoc_width, @undoc_attributes]
report << 'Methods: %*d (%*d undocumented)' % [
report << "Methods: %*d (%*d undocumented)\n" % [
num_width, @num_methods, undoc_width, @undoc_methods]
report << 'Parameters: %*d (%*d undocumented)' % [
report << "Parameters: %*d (%*d undocumented)\n" % [
num_width, @num_params, undoc_width, @undoc_params] if
@coverage_level > 0
report << nil
report << "\n"
report << 'Total: %*d (%*d undocumented)' % [
report << "Total: %*d (%*d undocumented)\n" % [
num_width, @num_items, undoc_width, @undoc_items]
report << '%6.2f%% documented' % percent_doc
report << nil
report << 'Elapsed: %0.1fs' % (Time.now - @start)
report << "%6.2f%% documented\n" % percent_doc
report << "\n"
report << "Elapsed: %0.1fs\n" % (Time.now - @start)
report.join "\n"
RDoc::Markup::Document.new report
end
##

View file

@ -305,8 +305,10 @@ class RDoc::Store
# cache included modules before they are removed from the documentation
all_classes_and_modules.each { |cm| cm.ancestors }
remove_nodoc @classes_hash
remove_nodoc @modules_hash
unless min_visibility == :nodoc then
remove_nodoc @classes_hash
remove_nodoc @modules_hash
end
@unique_classes = find_unique @classes_hash
@unique_modules = find_unique @modules_hash

View file

@ -1,4 +1,11 @@
require 'rubygems'
begin
gem 'minitest', '~> 4.0'
rescue NoMethodError
# for ruby tests
end
require 'minitest/autorun'
require 'minitest/benchmark' if ENV['BENCHMARK']
@ -45,6 +52,7 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
@rdoc = RDoc::RDoc.new
@rdoc.store = @store
@rdoc.options = RDoc::Options.new
g = Object.new
def g.class_dir() end
@ -52,6 +60,27 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
@rdoc.generator = g
end
##
# Asserts +path+ is a file
def assert_file path
assert File.file?(path), "#{path} is not a file"
end
##
# Asserts +path+ is a directory
def assert_directory path
assert File.directory?(path), "#{path} is not a directory"
end
##
# Refutes +path+ exists
def refute_file path
refute File.exist?(path), "#{path} exists"
end
##
# Shortcut for RDoc::Markup::BlankLine.new
@ -109,6 +138,16 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
@RM::List.new type, *items
end
##
# Enables pretty-print output
def mu_pp obj # :nodoc:
s = ''
s = PP.pp obj, s
s = s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
##
# Shortcut for RDoc::Markup::Paragraph.new with +contents+

View file

@ -140,7 +140,7 @@ module RDoc::Text
def snippet text, limit = 100
document = parse text
RDoc::Markup::ToHtmlSnippet.new(limit).convert document
RDoc::Markup::ToHtmlSnippet.new(options, limit).convert document
end
##

View file

@ -129,7 +129,8 @@ class RDoc::TomDoc < RDoc::Markup::Parser
def initialize
super
@section = nil
@section = nil
@seen_returns = false
end
# Internal: Builds a heading from the token stream
@ -176,9 +177,17 @@ class RDoc::TomDoc < RDoc::Markup::Parser
until @tokens.empty? do
type, data, = get
if type == :TEXT then
case type
when :TEXT then
@section = 'Returns' if data =~ /\AReturns/
paragraph << data
skip :NEWLINE
when :NEWLINE then
if :TEXT == peek_token[0] then
paragraph << ' '
else
break
end
else
unget
break
@ -190,6 +199,21 @@ class RDoc::TomDoc < RDoc::Markup::Parser
paragraph
end
##
# Detects a section change to "Returns" and adds a heading
def parse_text parent, indent # :nodoc:
paragraph = build_paragraph indent
if false == @seen_returns and 'Returns' == @section then
@seen_returns = true
parent << RDoc::Markup::Heading.new(3, 'Returns')
parent << RDoc::Markup::BlankLine.new
end
parent << paragraph
end
# Internal: Turns text into an Array of tokens
#
# text - A String containing TomDoc-format text.

View file

@ -30,7 +30,7 @@ class RDoc::TopLevel < RDoc::Context
attr_accessor :diagram # :nodoc:
##
# The parser that processed this file
# The parser class that processed this file
attr_accessor :parser

View file

@ -38,10 +38,39 @@ method(a, b) { |c, d| ... }
assert_equal 'my_c1_m', @c1_m.c_function
end
def test_call_seq_equals
m = RDoc::AnyMethod.new nil, nil
m.call_seq = ''
assert_nil m.call_seq
m.call_seq = 'foo'
assert_equal 'foo', m.call_seq
end
def test_full_name
assert_equal 'C1::m', @c1.method_list.first.full_name
end
def test_is_alias_for
assert_equal @c2_b, @c2_a.is_alias_for
# set string on instance variable
loaded = Marshal.load Marshal.dump @c2_a
loaded.store = @store
assert_equal @c2_b, loaded.is_alias_for, 'Marshal.load'
m1 = RDoc::AnyMethod.new nil, 'm1'
m1.store = @store
m1.instance_variable_set :@is_alias_for, ['Missing', false, 'method']
assert_nil m1.is_alias_for, 'missing alias'
end
def test_markup_code
tokens = [
RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'),
@ -101,11 +130,14 @@ method(a, b) { |c, d| ... }
end
def test_marshal_load_aliased_method
aliased_method = Marshal.load Marshal.dump(@c2.method_list.last)
aliased_method = Marshal.load Marshal.dump(@c2_a)
aliased_method.store = @store
assert_equal 'C2#a', aliased_method.full_name
assert_equal 'C2', aliased_method.parent_name
assert_equal '()', aliased_method.params
assert_equal @c2_b, aliased_method.is_alias_for, 'is_alias_for'
assert aliased_method.display?
end
@ -170,16 +202,87 @@ method(a, b) { |c, d| ... }
assert_equal nil, loaded.file
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert_nil loaded.is_alias_for
assert loaded.display?
end
def test_marshal_dump_version_2
@store.path = Dir.tmpdir
top_level = @store.add_file 'file.rb'
m = RDoc::AnyMethod.new nil, 'method'
m.block_params = 'some_block'
m.call_seq = 'call_seq'
m.comment = 'this is a comment'
m.params = 'param'
m.record_location top_level
cm = top_level.add_class RDoc::ClassModule, 'Klass'
cm.add_method m
section = cm.sections.first
al = RDoc::Alias.new nil, 'method', 'aliased', 'alias comment'
al_m = m.add_alias al, cm
loaded = Marshal.load "\x04\bU:\x14RDoc::AnyMethod[\x14i\bI" +
"\"\vmethod\x06:\x06ETI" +
"\"\x11Klass#method\x06;\x06T0:\vpublic" +
"o:\eRDoc::Markup::Document\b:\v@parts[\x06" +
"o:\x1CRDoc::Markup::Paragraph\x06;\t[\x06I" +
"\"\x16this is a comment\x06;\x06T:\n@file0" +
":0@omit_headings_from_table_of_contents_below0" +
"I\"\rcall_seq\x06;\x06TI\"\x0Fsome_block\x06" +
";\x06T[\x06[\aI\"\faliased\x06;\x06To;\b\b;\t" +
"[\x06o;\n\x06;\t[\x06I\"\x12alias comment\x06" +
";\x06T;\v0;\f0I\"\nparam\x06;\x06TI" +
"\"\ffile.rb\x06;\x06TFI\"\nKlass\x06;\x06T" +
"c\x16RDoc::ClassModule0"
loaded.store = @store
comment = doc(para('this is a comment'))
assert_equal m, loaded
assert_equal [al_m.name], loaded.aliases.map { |alas| alas.name }
assert_equal 'some_block', loaded.block_params
assert_equal 'call_seq', loaded.call_seq
assert_equal comment, loaded.comment
assert_equal top_level, loaded.file
assert_equal 'Klass#method', loaded.full_name
assert_equal 'method', loaded.name
assert_equal 'param', loaded.params
assert_equal nil, loaded.singleton # defaults to nil
assert_equal :public, loaded.visibility
assert_equal cm, loaded.parent
assert_equal section, loaded.section
assert_nil loaded.is_alias_for
end
def test_name
m = RDoc::AnyMethod.new nil, nil
assert_nil m.name
end
def test_name_call_seq
m = RDoc::AnyMethod.new nil, nil
m.call_seq = "yields(name)\nyields(name, description)"
assert_equal 'yields', m.name
end
def test_name_call_seq_dot
m = RDoc::AnyMethod.new nil, nil
m.call_seq = "obj.yields(name)\nobj.yields(name, description)"
assert_equal 'yields', m.name
end
def test_param_list_block_params
m = RDoc::AnyMethod.new nil, 'method'
m.parent = @c1

View file

@ -2,13 +2,6 @@ require File.expand_path '../xref_test_case', __FILE__
class TestRDocClassModule < XrefTestCase
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_add_comment
tl1 = @store.add_file 'one.rb'
tl2 = @store.add_file 'two.rb'
@ -108,23 +101,23 @@ class TestRDocClassModule < XrefTestCase
def test_documented_eh
cm = RDoc::ClassModule.new 'C'
refute cm.documented?
refute cm.documented?, 'no comments, no markers'
cm.add_comment '', @top_level
refute cm.documented?, 'empty comment'
cm.add_comment 'hi', @top_level
assert cm.documented?
cm.comment.replace ''
assert cm.documented?
assert cm.documented?, 'commented'
cm.comment_location.clear
refute cm.documented?
refute cm.documented?, 'no comment'
cm.document_self = nil # notify :nodoc:
assert cm.documented?
assert cm.documented?, ':nodoc:'
end
def test_each_ancestor
@ -165,6 +158,7 @@ class TestRDocClassModule < XrefTestCase
ns = tl.add_module RDoc::NormalModule, 'Namespace'
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
cm.document_self = true
cm.record_location tl
a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
@ -236,6 +230,59 @@ class TestRDocClassModule < XrefTestCase
assert_equal tl, loaded.method_list.first.file
end
def test_marshal_dump_visibilty
@store.path = Dir.tmpdir
tl = @store.add_file 'file.rb'
ns = tl.add_module RDoc::NormalModule, 'Namespace'
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
cm.record_location tl
a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
a1.record_location tl
a1.document_self = false
m1 = RDoc::AnyMethod.new nil, 'm1'
m1.record_location tl
m1.document_self = false
c1 = RDoc::Constant.new 'C1', nil, ''
c1.record_location tl
c1.document_self = false
i1 = RDoc::Include.new 'I1', ''
i1.record_location tl
i1.document_self = false
e1 = RDoc::Extend.new 'E1', ''
e1.record_location tl
e1.document_self = false
section_comment = RDoc::Comment.new('section comment')
section_comment.location = tl
assert_equal 1, cm.sections.length, 'sanity, default section only'
cm.add_attribute a1
cm.add_method m1
cm.add_constant c1
cm.add_include i1
cm.add_extend e1
cm.add_comment 'this is a comment', tl
loaded = Marshal.load Marshal.dump cm
loaded.store = @store
assert_equal cm, loaded
assert_empty loaded.attributes
assert_empty loaded.constants
assert_empty loaded.includes
assert_empty loaded.extends
assert_empty loaded.method_list
end
def test_marshal_load_version_0
tl = @store.add_file 'file.rb'
ns = tl.add_module RDoc::NormalModule, 'Namespace'
@ -1401,7 +1448,7 @@ class TestRDocClassModule < XrefTestCase
@c1.update_extends
assert_equal [a, c], @c1.extends
assert_equal [a, b, c], @c1.extends
end
def test_update_extends_trim

View file

@ -100,24 +100,56 @@ class TestRDocCodeObject < XrefTestCase
refute @co.display?
end
def test_display_eh_suppress
assert @co.display?
@co.suppress
refute @co.display?
@co.comment = comment('hi')
refute @co.display?
@co.done_documenting = false
assert @co.display?
@co.ignore
@co.done_documenting = false
refute @co.display?
end
def test_document_children_equals
@co.document_children = false
refute @co.document_children
# TODO this is not true anymore:
# test all the nodoc stuff etc...
#@c2.document_children = false
#assert_empty @c2.classes
@store.rdoc.options.visibility = :nodoc
@co.store = @store
assert @co.document_children
@co.document_children = false
assert @co.document_children
end
def test_document_self_equals
@co.document_self = false
refute @co.document_self
# TODO this is not true anymore:
# test all the nodoc stuff etc...
#@c1.document_self = false
#assert_empty @c1.method_list
@store.rdoc.options.visibility = :nodoc
@co.store = @store
assert @co.document_self
@co.document_self = false
assert @co.document_self
end
def test_documented_eh
@ -159,6 +191,18 @@ class TestRDocCodeObject < XrefTestCase
@co.done_documenting = false
assert @co.document_self
assert @co.document_children
@co.done_documenting = true
@store.rdoc.options.visibility = :nodoc
@co.store = @store
refute @co.done_documenting
@co.done_documenting = true
refute @co.done_documenting
end
def test_each_parent
@ -195,6 +239,18 @@ class TestRDocCodeObject < XrefTestCase
refute @co.document_self
refute @co.document_children
assert @co.ignored?
@store.rdoc.options.visibility = :nodoc
@co.store = @store
assert @co.document_self
assert @co.document_children
refute @co.ignored?
@co.ignore
refute @co.ignored?
end
def test_ignore_eh
@ -229,6 +285,14 @@ class TestRDocCodeObject < XrefTestCase
assert_equal 5, @c1_m.offset
end
def test_options
assert_kind_of RDoc::Options, @co.options
@co.store = @store
assert_same @options, @co.options
end
def test_parent_file_name
assert_equal '(unknown)', @co.parent_file_name
assert_equal 'xref_data.rb', @c1.parent_file_name
@ -263,6 +327,13 @@ class TestRDocCodeObject < XrefTestCase
refute @co.ignored?
end
def test_record_location_suppressed
@co.suppress
@co.record_location @xref_data
refute @co.suppressed?
end
def test_section
parent = RDoc::Context.new
section = parent.sections.first
@ -303,6 +374,30 @@ class TestRDocCodeObject < XrefTestCase
refute @co.ignored?
end
def test_start_doc_suppressed
@co.suppress
@co.start_doc
assert @co.document_self
assert @co.document_children
refute @co.suppressed?
end
def test_store_equals
@co.document_self = false
@co.store = @store
refute @co.document_self
@store.rdoc.options.visibility = :nodoc
@co.store = @store
assert @co.document_self
end
def test_stop_doc
@co.document_self = true
@co.document_children = true
@ -311,6 +406,44 @@ class TestRDocCodeObject < XrefTestCase
refute @co.document_self
refute @co.document_children
@store.rdoc.options.visibility = :nodoc
@co.store = @store
assert @co.document_self
assert @co.document_children
@co.stop_doc
assert @co.document_self
assert @co.document_children
end
def test_suppress
@co.suppress
refute @co.document_self
refute @co.document_children
assert @co.suppressed?
@store.rdoc.options.visibility = :nodoc
@co.store = @store
refute @co.suppressed?
@co.suppress
refute @co.suppressed?
end
def test_suppress_eh
refute @co.suppressed?
@co.suppress
assert @co.suppressed?
end
end

View file

@ -41,6 +41,14 @@ class TestRDocContext < XrefTestCase
assert_equal [as], @context.unmatched_alias_lists['#old_name']
end
def test_add
@context.add RDoc::Extend, 'Ext', 'comment'
@context.add RDoc::Include, 'Incl', 'comment'
refute_empty @context.extends
refute_empty @context.includes
end
def test_add_alias_method_attr
top_level = @store.add_file 'file.rb'
@ -691,6 +699,15 @@ class TestRDocContext < XrefTestCase
assert_equal [@apub, @aprot, @apriv], @vis.attributes
end
def test_remove_invisible_nodoc
util_visibilities
@vis.remove_invisible :nodoc
assert_equal [@pub, @prot, @priv], @vis.method_list
assert_equal [@apub, @aprot, @apriv], @vis.attributes
end
def test_remove_invisible_protected
util_visibilities

View file

@ -13,13 +13,6 @@ class TestRDocContextSection < RDoc::TestCase
@s = @S.new @klass, 'section', comment('# comment', @top_level)
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_add_comment
file1 = @store.add_file 'file1.rb'

View file

@ -19,9 +19,10 @@ class TestRDocCrossReference < XrefTestCase
def test_METHOD_REGEXP_STR
re = /#{RDoc::CrossReference::METHOD_REGEXP_STR}/
re =~ '==='
assert_equal '===', $&
%w'=== [] []= << >>'.each do |x|
re =~ x
assert_equal x, $&
end
end
def test_resolve_C2

View file

@ -65,21 +65,6 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
FileUtils.rm_rf @tmpdir
end
def assert_file path
assert File.file?(path), "#{path} is not a file"
end
def refute_file path
refute File.exist?(path), "#{path} exists"
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s = s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_generate
top_level = @store.add_file 'file.rb'
top_level.add_class @klass.class, @klass.name
@ -91,16 +76,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
assert_file 'table_of_contents.html'
assert_file 'js/search_index.js'
assert_hard_link 'rdoc.css'
assert_hard_link 'fonts.css'
assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
encoding = if Object.const_defined? :Encoding then
Regexp.escape Encoding::UTF_8.name
else
Regexp.escape 'UTF-8'
end
assert_match(/<meta content="text\/html; charset=#{encoding}"/,
File.read('index.html'))
assert_match(/<meta content="text\/html; charset=#{encoding}"/,
File.read('Object.html'))
assert_match %r%<meta charset="#{encoding}">%, File.read('index.html')
assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html')
refute_match(/Ignored/, File.read('index.html'))
end
@ -145,6 +134,36 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
refute_file 'image.png'
end
def test_install_rdoc_static_file
src = Pathname(__FILE__)
dst = File.join @tmpdir, File.basename(src)
options = {}
@g.install_rdoc_static_file src, dst, options
assert_file dst
begin
assert_hard_link dst
rescue MiniTest::Assertion
return # hard links are not supported, no further tests needed
end
@g.install_rdoc_static_file src, dst, options
assert_hard_link dst
end
def test_install_rdoc_static_file_missing
src = Pathname(__FILE__) + 'nonexistent'
dst = File.join @tmpdir, File.basename(src)
options = {}
@g.install_rdoc_static_file src, dst, options
refute_file dst
end
def test_setup
@g.setup
@ -183,5 +202,26 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
assert_same template, @g.send(:template_for, partial)
end
##
# Asserts that +filename+ has a link count greater than 1 if hard links to
# @tmpdir are supported.
def assert_hard_link filename
assert_file filename
src = @g.template_dir + '_head.rhtml'
dst = File.join @tmpdir, 'hardlinktest'
begin
FileUtils.ln src, dst
FileUtils.rm dst
rescue SystemCallError
return
end
assert_operator File.stat(filename).nlink, :>, 1,
"#{filename} is not hard-linked"
end
end

View file

@ -57,17 +57,6 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
FileUtils.rm_rf @tmpdir
end
def assert_file path
assert File.file?(path), "#{path} is not a file"
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s = s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_build_index
index = @g.build_index

View file

@ -42,14 +42,6 @@ class TestRDocGeneratorRI < RDoc::TestCase
FileUtils.rm_rf @tmpdir
end
def assert_file path
assert File.file?(path), "#{path} is not a file"
end
def refute_file path
refute File.exist?(path), "#{path} exists"
end
def test_generate
@g.generate

View file

@ -1,10 +1,6 @@
# coding: UTF-8
require 'rubygems'
require 'minitest/autorun'
require 'pp'
require 'rdoc'
require 'rdoc/test_case'
require 'rdoc/markup/block_quote'
require 'rdoc/markdown'
@ -14,13 +10,8 @@ class TestRDocMarkdown < RDoc::TestCase
@RM = RDoc::Markup
@parser = RDoc::Markdown.new
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
@to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
end
def test_class_parse
@ -439,7 +430,19 @@ heading
def test_parse_image
doc = parse "image ![alt text](path/to/image.jpg)"
expected = doc(para("image {alt text}[path/to/image.jpg]"))
expected = doc(para("image rdoc-image:path/to/image.jpg"))
assert_equal expected, doc
end
def test_parse_image_link
@parser.html = true
doc = parse "[![alt text](path/to/image.jpg)](http://example.com)"
expected =
doc(
para('{rdoc-image:path/to/image.jpg}[http://example.com]'))
assert_equal expected, doc
end

View file

@ -15,13 +15,6 @@ class TestRDocMarkdownTest < RDoc::TestCase
@parser = RDoc::Markdown.new
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_amps_and_angle_encoding
input = File.read "#{MARKDOWN_TEST_PATH}/Amps and angle encoding.text"

View file

@ -26,6 +26,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.add_word_pair("{", "}", :WOMBAT)
@wombat_on = @am.changed_attribute_by_name([], [:WOMBAT])
@wombat_off = @am.changed_attribute_by_name([:WOMBAT], [])
@klass = RDoc::Markup::AttributeManager
@formatter = RDoc::Markup::Formatter.new @rdoc.options
@formatter.add_tag :BOLD, '<B>', '</B>'
@formatter.add_tag :EM, '<EM>', '</EM>'
@formatter.add_tag :TT, '<CODE>', '</CODE>'
end
def crossref(text)
@ -44,6 +50,21 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
#assert_equal(["cat {and} dog" ], @am.flow("cat \\{and} dog"))
end
def test_add_html_tag
@am.add_html("Test", :TEST)
tags = @am.html_tags
assert_equal(6, tags.size)
assert(tags.has_key?("test"))
end
def test_add_special
@am.add_special "WikiWord", :WIKIWORD
specials = @am.special
assert_equal 1, specials.size
assert specials.assoc "WikiWord"
end
def test_add_word_pair
@am.add_word_pair '%', '&', 'percent and'
@ -60,6 +81,20 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal "Word flags may not start with '<'", e.message
end
def test_add_word_pair_invalid
assert_raises ArgumentError do
@am.add_word_pair("<", "<", :TEST)
end
end
def test_add_word_pair_map
@am.add_word_pair("x", "y", :TEST)
word_pair_map = @am.word_pair_map
assert_includes word_pair_map.keys.map { |r| r.source }, "(x)(\\S+)(y)"
end
def test_add_word_pair_matching
@am.add_word_pair '^', '^', 'caret'
@ -151,6 +186,56 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal "\000x-y\000", str
end
def test_convert_attrs_ignores_code
assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <code>__send__</code> bar')
end
def test_convert_attrs_ignores_tt
assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <tt>__send__</tt> bar')
end
def test_convert_attrs_preserves_double
assert_equal 'foo.__send__ :bar', output('foo.__send__ :bar')
assert_equal 'use __FILE__ to', output('use __FILE__ to')
end
def test_convert_attrs_does_not_ignore_after_tt
assert_equal 'the <CODE>IF:</CODE><EM>key</EM> directive', output('the <tt>IF:</tt>_key_ directive')
end
def test_escapes
assert_equal '<CODE>text</CODE>', output('<tt>text</tt>')
assert_equal '<tt>text</tt>', output('\\<tt>text</tt>')
assert_equal '<tt>', output('\\<tt>')
assert_equal '<CODE><tt></CODE>', output('<tt>\\<tt></tt>')
assert_equal '<CODE>\\<tt></CODE>', output('<tt>\\\\<tt></tt>')
assert_equal '<B>text</B>', output('*text*')
assert_equal '*text*', output('\\*text*')
assert_equal '\\', output('\\')
assert_equal '\\text', output('\\text')
assert_equal '\\\\text', output('\\\\text')
assert_equal 'text \\ text', output('text \\ text')
assert_equal 'and <CODE>\\s</CODE> matches space',
output('and <tt>\\s</tt> matches space')
assert_equal 'use <CODE><tt>text</CODE></tt> for code',
output('use <tt>\\<tt>text</tt></tt> for code')
assert_equal 'use <CODE><tt>text</tt></CODE> for code',
output('use <tt>\\<tt>text\\</tt></tt> for code')
assert_equal 'use <tt><tt>text</tt></tt> for code',
output('use \\<tt>\\<tt>text</tt></tt> for code')
assert_equal 'use <tt><CODE>text</CODE></tt> for code',
output('use \\<tt><tt>text</tt></tt> for code')
assert_equal 'use <CODE>+text+</CODE> for code',
output('use <tt>\\+text+</tt> for code')
assert_equal 'use <tt><CODE>text</CODE></tt> for code',
output('use \\<tt>+text+</tt> for code')
assert_equal 'illegal <tag>not</tag> changed',
output('illegal <tag>not</tag> changed')
assert_equal 'unhandled <p>tag</p> unchanged',
output('unhandled <p>tag</p> unchanged')
end
def test_html_like_em_bold
assert_equal ["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
@am.flow("cat <i>and </i><b>dog</b>")
@ -191,6 +276,38 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow("<tt>cat</tt> <i>and <b></i>dog</b>")
end
def test_initial_html
html_tags = @am.html_tags
assert html_tags.is_a?(Hash)
assert_equal(5, html_tags.size)
end
def test_initial_word_pairs
word_pairs = @am.matching_word_pairs
assert word_pairs.is_a?(Hash)
assert_equal(3, word_pairs.size)
end
def test_mask_protected_sequence
def @am.str() @str end
def @am.str=(str) @str = str end
@am.str = '<code>foo</code>'
@am.mask_protected_sequences
assert_equal "<code>foo</code>", @am.str
@am.str = '<code>foo\\</code>'
@am.mask_protected_sequences
assert_equal "<code>foo<\x04/code>", @am.str, 'escaped close'
@am.str = '<code>foo\\\\</code>'
@am.mask_protected_sequences
assert_equal "<code>foo\\</code>", @am.str, 'escaped backslash'
end
def test_protect
assert_equal(['cat \\ dog'],
@am.flow('cat \\ dog'))
@ -233,5 +350,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
@am.flow('<tt>"\n"</tt>')
end
def output str
@formatter.convert_flow @am.flow str
end
end

View file

@ -8,13 +8,6 @@ class TestRDocMarkupDocument < RDoc::TestCase
@d = @RM::Document.new
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_append
@d << @RM::Paragraph.new('hi')

View file

@ -71,20 +71,46 @@ class TestRDocMarkupFormatter < RDoc::TestCase
@to.add_special_RDOCLINK
assert_includes special_names, 'RDOCLINK'
def @to.handle_special_RDOCLINK special
"<#{special.text}>"
end
document = doc(para('{foo}[rdoc-label:bar].'))
formatted = document.accept @to
assert_equal '{foo}[<rdoc-label:bar>].', formatted
end
def test_add_special_TIDYLINK
@to.add_special_TIDYLINK
assert_includes special_names, 'TIDYLINK'
def @to.handle_special_TIDYLINK special
"<#{special.text}>"
end
document = doc(para('foo[rdoc-label:bar].'))
formatted = document.accept @to
assert_equal '<foo[rdoc-label:bar]>.', formatted
document = doc(para('{foo}[rdoc-label:bar].'))
formatted = document.accept @to
assert_equal '<{foo}[rdoc-label:bar]>.', formatted
end
def test_parse_url
scheme, url, id = @to.parse_url 'example/foo'
assert_equal 'http', scheme
assert_equal 'http://example/foo', url
assert_equal nil, id
assert_equal 'http', scheme
assert_equal 'example/foo', url
assert_equal nil, id
end
def test_parse_url_anchor

View file

@ -12,6 +12,15 @@ class TestRDocMarkupHeading < RDoc::TestCase
assert_equal 'label-Hello+Friend%21', @h.aref
end
def test_label
assert_equal 'label-Hello+Friend%21', @h.label
assert_equal 'label-Hello+Friend%21', @h.label(nil)
context = RDoc::NormalClass.new 'Foo'
assert_equal 'class-Foo-label-Hello+Friend%21', @h.label(context)
end
def test_plain_html
assert_equal 'Hello <strong>Friend</strong>!', @h.plain_html
end

View file

@ -12,13 +12,6 @@ class TestRDocMarkupParser < RDoc::TestCase
@RMP = @RM::Parser
end
def mu_pp(obj)
s = ''
s = PP.pp obj, s
s = s.force_encoding(Encoding.default_external) if @have_encoding
s.chomp
end
def test_build_heading
parser = @RMP.new

View file

@ -147,7 +147,7 @@ contents of a string.
def test_handle_directive_blankline
result = @pp.handle_directive '#', 'arg', 'a, b'
assert_equal "#\n", result
assert_equal "#:arg: a, b\n", result
end
def test_handle_directive_downcase
@ -169,7 +169,7 @@ contents of a string.
def test_handle_directive_arg_no_context
result = @pp.handle_directive '', 'arg', 'a, b', nil
assert_equal "\n", result
assert_equal ":arg: a, b\n", result
end
def test_handle_directive_args

View file

@ -8,13 +8,6 @@ class TestRDocMarkupRaw < RDoc::TestCase
@p = @RM::Raw.new
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_push
@p.push 'hi', 'there'

View file

@ -256,7 +256,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def accept_paragraph_break
assert_equal "\n<p>hello<br>\nworld</p>\n", @to.res.join
assert_equal "\n<p>hello<br> world</p>\n", @to.res.join
end
def accept_paragraph_i
@ -288,7 +288,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def accept_rule
assert_equal "<hr style=\"height: 4px\">\n", @to.res.join
assert_equal "<hr>\n", @to.res.join
end
def accept_verbatim
@ -357,12 +357,12 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.code_object = RDoc::NormalClass.new 'Foo'
@to.start_accepting
@to.accept_heading @RM::Heading.new(1, 'Hello')
@to.accept_heading head(1, 'Hello')
links = '<span><a href="#label-Hello">&para;</a> ' +
links = '<span><a href="#class-Foo-label-Hello">&para;</a> ' +
'<a href="#documentation">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n",
assert_equal "\n<h1 id=\"class-Foo-label-Hello\">Hello#{links}</h1>\n",
@to.res.join
end
@ -389,6 +389,35 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
end
def test_accept_paragraph_newline
@to.start_accepting
@to.accept_paragraph para("hello\n", "world\n")
assert_equal "\n<p>hello world</p>\n", @to.res.join
end
def test_accept_heading_output_decoration
@options.output_decoration = false
@to.start_accepting
@to.accept_heading @RM::Heading.new(1, 'Hello')
assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>\n", @to.res.join
end
def test_accept_heading_output_decoration_with_pipe
@options.pipe = true
@options.output_decoration = false
@to.start_accepting
@to.accept_heading @RM::Heading.new(1, 'Hello')
assert_equal "\n<h1>Hello</h1>\n", @to.res.join
end
def test_accept_verbatim_parseable
verb = @RM::Verbatim.new("class C\n", "end\n")
@ -422,6 +451,24 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
assert_equal expected, @to.res.join
end
def test_accept_verbatim_pipe
@options.pipe = true
verb = @RM::Verbatim.new("1 + 1\n")
verb.format = :ruby
@to.start_accepting
@to.accept_verbatim verb
expected = <<-EXPECTED
<pre><code>1 + 1
</code></pre>
EXPECTED
assert_equal expected, @to.res.join
end
def test_accept_verbatim_ruby
verb = @RM::Verbatim.new("1 + 1\n")
verb.format = :ruby
@ -457,13 +504,13 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def test_convert_RDOCLINK_label_foottext
result = @to.convert 'rdoc-label:foottext-1'
assert_equal "\n<p><a href=\"#foottext-1\">*1</a></p>\n", result
assert_equal "\n<p><a href=\"#foottext-1\">1</a></p>\n", result
end
def test_convert_RDOCLINK_label_footmark
result = @to.convert 'rdoc-label:footmark-1'
assert_equal "\n<p><a href=\"#footmark-1\">^1</a></p>\n", result
assert_equal "\n<p><a href=\"#footmark-1\">1</a></p>\n", result
end
def test_convert_RDOCLINK_ref
@ -475,7 +522,28 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def test_convert_TIDYLINK_footnote
result = @to.convert 'text{*1}[rdoc-label:foottext-1:footmark-1]'
assert_equal "\n<p>text<a id=\"footmark-1\" href=\"#foottext-1\">*1</a></p>\n", result
assert_equal "\n<p>text<sup><a id=\"footmark-1\" href=\"#foottext-1\">1</a></sup></p>\n", result
end
def test_convert_TIDYLINK_multiple
result = @to.convert '{a}[http://example] {b}[http://example]'
expected = <<-EXPECTED
<p><a href=\"http://example\">a</a> <a href=\"http://example\">b</a></p>
EXPECTED
assert_equal expected, result
end
def test_convert_TIDYLINK_image
result =
@to.convert '{rdoc-image:path/to/image.jpg}[http://example.com]'
expected =
"\n<p><a href=\"http://example.com\"><img src=\"path/to/image.jpg\"></a></p>\n"
assert_equal expected, result
end
def test_convert_TIDYLINK_rdoc_label
@ -501,7 +569,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def test_gen_url_rdoc_label_id
assert_equal '<a id="footmark-1" href="#foottext-1">example</a>',
assert_equal '<sup><a id="footmark-1" href="#foottext-1">example</a></sup>',
@to.gen_url('rdoc-label:foottext-1:footmark-1', 'example')
end

View file

@ -36,6 +36,13 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
result
end
def test_convert_CROSSREF_section
@c1.add_section 'Section'
result = @to.convert 'C1@Section'
assert_equal para("<a href=\"C1.html#Section\">Section at C1</a>"), result
end
def test_convert_RDOCLINK_rdoc_ref
result = @to.convert 'rdoc-ref:C1'

View file

@ -626,15 +626,15 @@ This routine modifies its +comment+ parameter.
def test_convert_RDOCLINK_label_foottext
result = @to.convert 'rdoc-label:foottext-1'
assert_equal "<p>*1\n", result
assert_equal 2, @to.characters
assert_equal "<p>1\n", result
assert_equal 1, @to.characters
end
def test_convert_RDOCLINK_label_footmark
result = @to.convert 'rdoc-label:footmark-1'
assert_equal "<p>^1\n", result
assert_equal 2, @to.characters
assert_equal "<p>1\n", result
assert_equal 1, @to.characters
end
def test_convert_RDOCLINK_ref

View file

@ -354,6 +354,12 @@ words words words words
assert_equal "C\n", result
end
def test_convert_RDOCLINK_image
result = @to.convert 'rdoc-image:/path/to/image.jpg'
assert_equal "![](/path/to/image.jpg)\n", result
end
def test_convert_TIDYLINK
result = @to.convert \
'{DSL}[http://en.wikipedia.org/wiki/Domain-specific_language]'

View file

@ -2,6 +2,10 @@ require File.expand_path '../xref_test_case', __FILE__
class TestRDocMethodAttr < XrefTestCase
def test_initialize_copy
refute_same @c1_m.full_name, @c1_m.dup.full_name
end
def test_block_params_equal
m = RDoc::MethodAttr.new(nil, 'foo')
@ -116,6 +120,10 @@ class TestRDocMethodAttr < XrefTestCase
assert_equal 'C1::m', @c1__m.full_name
end
def test_is_alias_for
assert_equal @c2_b, @c2_a.is_alias_for
end
def test_output_name
assert_equal '#m', @c1_m.output_name(@c1)
assert_equal '::m', @c1__m.output_name(@c1)

View file

@ -21,6 +21,11 @@ class TestRDocNormalClass < XrefTestCase
assert_equal [c2, c1, 'Object'], c3.ancestors
end
def test_aref
assert_equal 'class-C1', @c1.aref
assert_equal 'class-C2::C3', @c2_c3.aref
end
def test_direct_ancestors
incl = RDoc::Include.new 'Incl', ''

Some files were not shown because too many files have changed in this diff Show more