在记录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
Run Code Online (Sandbox Code Playgroud)
这个猜测没关系,但也许有更好/更优秀的文档实践?
Ken*_*oom 188
您应该定位RDoc处理器的文档,该处理器可以找到您的文档并从中生成HTML.您已将评论放在正确的位置,但您应该查看RDoc文档以了解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)
Run Code Online (Sandbox Code Playgroud)
vgo*_*off 22
我建议按照规定了解RDoc.但是不要忽略非常流行的YARD A Ruby Document工具.你将在网上看到Ruby的很多文档使用Yard.RVM知道Yard并使用它在您的机器上生成文档(如果可用).
当Yard使用它时,仍然需要RDoc.