ruby / ruby/rdoc

Rdoc is not generated if executed on a custom task.

Open
#372 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feedback Required
Dominant language
Ruby
Stars
930
Forks
465
Avg merge
3d 10h
Merged PRs (30d)
27

Description

I wrote a task to create doc of my gem in a project folder that install this gem, just reading the Rakefile. I debugging then finding the problem. The method file of the module Rake::DSL (https://github.com/ruby/rake/blob/v10.4.2/lib/rake/dsl_definition.rb#L82) did not run the lines that are within the block passed as a parameter. When checked this method, i saw he calls another, but none of them has the method yield to return execution to the body block. So one of my solutions was:

"Monkey patches"...

# rake/lib/rake/dsl_definition.rb
module Rake
  module DSL

    private
    def file(*args, &block) # :doc:
      Rake::FileTask.define_task(*args, &block)
      # this line has been added
      yield if block_given?
    end

  end
end

The rdoc method that uses the method file is the define of the class RDoc::Task (https://github.com/rdoc/rdoc/blob/v4.2.0/lib/rdoc/task.rb#L243).

Another problem I found was at the time the darkfish generates files in folders. In the method generate_page the variable out_file (https://github.com/rdoc/rdoc/blob/v4.2.0/lib/rdoc/generator/darkfish.rb#L454) gets a junction of paths: the path root of the app, + path rdoc (set to rdoc_dir) + file.path. The problem is file.path because when we define the files with rdoc_files.include if we put the absolute path, gives problem because what should be joined is only the filename, not all the way. I resolved with the method File.basename Ruby.

class RDoc::Generator::Darkfish

  def generate_page file
    setup

    template_file = @template_dir + 'page.rhtml'

    # this line has been modified
    out_file = @outputdir + File.basename(file.path)
    debug_msg "  working on %s (%s)" % [file.full_name, out_file]
    rel_prefix = @outputdir.relative_path_from out_file.dirname
    search_index_rel_prefix = rel_prefix
    search_index_rel_prefix += @asset_rel_path if @file_output

    # suppress 1.9.3 warning
    current          = current          = file
    asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path

    @title = "#{file.page_name} - #{@options.title}"

    debug_msg "  rendering #{out_file}"
    render_template template_file, out_file do |io| binding end
  end

end

Now works. I just run: $ rake my_gem:rdoc

They can fix this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with RDoc::Task#define in rdoc/task.rb and RDoc::Generator::Darkfish#generate_page in rdoc/generator/darkfish.rb, then compare the referenced Rake::DSL#file behavior in rake/lib/rake/dsl_definition.rb. Reproduce the issue with rake my_gem:rdoc; done means a custom task generates the requested RDoc files correctly, including when absolute paths are supplied.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.