如何以正确的方式声明和显示与常量值相关的文档?
我正在使用 Ruby on Rails 3.1.0,并尝试使用 YARD 0.7.4。我想记录常量值,因此在我的类中我声明了这一点:
# [Fixnum] Test constant documentation.
TEST_CONSTANT = 1
但是运行 yardoc
(或 yard doc
)命令后的 HTML 输出如下:
< img src="https://i.sstatic.net/R6gqS.png" alt="在此处输入图像描述">
上图中显示 HTML 文档渲染/生成不佳,至少不像我那样预计。我阅读了 YAML 文档,但我仍然有一些问题:如何更好地声明和显示与常量值相关的文档?
I am using Ruby on Rails 3.1.0 and I am trying to use YARD 0.7.4. I would like to document constant values, so in my class I state this:
# [Fixnum] Test constant documentation.
TEST_CONSTANT = 1
but the HTML output after I run the yardoc
(or yard doc
) command is the following:
In the above image is shown that the HTML documentation is not good rendered/generated, at least not as I would expect. I read the YAML documentation but I still have some problem on that: how can I better state and display documentation related to constant values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了这个问题,谷歌给我回复了这篇未答复的帖子。我在另一个论坛中找到了 Loren Segal(Yard 的创建者)的答案: link_to_forum。出于完整性原因,我为遇到相同问题的人添加了这一点:
您以记录任何其他对象的方式记录它。只需将注释放在常量上方即可。
但请注意,至少对我来说,结果格式看起来有点奇怪。它首先格式化常量的名称,然后显示说明,然后显示值。我希望首先是描述,然后是名称和值。
I also ran into this problem and google returned me this unanswered post. I found the answer by Loren Segal (creator of Yard) in another forum: link_to_forum. For completeness reasons I add this for people that run into the same problem:
You document it the same way you document any other object. Just put comments above the constant.
Note though that at least for me the resulting formatting looks a bit strange. It first formats the name of the constant, then shows the description and then the values. I would expect first the description, followed by the name and values.