<tt>在Ruby评论中代表什么?</tt>

时间:2012-12-20 12:02:09

标签: ruby-on-rails ruby

查看用Ruby编写的源代码,比如Rails,我经常看到小代码包含tt标记,如rails / activesupport / core_ext / array / access.rb

  # Equal to <tt>self[2]</tt>.
  #
  #   %w( a b c d e).third # => "c"
  def third
    self[2]
  end

这背后的惯例是什么,何时以及为什么决定使用这种表示法?

2 个答案:

答案 0 :(得分:4)

是的,我的错,抱歉

这是特殊RDoc系统的一部分。

Non-verbatim text can be marked up:
italic: word or <em>text</em>
bold:   word or <b>text</b>
typewriter: word or <tt>text</tt>

详细了解here

答案 1 :(得分:0)

我自己在Rails documentation guide

中找到了它
  

使用一对+...+作为固定宽度字体仅适用于单词;那   是:匹配\A\w+\z的任何内容。对于任何其他用途<tt>...</tt>,   特别是符号,二传手,内联片段等:

相关问题