本文介绍了我可以使用正确的格式将README.textile放入RDoc吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用Textile或Markdown为我的项目编写自述文件,但是当我生成RDoc时,自述文件被解释为RDoc,看起来确实很恐怖.有没有一种方法可以使RDoc通过RedCloth或BlueCloth而不是其自己的格式化程序来运行文件?可以将其配置为从文件后缀自动检测格式吗? (例如README.textile通过RedCloth运行,而README.mdown通过BlueCloth运行)

I like to use Textile or Markdown to write readme files for my projects, but when I generate the RDoc the readme file gets interpreted as RDoc and looks really horrible. Is there a way to make RDoc run the file through RedCloth or BlueCloth instead of its own formatter? Can it be configured to autodetect the formatting from the file suffix? (e.g. README.textile gets run through RedCloth, but README.mdown gets run through BlueCloth)

推荐答案

直接使用 YARD 代替RDoc可以使您只要文件后缀合理,就包括Textile或Markdown文件.我经常使用以下Rake任务:

Using YARD instead of RDoc directly will let you include Textile or Markdown files so long as their file suffixes are reasonable. I often use something like the following Rake task:

desc "Generate RDoc"
task :doc => ['doc:generate']

namespace :doc do
  project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
  doc_destination = File.join(project_root, 'doc', 'rdoc')

  begin
    require 'yard'
    require 'yard/rake/yardoc_task'

    YARD::Rake::YardocTask.new(:generate) do |yt|
      yt.files   = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + 
                   [ File.join(project_root, 'README.md') ]
      yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
    end
  rescue LoadError
    desc "Generate YARD Documentation"
    task :generate do
      abort "Please install the YARD gem to generate rdoc."
    end
  end

  desc "Remove generated documenation"
  task :clean do
    rm_r doc_dir if File.exists?(doc_destination)
  end

end

这篇关于我可以使用正确的格式将README.textile放入RDoc吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 12:55