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
これは大丈夫だと思いますが、おそらくより優れた/優れた文書化の方法がありますか?
shop.oreilly.com/product/9780596516178.doのソースコードには、ちょっとした良い例があります。第2章のリストをご覧ください。それはここの答えのようなものです。私はソースコードを表示するためだけにrdocで遊んだことがあります。ファイル拡張子をmy_code.rbからmy_code.rb.txtのようにして、それに対してrdocを実行できます。> rdoc my_code.rb.txtの場合、rdocはとにかくHTMLをレンダリングするため、クラスやモジュールについては問題になりません。楽しんでください。
—
ダグラスG.アレン