Sha256: 744de553563cda7ef8b9fa6492724af4c1e2e2ed20879b5e6a27e79cb152ac4e
Contents?: true
Size: 1.71 KB
Versions: 4
Compression:
Stored size: 1.71 KB
Contents
require 'active_support/concern' begin Markdown rescue NameError require 'rdiscount' end module RDoc # :nodoc: ## # Extend RDoc to support Markdown files. It will automatically use Markdown # for any files with the `.md` or `.markdown` extension. You may also specify # files with `RDoc::Markdown.files` # # After RDoc is loaded: # # require 'dionysus/rdoc/markdown' # RDoc::Markdown.files.include('README') module Markdown FILE_NAMES = Rake::FileList.new def self.files() FILE_NAMES; end def self.markdown_for_file?(file_name) %w(.md .markdown).include?(File.extname(file_name)) or self.files.resolve.to_a.include?(file_name) end module Parser # :nodoc: extend ActiveSupport::Concern included do class << self alias_method :can_parse_without_markdown, :can_parse alias_method :can_parse, :can_parse_with_markdown end end module ClassMethods # :nodoc: def can_parse_with_markdown(file_name) result = can_parse_without_markdown(file_name) if result.nil? and Markdown.markdown_for_file?(file_name) ::RDoc::Parser::Simple else result end end end end module TopLevel # :nodoc: extend ActiveSupport::Concern module InstanceMethods # :nodoc: def description return super unless Markdown.markdown_for_file?(full_name) ::Markdown.new(File.read(::RDoc::RDoc.current.generator.basedir + full_name)).to_html end end end end end RDoc::TopLevel.send(:include, RDoc::Markdown::TopLevel) RDoc::Parser.send(:include, RDoc::Markdown::Parser)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dionysus-1.0.2 | lib/dionysus/rdoc/markdown.rb |
dionysus-1.0.1 | lib/dionysus/rdoc/markdown.rb |
dionysus-1.0.0 | lib/dionysus/rdoc/markdown.rb |
dionysus-0.4.0 | lib/dionysus/rdoc/markdown.rb |