2010-09-22 95 views
0

我有這樣的方法在一個類中我使用簡單RDOC問題

def binary_search(a,x) 
    # ... 
end 

,我想在文件中的參數顯示爲def binary_search(array, key),而不是binary_search(a,x)。我試圖使用文檔修改器# :binary_search: array, key沒有成功。我知道這是一件小事,但如果有人知道如何使文檔中的參數與實際源代碼中的參數不同,請告訴我?謝謝。

+1

根本就不使用短變量名? – Reactormonk 2010-09-22 19:26:20

+0

是的,我知道,我不知道。出於好奇,我只是問了這個問題。 – agentbanks217 2010-09-23 02:11:13

+0

在問題標題中放置「問題」是多餘的。 – 2011-04-10 22:56:57

回答

1

你應該能夠使用:call-seq:指令的方法頭註釋如下:

## 
# Pass array and key. 
# 
# :call-seq: 
# binary_search(array, key) 
def binary_search(a, x) 
    # ... 
end 

我還沒有得到這方面的工作還沒有。我正在使用RDoc V1.0.1和Ruby 1.8.7。

+0

我試過了,它在我的系統上也沒有工作,而且我正在使用RDoc 2.5.8運行Ruby 1.9.2 – agentbanks217 2010-09-23 02:12:28

1

也許嘗試# :args: thing_to_try像這樣:(小心空格)

# rdoc-2.5.8/lib/rdoc/parser/ruby.rb:48 
# The parser extracts the arguments from the method definition. You can 
# override this with a custom argument definition using the :args: directive: 

    ## 
    # This method tries over and over until it is tired 

    def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try 
    puts thing_to_try 
    go_go_go thing_to_try, tries - 1 
    end