Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby中Python文档字符串的等价物是什么?_Python_Ruby On Rails_Ruby_Documentation_Language Comparisons - Fatal编程技术网

Ruby中Python文档字符串的等价物是什么?

Ruby中Python文档字符串的等价物是什么?,python,ruby-on-rails,ruby,documentation,language-comparisons,Python,Ruby On Rails,Ruby,Documentation,Language Comparisons,在Python中,您可以使用obj.\uuuu doc\uuuu访问对象的docstring。Ruby中的等效操作是什么?我不相信Ruby支持这一点 Ruby没有Python\uuuuu文档等价物。它们通常用于编写文档。使用Yard在Ruby中编写文档更容易,Yard支持不同的标记,如:NODOC: 要用Yard记录代码,只需在代码上方写注释 # MyClass.new(...) some comment here class MyClass end # foo("bar") def foo(

在Python中,您可以使用
obj.\uuuu doc\uuuu
访问对象的docstring。Ruby中的等效操作是什么?

我不相信Ruby支持这一点

Ruby没有Python
\uuuuu文档
等价物。它们通常用于编写文档。

使用Yard在Ruby中编写文档更容易,Yard支持不同的标记,如
:NODOC:

要用Yard记录代码,只需在代码上方写注释

# MyClass.new(...) some comment here
class MyClass
end

# foo("bar")
def foo(bar = nil)
end

然后在项目的当前工作目录上运行
yard
,这将为您生成
$PWD/doc
目录,其中包含一组很好的文档。

不幸的是,Ruby没有任何类似Python的内置docstring


RDoc看起来很糟糕。RDoc被设计成HTML格式并在we浏览器中读取。这不是纯文本。谁喜欢阅读类似HTML的源代码?院子里比较好。还有一些只使用纯文本的。但是没有一个可以与Pythonic docstrings相比,Pythonic docstrings允许从任何python控制台进行简单的自动完成,并且确实需要使用任何处理工具。

好吧,也许你应该首先问一下Ruby是否有docstrings……Yard是一种可选的方法,但是它是标准的,因为它与Ruby一起提供。