gpt4 book ai didi

ruby - YARD - @param 标签有未知的参数名称

转载 作者:行者123 更新时间:2023-12-03 17:17:02 32 4
gpt4 key购买 nike

我正在尝试使用 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 )建议的做法。那么,我怎样才能摆脱警告呢?

最佳答案

我相信您需要做的是为参数提供数据类型。它看起来像这样:

# @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
一个参数中可以有多个数据类型——我把 StringInteger in,因为用户可以放入其中之一。

关于ruby - YARD - @param 标签有未知的参数名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41274424/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com