Sha256: 00cc0369523e187577e7ab2f05b7ff86e6e99fb33b20e8c0eadd72a2144d1832

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'active_support/concern'

module RDoc # :nodoc:
  ##
  # Extend RDoc to support plaintext files that will be displayed inside a <pre> block.
  #
  # After RDoc is loaded:
  #
  #     require 'dionysus/rdoc/no_markup'
  #     RDoc::NoMarkup.files.include('LICENSE','VERSION')
  module NoMarkup
    FILE_NAMES = Rake::FileList.new
    
    def self.files() FILE_NAMES; end
    
    def self.no_markup_for_file?(file_name)
      self.files.resolve.to_a.include?(file_name)
    end
    
    module Parser # :nodoc:
      extend ActiveSupport::Concern
      
      included do
        class << self
          alias_method :can_parse_with_markup, :can_parse
          alias_method :can_parse, :can_parse_without_markup
        end
      end
      
      module ClassMethods # :nodoc:
        def can_parse_without_markup(file_name)
          if NoMarkup.no_markup_for_file?(file_name)
            ::RDoc::Parser::Simple
          else
            can_parse_with_markup(file_name)
          end
        end
      end
    end
    
    module TopLevel # :nodoc:
      extend ActiveSupport::Concern
      
      module InstanceMethods # :nodoc:
        def description
          return super unless NoMarkup.no_markup_for_file?(full_name)
          txt = File.read(::RDoc::RDoc.current.generator.basedir + full_name)
          %(<pre>#{txt}</pre>)
        end
      end
    end
  end
end

RDoc::TopLevel.send(:include, RDoc::NoMarkup::TopLevel)
RDoc::Parser.send(:include, RDoc::NoMarkup::Parser)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dionysus-1.0.2 lib/dionysus/rdoc/no_markup.rb
dionysus-1.0.1 lib/dionysus/rdoc/no_markup.rb
dionysus-1.0.0 lib/dionysus/rdoc/no_markup.rb
dionysus-0.4.0 lib/dionysus/rdoc/no_markup.rb