如何在YARD文档中创建任意链接?(How do I create an arbitrary link in YARD documentation?)

编程入门 行业动态 更新时间:2024-10-25 10:30:47
如何在YARD文档中创建任意链接?(How do I create an arbitrary link in YARD documentation?)

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

# I like {http://stackoverflow.com Stackoverflow}

呈现为

<p>I like <a href="http://stackoverflow.com">Stackoverflow</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似乎忽略了这一点。 有谁知道更可靠的语法?

I'm trying to create some links in my YARD documentation. I can get an HTTP link:

# I like {http://stackoverflow.com Stackoverflow}

renders as

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

But an email link:

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

gives me a warning:

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

and renders as

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

I've tried the regular RDoc syntax for links:

bugs[mailto:bugs@myproject.com]

but YARD seems to ignore that. Does anyone know of a more reliable syntax?

最满意答案

挖掘YARD的代码显示问题:在gems/yard-0.2.3.5/lib/yard有第(73)行:

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

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

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

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

Digging into YARD's code shows the problem: in gems/yard-0.2.3.5/lib/yard there is the line (73):

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

which doesn't allow mailto links. You can replace this line with

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

and it will work as you want... not exactly ideal, but that's all I've got right now.

更多推荐

本文发布于:2023-08-04 08:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412422.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   链接   如何在   YARD   documentation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!