在yard文档工具中的@tag和@!标签有什么区别? [英] What's the difference between @tag and @!tag in Yard documentation tool?

查看:161
本文介绍了在yard文档工具中的@tag和@!标签有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查看院子文件时,我发现一些以冒号标记为前缀的标签。

While looking at Yard documentation and examples sI found some tags prefixed by an exclamation mark.

我发现有和没有感叹号的工作示例,我无法察觉到差异,所以当$ $ c使用$ c> @!some-tag 而不是 @ some-tag

I found working examples with and without exclamation marks and I wasn't able to spot the difference, so what changes when @!some-tag is used instead of @some-tag?

例如,这段代码为 attr attr2

class Anything
  # @!attribute [rw] attr
  # @attribute [rw] attr2
end

另一方面,在一些 示例感叹号的重要性被强调了,所以应该做一些事情,但我不能找到有关其使用的任何文档。

On the other side, in some examples the importance of exclamation mark is underlined, so it's supposed to do something, but I can't find any documentation on its usage.

这两个Rails模型中的这些注释产生新的方法

Both these comments in a Rails model generate new methods

# @!method with_bang(param)
scope :foo_bar, where(foo: 'bar')
# @method without_bang(param)
scope :foo_baz, where(foo: 'baz')

院子输出:

推荐答案

c $ c>修改器在 Yard 中被使用,当记录的代码段将在其类中生成属性或方法时。例如:

The ! modifier in Yard is used when the documented piece of code will generate attributes or methods in its class. For example:

# @!method foo(name, opts = {})
create_a_foo_method

这是告诉我们, create_a_foo_method 将生成一个带签名的方法 def foo(name,ops = {})。您可以将这一思路应用到 @!scope @!visibility 以及其他 @!标记。如Yard文档所述,这对于记录DSL是有用的。

This is telling us that create_a_foo_method will generate a method with the signature def foo(name, ops = {}). You can apply this line of thinking to @!scope, @!visibility, and every other @!tag. As said in Yard documentation, this is useful for documenting DSLs.

这篇关于在yard文档工具中的@tag和@!标签有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆