루비 코드를 문서화 할 때 특정 코드 규칙이 있습니까? 예를 들어 다음 코드 스 니펫이 있습니다.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
이것은 괜찮 으면 좋겠지 만 우수한/우수한 문서화 방법이 있습니까?
http://shop.oreilly.com/product/9780596516178.do에는 소스 코드에 멋진 예제가 있습니다. 2 장 목록을보십시오. 그것은 대답과 같습니다. 필자는 소스 코드를 보여주기 위해 rdoc을 사용했습니다. my_code.rb.txt에 my_code.rb와 같은 파일 확장명을 붙인 다음 rdoc을 실행할 수 있습니다. > rdoc my_code.rb.txt 그러면 rdoc이 HTML을 렌더링 할 것이므로 클래스와 모듈에 대해서는 중요하지 않습니다. 그걸 가지고 놀아 라. –