如何记录Ruby代码?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (3)
  • 关注 (0)
  • 查看 (46)

记录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
提问于
用户回答回答于
用户回答回答于

、建议使用RDoC,这几乎是标准。它很容易阅读代码注释,它允许你轻松地创建基于web的文档为你的项目。

用户回答回答于

你应该针对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)

扫码关注云+社区

领取腾讯云代金券