2010-09-22 97 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