ruby - 如何阻止 RDoc 解析 URL?

标签 ruby rdoc

假设我有以下类(class)。

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>

实现这一目标的最佳方法是什么?

最佳答案

第 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>

关于ruby - 如何阻止 RDoc 解析 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4676167/

相关文章:

ruby - 序列化哈希数组

ruby-on-rails - 没有 Rails、Rspec 或 Cucumber 的 Capybara 的 NoMethod 错误

ruby-on-rails - Sorbet - 无法解析常量

ruby-on-rails - 如何为(所有)Rails 生成 RDOC?

ruby - 将 Ruby 源代码作为 HTML 添加到 RDoc

ruby-on-rails - rake 中止!不知道如何构建任务 'doc:app'

ruby - 如何在案例中使用 "break"...而在 Ruby 中

ruby-on-rails - 如何修复DEPRECATION WARNING : Class level methods will no longer inherit scoping from in Rails 6. 1?

css - 如何自定义 rdoc Darkfish 样式表?

ruby - 如何使 rdoc 链接到带有等号的方法