Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use @!scope class on an attribute defined by attr_* #1582

Open
UlyssesZh opened this issue Sep 11, 2024 · 0 comments
Open

Cannot use @!scope class on an attribute defined by attr_* #1582

UlyssesZh opened this issue Sep 11, 2024 · 0 comments

Comments

@UlyssesZh
Copy link

UlyssesZh commented Sep 11, 2024

If I add @!scope class for a attr_* call (such as attr_reader :test), there is an error.

Discussion context: #1581.

Steps to reproduce

Write these to lib/test.rb:

# A test class.
class Test

  # @!scope class
  # A test attribute.
  attr_reader :test
end

Then run yard doc --debug.

Actual Output

[debug]: Parsing ["{lib,app}/**/*.rb", "ext/**/*.{c,cc,cxx,cpp,rb}"] with `ruby` parser
[debug]: Parsing lib/test.rb                                                                   
[debug]: Serializing to .yardoc/objects/root.dat
[debug]: Re-generating object ...                                                                                                                                                             
[debug]: Re-generating object Test...                                                                                                                                                         
[debug]: Generating asset js/jquery.js                                                                                                                                                        
[debug]: Serializing to doc/js/jquery.js                                                                                                                                                      
[debug]: Generating asset js/app.js                                                                                                                                                           
[debug]: Serializing to doc/js/app.js                                                                                                                                                         
[debug]: Generating asset js/full_list.js
[debug]: Serializing to doc/js/full_list.js
[debug]: Generating asset css/style.css
[debug]: Serializing to doc/css/style.css
[debug]: Generating asset css/common.css
[debug]: Serializing to doc/css/common.css
[debug]: Generating asset css/full_list.css
[debug]: Serializing to doc/css/full_list.css
[debug]: Generating asset class_list.html
[debug]: Serializing to doc/class_list.html
[debug]: Generating asset method_list.html
[debug]: Serializing to doc/method_list.html
[debug]: Generating asset file_list.html
[debug]: Serializing to doc/file_list.html
[debug]: Generating asset frames.html
[debug]: Serializing to doc/frames.html
[debug]: Serializing to doc/index.html
[debug]: Serializing to doc/_index.html
[debug]: Serializing to doc/top-level-namespace.html
[error]: Exception occurred while generating 'Test.html'
[error]: NoMethodError: undefined method `[]' for nil
[error]: Stack trace:
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/html/attribute_details.erb:8:in `block (2 levels) in _erb_cache_24'
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/html/attribute_details.erb:6:in `each'
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/html/attribute_details.erb:6:in `each_with_index'
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/html/attribute_details.erb:6:in `block in _erb_cache_24'
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/setup.rb:155:in `block in scopes'
        /home/ulysses/.local/share/gem/ruby/3.3.0/gems/yard-0.9.37/templates/default/module/setup.rb:153:in `each'

Files:           1
Modules:         0 (    0 undocumented)
Classes:         1 (    0 undocumented)
Constants:       0 (    0 undocumented)
Attributes:      0 (    0 undocumented)
Methods:         1 (    0 undocumented)
 100.00% documented

Expected Output

Should be equivalent to what this would do:

# A test class.
class Test

  # @!scope class
  # @!attribute [r] test
  # A test attribute.
end

Environment details:

  • OS: NixOS 24.05
  • Ruby version (ruby -v): 3.3.4
  • YARD version (yard -v): 0.9.37

I have read the Contributing Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant