代码之家  ›  专栏  ›  技术社区  ›  Theo

我可以用正确的格式将README.textile放入RDoc吗?

  •  5
  • Theo  · 技术社区  · 16 年前

    3 回复  |  直到 16 年前
        1
  •  7
  •   James A. Rosen    16 年前

    使用 YARD

    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
    
        2
  •  2
  •   bess    16 年前

    如果您将项目托管在github上,也可以使用 http://rdoc.info 使用YARD自动构建和发布rdocs。

        3
  •  0
  •   Community Mohan Dere    9 年前

    我意识到代码在 26819

    desc "Generate RDoc"
    task :doc => ['doc:generate']
    
    namespace :doc do
    
      # edit: typically (for gems, at least), Rakefile is in the root, so ".", not ".."
      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|
          # edit: README.md is not a ruby source file - see
          # https://stackoverflow.com/questions/7907698/yard-0-7-3-fails-to-build-my-readme-in-both-markdown-and-textile
          # remove README.md from yt.files
          yt.files   = Dir.glob(File.join(project_root, 'lib', '**', '*.rb'))
          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
        #edit: doc_dir was undefined; replaced by doc_destination
        rm_r doc_destination if File.exists?(doc_destination)
      end
    
    end
    
    推荐文章