From df7dac9174a31e71b58be6184e23bfe6b742a494 Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 18 Sep 2013 23:33:36 +0000 Subject: * 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 --- ChangeLog | 11 + lib/rdoc.rb | 7 +- lib/rdoc/any_method.rb | 52 +- lib/rdoc/class_module.rb | 30 +- lib/rdoc/code_object.rb | 121 +- lib/rdoc/comment.rb | 3 - lib/rdoc/context.rb | 22 +- lib/rdoc/cross_reference.rb | 2 +- lib/rdoc/extend.rb | 116 +- lib/rdoc/generator/darkfish.rb | 53 +- lib/rdoc/generator/template/darkfish/_footer.rhtml | 8 +- lib/rdoc/generator/template/darkfish/_head.rhtml | 22 +- .../template/darkfish/_sidebar_VCS_info.rhtml | 7 +- .../template/darkfish/_sidebar_classes.rhtml | 6 +- .../template/darkfish/_sidebar_extends.rhtml | 7 +- .../template/darkfish/_sidebar_in_files.rhtml | 7 +- .../template/darkfish/_sidebar_includes.rhtml | 7 +- .../template/darkfish/_sidebar_installed.rhtml | 9 +- .../template/darkfish/_sidebar_methods.rhtml | 8 +- .../template/darkfish/_sidebar_navigation.rhtml | 12 +- .../template/darkfish/_sidebar_pages.rhtml | 10 +- .../template/darkfish/_sidebar_parent.rhtml | 7 +- .../template/darkfish/_sidebar_search.rhtml | 19 +- .../template/darkfish/_sidebar_sections.rhtml | 9 +- .../darkfish/_sidebar_table_of_contents.rhtml | 13 +- lib/rdoc/generator/template/darkfish/class.rhtml | 77 +- lib/rdoc/generator/template/darkfish/fonts.css | 167 ++ .../template/darkfish/fonts/Lato-Light.ttf | Bin 0 -> 94668 bytes .../template/darkfish/fonts/Lato-LightItalic.ttf | Bin 0 -> 94196 bytes .../template/darkfish/fonts/Lato-Regular.ttf | Bin 0 -> 96184 bytes .../template/darkfish/fonts/Lato-RegularItalic.ttf | Bin 0 -> 95316 bytes .../template/darkfish/fonts/SourceCodePro-Bold.ttf | Bin 0 -> 71200 bytes .../darkfish/fonts/SourceCodePro-Regular.ttf | Bin 0 -> 71692 bytes lib/rdoc/generator/template/darkfish/index.rhtml | 18 +- .../generator/template/darkfish/js/darkfish.js | 15 - lib/rdoc/generator/template/darkfish/js/search.js | 16 +- lib/rdoc/generator/template/darkfish/page.rhtml | 18 +- lib/rdoc/generator/template/darkfish/rdoc.css | 465 ++--- .../template/darkfish/servlet_not_found.rhtml | 10 +- .../generator/template/darkfish/servlet_root.rhtml | 38 +- .../template/darkfish/table_of_contents.rhtml | 31 +- lib/rdoc/include.rb | 118 +- lib/rdoc/known_classes.rb | 1 + lib/rdoc/markdown.rb | 2172 ++++++++------------ lib/rdoc/markdown/literals_1_9.rb | 2 +- lib/rdoc/markup.rb | 21 +- lib/rdoc/markup/attribute_manager.rb | 5 +- lib/rdoc/markup/formatter.rb | 6 +- lib/rdoc/markup/heading.rb | 13 + lib/rdoc/markup/parser.rb | 9 +- lib/rdoc/markup/pre_process.rb | 2 +- lib/rdoc/markup/to_html.rb | 105 +- lib/rdoc/markup/to_html_crossref.rb | 3 + lib/rdoc/markup/to_markdown.rb | 12 +- lib/rdoc/method_attr.rb | 12 + lib/rdoc/mixin.rb | 120 ++ lib/rdoc/normal_class.rb | 4 + lib/rdoc/normal_module.rb | 4 + lib/rdoc/options.rb | 82 +- lib/rdoc/parser.rb | 9 + lib/rdoc/parser/c.rb | 50 +- lib/rdoc/parser/ruby.rb | 1159 ++++++----- lib/rdoc/rd/block_parser.rb | 124 +- lib/rdoc/rd/inline_parser.rb | 98 +- lib/rdoc/rdoc.rb | 9 +- lib/rdoc/ri/driver.rb | 281 ++- lib/rdoc/ruby_lex.rb | 225 +- lib/rdoc/ruby_token.rb | 81 +- lib/rdoc/rubygems_hook.rb | 11 +- lib/rdoc/servlet.rb | 41 +- lib/rdoc/stats.rb | 109 +- lib/rdoc/store.rb | 6 +- lib/rdoc/test_case.rb | 39 + lib/rdoc/text.rb | 2 +- lib/rdoc/tom_doc.rb | 30 +- lib/rdoc/top_level.rb | 2 +- test/rdoc/test_rdoc_any_method.rb | 105 +- test/rdoc/test_rdoc_class_module.rb | 77 +- test/rdoc/test_rdoc_code_object.rb | 149 +- test/rdoc/test_rdoc_context.rb | 17 + test/rdoc/test_rdoc_context_section.rb | 7 - test/rdoc/test_rdoc_cross_reference.rb | 7 +- test/rdoc/test_rdoc_generator_darkfish.rb | 78 +- test/rdoc/test_rdoc_generator_json_index.rb | 11 - test/rdoc/test_rdoc_generator_ri.rb | 8 - test/rdoc/test_rdoc_markdown.rb | 27 +- test/rdoc/test_rdoc_markdown_test.rb | 7 - test/rdoc/test_rdoc_markup_attribute_manager.rb | 121 ++ test/rdoc/test_rdoc_markup_document.rb | 7 - test/rdoc/test_rdoc_markup_formatter.rb | 32 +- test/rdoc/test_rdoc_markup_heading.rb | 9 + test/rdoc/test_rdoc_markup_parser.rb | 7 - test/rdoc/test_rdoc_markup_pre_process.rb | 4 +- test/rdoc/test_rdoc_markup_raw.rb | 7 - test/rdoc/test_rdoc_markup_to_html.rb | 86 +- test/rdoc/test_rdoc_markup_to_html_crossref.rb | 7 + test/rdoc/test_rdoc_markup_to_html_snippet.rb | 8 +- test/rdoc/test_rdoc_markup_to_markdown.rb | 6 + test/rdoc/test_rdoc_method_attr.rb | 8 + test/rdoc/test_rdoc_normal_class.rb | 5 + test/rdoc/test_rdoc_normal_module.rb | 5 + test/rdoc/test_rdoc_options.rb | 149 +- test/rdoc/test_rdoc_parser.rb | 15 + test/rdoc/test_rdoc_parser_c.rb | 124 +- test/rdoc/test_rdoc_parser_changelog.rb | 7 - test/rdoc/test_rdoc_parser_rd.rb | 7 - test/rdoc/test_rdoc_parser_ruby.rb | 357 +++- test/rdoc/test_rdoc_rd_block_parser.rb | 8 - test/rdoc/test_rdoc_rd_inline_parser.rb | 1 - test/rdoc/test_rdoc_rdoc.rb | 25 +- test/rdoc/test_rdoc_ri_driver.rb | 31 +- test/rdoc/test_rdoc_ruby_lex.rb | 117 +- test/rdoc/test_rdoc_servlet.rb | 82 +- test/rdoc/test_rdoc_stats.rb | 302 +-- test/rdoc/test_rdoc_store.rb | 30 +- test/rdoc/test_rdoc_text.rb | 74 +- test/rdoc/test_rdoc_tom_doc.rb | 60 +- test/rdoc/xref_test_case.rb | 2 + 118 files changed, 5190 insertions(+), 3396 deletions(-) create mode 100644 lib/rdoc/generator/template/darkfish/fonts.css create mode 100644 lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf create mode 100644 lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf create mode 100644 lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf create mode 100644 lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf create mode 100644 lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf create mode 100644 lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf create mode 100644 lib/rdoc/mixin.rb diff --git a/ChangeLog b/ChangeLog index 9620d8cfc2..39e82e5358 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Sep 19 08:33:14 2013 Eric Hodel + + * 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 * ext/psych/lib/psych.rb: updating Psych version diff --git a/lib/rdoc.rb b/lib/rdoc.rb index 32a3658e41..7f2f8913f7 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -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 rdoc --help 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' diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb index 23110dcb2a..3afafc86b8 100644 --- a/lib/rdoc/any_method.rb +++ b/lib/rdoc/any_method.rb @@ -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 ## diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb index b796050431..71566f050a 100644 --- a/lib/rdoc/class_module.rb +++ b/lib/rdoc/class_module.rb @@ -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 diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 83732e3d3b..4620fa586d 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -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 diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb index 2b5be44ee5..33ced18b5a 100644 --- a/lib/rdoc/comment.rb +++ b/lib/rdoc/comment.rb @@ -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 diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb index 22339bf1c7..892a43e118 100644 --- a/lib/rdoc/context.rb +++ b/lib/rdoc/context.rb @@ -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 diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb index 2cb0571732..5b08d5202d 100644 --- a/lib/rdoc/cross_reference.rb +++ b/lib/rdoc/cross_reference.rb @@ -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 diff --git a/lib/rdoc/extend.rb b/lib/rdoc/extend.rb index 2bccfba084..efa2c69bee 100644 --- a/lib/rdoc/extend.rb +++ b/lib/rdoc/extend.rb @@ -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 O(n!) 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 diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 26f545b14b..bd37b60668 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -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 diff --git a/lib/rdoc/generator/template/darkfish/_footer.rhtml b/lib/rdoc/generator/template/darkfish/_footer.rhtml index 0736c335ba..3d9526f02a 100644 --- a/lib/rdoc/generator/template/darkfish/_footer.rhtml +++ b/lib/rdoc/generator/template/darkfish/_footer.rhtml @@ -1,5 +1,5 @@ -