我正在尝试使用YARD
记录我的代码,但是我很难弄清楚如何摆脱以下警告:
$ ~/.gem/ruby/2.3.0/bin/yard
[warn]: @param tag has unknown parameter name: val
in file `lib/wolfsden_myanimelist/values.rb' near line 22
Files: 4
Modules: 2 ( 2 undocumented)
Classes: 4 ( 2 undocumented)
Constants: 6 ( 6 undocumented)
Attributes: 14 ( 0 undocumented)
Methods: 4 ( 0 undocumented)
66.67% documented
在以下代码中:
# @overload episode
# Gets last seen episode.
# @return [Integer] last seen episode
# @overload episode=(val)
# Sets last seen episode.
# @param val last seen episode
attr_reader :episode
def episode=(val)
@status = Integer(val)
end
但我相信这正是文档(http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md#Documentation_for_a_Separate_Attribute_Writer)建议的方式。那么,我怎样才能摆脱警告?
答案 0 :(得分:1)
我相信您需要做的是为参数提供数据类型。它看起来像这样:
# @overload episode
# Gets last seen episode.
# @overload episode=(val)
# Sets last seen episode.
# @param [String, Integer] val Last seen episode
# @return [Integer] Last seen episode
attr_reader :episode
def episode=(val)
@status = Integer(val)
end
一个参数中可以有多个数据类型——我将 String
和 Integer
放入,因为用户可以放入其中之一。