2

我正在使用带有 Markdown 的YARDoc来记录我的 Ruby 代码,并且希望在方法的文档中包含一个无序列表(HTML“项目符号”)。这是我到目前为止所拥有的:

$ cat file.rb
class Foo
  # Returns "foo", which consists of the letters:
  # * f
  # * o
  # * o
  def method; "foo"; end
end

我正在使用以下方法生成文档:

$ yard doc --markup markdown file.rb

但它不会生成 HTML 项目符号,它将星号 ( *) 视为文字字符。生成的doc/Foo.html文件包含:

<span class="summary_desc"><div class='inline'><p>Returns &quot;foo&quot;,
which consists of the letters:
* f
* o
* o.</p>
</div></span>

如何在 YARD 中使用 Markdown 插入 HTML 项目符号?我本质上希望上述输出中的每个字母都包含在 中,并且列表被一个元素<li>...</li>包围。<ul>

4

2 回答 2

5

我需要有一个空白行分隔第一行文本和列表的开头:

$ cat file.rb 
class Foo
  # Returns "foo", which consists of the letters:
  #
  # * f
  # * o
  # * o
  def method; "foo"; end
end

产生:

<div class="discussion">
  <p>Returns &quot;foo&quot;, which consists of the letters:</p>
  <ul>
    <li>f</li>
    <li>o</li>
    <li>o</li>
  </ul>
</div>
于 2013-05-14T07:24:00.287 回答
0
$ cat file.rb
class Foo
  # Returns "foo", which consists of the letters:

* f
* o
* o
^

  def method; "foo"; end
end

$ kramdown file.rb
<p>class Foo
  # Returns "foo", which consists of the letters:</p>

<ul>
  <li>f</li>
  <li>o</li>
  <li>o</li>
</ul>

<p>def method; "foo"; end
end</p>

http://kramdown.rubyforge.org/syntax.html#block-ials

于 2013-05-14T07:24:51.980 回答