简体   繁体   English

如何在ruby documentor中声明特定类型的数组?

[英]How to declare array of a particular type in ruby documentor?

I'd like to declare an array of objects with the exact object class in rubydoc for either a parameter or variable, or for @return . 我想在rubydoc中为参数或变量或@return声明具有确切对象类的对象数组。 (it must be RDoc?..) (必须是RDoc ?。)

The main reason, to make RubyMine (or another IDE) work for autocomplete stuff, clickable methods, refactoring, etc., in right way. 使RubyMine(或其他IDE)以正确的方式工作于自动完成功能,可点击方法,重构等的主要原因是。

In PHP will look like: 在PHP中将如下所示:

/**
 * @param array $items
 * @param Filter[] $filters
 * @return Result[]
 */
function filter($items, $filters) {}

I'm just not sure if it can work in similar way in RubyMine: 我只是不确定它是否可以在RubyMine中以类似方式工作:

##
# @param [Array] items
# @param [Filter[]] filters
# @return [ResultClass[]]
#
def filter(items, filters); end

Extra example in PHP: PHP中的额外示例:

class My
{
    public $name;
}

/**
 * @return My[]
 */
function foo()
{
      // Similar code here
      //return [new My(), new My()];
}

function show()
{
    foreach (foo() as $item) {
        // IDE will make autocomplete for My::$name
        echo "$item->name\n";
    }
}
class TheClass
  # @param items   [Array]
  # @param filters [Array<Filter>]
  # @return        [Array<TheClass>]
  def filter(items, filters); end
end

As documented YARD Tags . 如记录的YARD标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM