【问题标题】:How do I create an arbitrary link in YARD documentation?如何在 YARD 文档中创建任意链接?
【发布时间】:2025-12-17 17:40:01
【问题描述】:

我正在尝试在我的 YARD 文档中创建一些链接。我可以得到一个 HTTP 链接:

# I like {http://*.com *}

呈现为

<p>I like <a href="http://*.com">*</a></p>

但是一个电子邮件链接:

# You can email the {mailto:bugs@myproject.com bugs} list

给我一​​个警告:

[warn]: In file `':: Cannot resolve link to mailto:bugs@myprojectmailto:bugs@myproject.com from text:

并呈现为

<p>You can email the <tt>bugs</tt> list</p>

我已经尝试过链接的常规 RDoc 语法:

bugs[mailto:bugs@myproject.com]

但 YARD 似乎忽略了这一点。有谁知道更可靠的语法吗?

【问题讨论】:

    标签: ruby documentation rdoc yard


    【解决方案1】:

    深入研究 YARD 的代码会发现问题:在 gems/yard-0.2.3.5/lib/yard有第(73)行:

    if name.include?("://")
    

    这不允许 mailto 链接。您可以将此行替换为

    if name.include?("://") or name.include?("mailto:")
    

    它会按照你的意愿工作......并不完全理想,但这就是我现在所拥有的。

    【讨论】:

    【解决方案2】:

    0.2.3.6会有这个支持

    【讨论】: