lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.94k stars 397 forks source link

Yardoc tries to read directory named readme #1160

Open BurdetteLamar opened 6 years ago

BurdetteLamar commented 6 years ago

When I have a directory named readme in my main project directory, yardoc fails.

Steps to reproduce

  1. Create directory ./readme.
  2. Run yardoc.
  3. See error message.

Here are my files/dirs in the project (top level):

$ ls -1 bin/ CODE_OF_CONDUCT.md Gemfile Gemfile.lock images/ lib/ LICENSE LICENSE.txt markdown_helper.gemspec MarkdownHelper/ pkg/ Rakefile readme/ README.md test/

Actual Output

C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/code_objects/extra_file_object.rb:77:in `read': Is a directory @ rb_sysopen - readme (Errno::EISDIR)
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/code_objects/extra_file_object.rb:77:in `ensure_parsed'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/code_objects/extra_file_object.rb:25:in `initialize'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/cli/yardoc.rb:299:in `new'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/cli/yardoc.rb:299:in `parse_arguments'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/cli/yardoc.rb:248:in `run'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/lib/yard/cli/command.rb:14:in `run'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/yard-0.9.12/bin/yardoc:13:in `<top (required)>'
        from C:/Ruby22/bin/yardoc:23:in `load'
        from C:/Ruby22/bin/yardoc:23:in `<main>'

Expected Output

No errors

Environment details:

Fwiw

Why, you may ask, would I have a directory named readme? Because my README.md file is built from a number of source files, most of which live in that directory. If interested, see gem markdown_helper.

lsegal commented 6 years ago

My guess is YARD is picking up readme as the first README* file in your directory. You can work around this by telling YARD where your readme is with

yard --readme README.md

Or by placing --readme README.md in your .yardopts file.

BurdetteLamar commented 6 years ago

Or, as in my case, renaming to readme_files.

SolaWing commented 5 years ago

if the readme dictory is other's gem, we can't modify it.

a simple patch

        readme = Dir.glob('README{,*[^~]}').
          select { |fn| File.file? fn }. # this line
          sort_by {|r| [r.count('.'), r.index('.'), r] }.first

fix the problem