2011-01-13 31 views
1

假設我有跟班。如何防止RDoc解析URL?

class Foo 

    # I want the following to appear as-is in my documentation, not as an anchor tag. 
    # 
    # http://www.google.com/ 
    # 
    def bar 
    puts "bar" 
    end 
end 

然後我通過rdoc運行它。

$ rdoc foo.rb

它會產生這樣的:

<div class="method-description"> 
    <p> 
    I want the following to appear as-is in my documentation, not as an anchor tag. 
    </p> 
    <p> 
    <a href="http://www.google.com">www.google.com</a>/ 
    </p> 
</div> 

我希望它產生這樣的事情,而不是:

<div class="method-description"> 
    <p> 
    I want the following to appear as-is in my documentation, not as an anchor tag. 
    </p> 
    <p> 
    http://www.google.com/ 
    </p> 
</div> 

什麼是完成這一任務的最好方法是什麼?

回答

3

步驟1

確保您使用的是:

ruby 1.9.2 
rdoc 2.5.8 

步驟2

逃避它,你應該罰款。

class Foo 

    # I want the following to appear as-is in my documentation, not as an anchor tag. 
    # 
    # \http://www.google.com/ 
    # 
    def bar 
    puts "bar" 
    end 
end 

輸出:

<div class="method-description"> 
    <p> 
    I want the following to appear as-is in my documentation, not as an anchor tag. 
    </p> 
    <p> 
    http://www.google.com/ 
    </p> 
</div> 
+1

這是真的,你有輸出?所有這些對我來說都是錨標籤前面的反斜槓。 – jdl 2011-01-13 03:16:02