在编写ruby代码文档时,是否有特定的代码约定?例如,我有以下代码片段:
require 'open3'
module ProcessUtils
# Runs a subprocess and applies handlers for stdout and stderr
# Params:
# - command: command line string to be executed by the system
# - outhandler: proc object that takes a pipe object as first and only param (may be nil)
# - errhandler: proc object that takes a pipe object as first and only param (may be nil)
def execute_and_handle(command, outhandler, errhandler)
Open3.popen3(command) do |_, stdout, stderr|
if (outhandler)
outhandler.call(stdout)
end
if (errhandler)
errhandler.call(stderr)
end
end
end
end
这种猜测是可以的,但也许有更好的/更好的文档实践?
发布于 2009-11-06 00:01:28
您应该将您的文档定位于RDoc处理器,它可以找到您的文档并从中生成HTML.您已经将注释放在了正确的位置,但是您应该看看RDoc documentation,以了解RDoc知道如何格式化的标签类型。为此,我将按如下方式重新格式化您的评论:
# Runs a subprocess and applies handlers for stdout and stderr
# Params:
# +command+:: command line string to be executed by the system
# +outhandler+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
# +errhandler+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
发布于 2012-12-14 23:32:22
我建议了解一下RDoc。但也不要忽视非常流行的YARD A Ruby Document工具。你会在网上看到很多Ruby的文档使用Yard。RVM知道Yard并使用它在您的机器上生成文档(如果可用)。
RDoc仍然是必需的,因为Yard正在使用它。
发布于 2009-11-06 00:00:57
Rails有一些API Documentation Guidelines。这可能是一个很好的起点。
https://stackoverflow.com/questions/1681467
复制相似问题