Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does IntelliJ IDEA give a warning that this file javadoc is dangling?

I'm using IntelliJ IDEA and I tried to add a Javadoc comment at the top of the file like this:

/**
 * @file ProcessJson.java
 * @author Tim Sloane
 * @date 2017-05-09
 */

But IntelliJ gives me the warning "Dangling Javadoc comment." What makes this comment dangling? I thought because it's tagged with @file, it should be at the start of the file.

like image 898
T Sloane Avatar asked May 09 '17 15:05

T Sloane


People also ask

How do I use Javadoc in Intellij?

From the main menu, select Tools | Generate JavaDoc. In the dialog that opens, select a scope — a set of files or directories for which you want to generate the reference, and set the output directory where the generated documentation will be placed.

What is Javadoc used for?

Javadoc is a tool for generating API documentation in HTML format from doc comments in source code. It can be downloaded only as part of the Java 2 SDK. To see documentation generated by the Javadoc tool, go to J2SE 1.5. 0 API Documentation.

How do you write a comment document in Java?

A doc comment is written in HTML and must precede a class, field, constructor or method declaration. It is made up of two parts -- a description followed by block tags. In this example, the block tags are @param , @return , and @see .


1 Answers

You will also see this if you placed the Javadoc comment after any annotations.

For example:

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
/**  --> Dangling Javadoc warning.
 * This class does great and wonderful things.
 */
public class ClassThatDoesStuff {
}

Instead, the Javadoc must precede everything to receive the "No errors found in this file" seal of approval:

/**
 * This class does great and wonderful things.
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuppressWarnings({"unused", "WeakerAccess"})
public class ClassThatDoesStuff {
}
like image 139
Jonathan Fischer Avatar answered Sep 28 '22 06:09

Jonathan Fischer