System, but they may not be reproduced for publication



Yüklə 83 Mb.
Pdf görüntüsü
səhifə79/82
tarix19.04.2023
ölçüsü83 Mb.
#106251
1   ...   74   75   76   77   78   79   80   81   82
Java A Beginner’s Guide, Eighth Edition ( PDFDrive )

block tags), and they must be used on their own line. Tags that begin with a brace, such
as {@code}, are called in­line tags, and they can be used within a larger description.
You may also use other, standard HTML tags in a documentation comment. However,
some tags such as headings should not be used, because they disrupt the look of the
HTML file produced by javadoc.
As it relates to documenting source code, you can use documentation comments to
document classes, interfaces, fields, constructors, methods, and modules. In all cases,
the documentation comment must immediately precede the item being documented.
Some tags, such as @see, @since, and @deprecated, can be used to document any
element. Other tags apply to only the relevant elements. Several key tags are examined


next.
NOTE
Documentation comments can also be used for documenting a package and preparing
an overview, but the procedures differ from those used to document source code. See
the javadoc documentation for details on these uses. Beginning wtih JDK 9, javadoc
can also document a module­info.java file.
@author
The @author tag documents the author of a program element. It has the following
syntax:
@author description
Here, description will usually be the name of the author. You will need to specify the ­
author option when executing javadoc in order for the @author field to be included
in the HTML documentation.
{@code}
The {@code} tag enables you to embed text, such as a snippet of code, into a
comment. That text is then displayed as­is in code font, without any further processing
such as HTML rendering. It has the following syntax:
{@code code­snippet}
@deprecated
The @deprecated tag specifies that a program element is deprecated. It is
recommended that you include @see or {@link} tags to inform the programmer
about available alternatives. The syntax is the following:
@deprecated description
Here, description is the message that describes the deprecation. The @deprecated tag
can be used in documentation for fields, methods, constructors, classes, modules, and
interfaces.
{@docRoot}


{@docRoot}
{@docRoot} specifies the path to the root directory of the current documentation.
@exception
The @exception tag describes an exception to a method. It has the following syntax:
@exception exception­name explanation
Here, the fully qualified name of the exception is specified by exception­name, and
explanation is a string that describes how the exception can occur. The @exception
tag can be used only in documentation for a method or constructor.
@hidden
The @hidden tag prevents an element from appearing in the documentation.
{@index}
The {@index} tag specifies an item that will be indexed, and thus found when using
the search feature. It has the following syntax:
{@index term usage­str }
Here, term is the item (which can be a quoted string) to be indexed. usage­str is
optional. Thus, in the following @exception tag, {@index} causes the term "error" to
be added to the index:
Note that the word “error” is still displayed as part of the description. It’s just that now
it is also indexed. If you include the optional usage­str, then that description will be
shown in the index and in the search box to indicate how the term is used. For example,
{@index error Serious execution failure} will show “Serious execution failure”
under "error" in the index and in the search box.
{@inheritDoc}
This tag inherits a comment from the immediate superclass.
{@link}


{@link}
The {@link} tag provides an in­line link to additional information. It has the following
syntax:
{@link pkg.class#member text}
Here, pkg.class#member specifies the name of a class or method to which a link is
added, and text is the string that is displayed.
{@linkplain}
The {@linkplain} tag inserts an in­line link to another topic. The link is displayed in
plain­text font. Otherwise, it is similar to {@link}.
{@literal}
The {@literal} tag enables you to embed text into a comment. That text is then
displayed as­is, without any further processing such as HTML rendering. It has the
following syntax:
{@literal description}
Here, description is the text that is embedded.
@param
The @param tag documents a parameter. It has the following syntax:
@param parameter­name explanation
Here, parameter­name specifies the name of a parameter. The meaning of that
parameter is described by explanation. The @param tag can be used only in
documentation for a method, a constructor, or a generic class or interface.
@provides
The @provides tag documents a service provided by a module. It has the following
syntax:
@provides type explanation


Here, type specifies a service provider type and explanation describes the service
provider.
@return
The @return tag describes the return value of a method. It has the following syntax:
@return explanation
Here, explanation describes the type and meaning of the value returned by a method.
The @return tag can be used only in documentation for a method.
@see
The @see tag provides a reference to additional information. Two commonly used
forms are shown here:
@see anchor
@see pkg.class#member text
In the first form, anchor is a link to an absolute or relative URL. In the second form,

Yüklə 83 Mb.

Dostları ilə paylaş:
1   ...   74   75   76   77   78   79   80   81   82




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə