@link (synonyms: {@linkcode}, {@linkplain})¶
-
.. @link::
¶ - 同义词
- 语法
{@link namepathOrURL} [link text]{@link namepathOrURL} {@link namepathOrURL|link text} {@link namepathOrURL link text (after the first space)}
- 概述
The
@link
inline tag creates a link to the namepath or URL that you specify. When you use the@link
tag, you can also provide link text, using one of several different formats. If you don’t provide any link text, JSDoc uses the namepath or URL as the link text.If you need to link to a tutorial, use the
@tutorial
instead of the@link
tag.- 链接格式
By default,
@link
generates standard HTML anchor tags. However, you may prefer to render certain links in a monospace font, or to specify the format of individual links. You can use the following synonyms for the@link
tag to control the formatting of links:@linkcode
: Forces the link’s text to use a monospace font.@linkplain
: Forces the link’s text to appear as normal text, without a monospace font.
您还可以在JSDoc的配置文件中设置以下选项之一;有关更多详细信息, 请参阅`配置JSDoc <about-configurations-jsdoc.html>`__:
templates.cleverLinks
: 当设置为``true``时, URL的链接使用普通文本, 而代码链接使用等宽字体.templates.monospaceLinks
: When set totrue
, all links use a monospace font, except for links created with the@linkplain
tag.
注意
Although the default JSDoc template renders all of these tags correctly, other templates may not recognize the
@linkcode
and@linkplain
tags. In addition, other templates may ignore the configuration options for link rendering.- 示例
The following example shows all of the ways to provide link text for the
@link
tag:Providing link text¶/** * See {@link MyClass} and [MyClass's foo property]{@link MyClass#foo}. * Also, check out {@link http://www.google.com|Google} and * {@link https://github.com GitHub}. */ function myFunction() {}
默认情况下, 上面的示例生成类似于以下内容的输出:
- caption
Output for {@link} tags
See <a href="MyClass.html">MyClass</a> and <a href="MyClass.html#foo">MyClass's foo property</a>. Also, check out <a href="http://www.google.com">Google</a> and <a href="https://github.com">GitHub</a>.
如果配置属性``templates.cleverLinks``设置为``true``, 上面的例子将产生以下输出:
- caption
Output with clever links enabled
See <a href="MyClass.html"><code>MyClass</code></a> and <a href="MyClass.html#foo"> <code>MyClass's foo property</code></a>. Also, check out <a href="http://www.google.com">Google</a> and <a href="https://github.com">GitHub</a>.