How do I configure IntelliJ to insert <p> tags into existing javadoc? - intellij-idea

I have configured my Android Studio (IntelliJ) to insert <p> characters on empty new lines in javadoc by checking the check box in Preferences > Code Style > Java > JavaDoc.
However, when I apply my formatter to my existing code base (Code > Reformat Code...), the <p> tags are not inserted.
My question is, how do I get the IDE to apply the formatter successfully for javadoc newline <p> tokens?

If you have JavaDoc like this:
/**
* Text
* <- no tag will be added here
* #author foo
*/
The <p/> tag will not be inserted between Text and #author, because it would serve no purpose there. The tags will only be inserted between lines of the description (the first part of the JavaDoc):
/**
* Text 1
* <- <p/> will be inserted on this line after reformat
* Text 2
* <- no tag will be inserted here
* #author foo
*/
I'm not certain if this is the problem you're experiencing. Let me know in the comments if it works for you with multiline description as in the second example or if it doesn't work at all.

Related

Make folded multiline comment show first line

I have a question regarding IntelliJ's comment folding.
I have the following comment:
/**
* compileNews() converts the text of TextCompiler.soundAlarm() to audio as speech.mp3
*
* #throws Exception
*/
When I fold it, it looks like:
/**...*/
Is there any way that I can get it to fold and show the first line of the comment?
such like:
/**compileNews() converts the text of TextCompiler.soundAlarm() to audio as speech.mp3*/
The text shown as a placeholder for a folded code fragment is controlled by the IDE; it cannot be changed by the user. See https://youtrack.jetbrains.com/issue/IDEA-144788 for a related YouTrack issue.

How to format json comments in IntelliJ?

I need add some json in comment to let the comment clearly. But I found IntelliJ will remove all indentation, so is there plugins or methods let IntelliJ format the json in comment correctly? I have tried to find such plugins but they do not take effect at comment.
Try wrapping your json inside the comment with <pre> tags
Eg:
/*
* <pre>
* {
* json: "value1"
* }
* </pre>
*/
Intellij should ignore formatting alignment for text within <pre> tag in javadoc. (With default code style settings for java).

How to keep IntelliJ IDEA from rearranging javadoc tags?

/**
* Comment.
*
* <p>Hello
*
* #author me (me#domain.com)
* #version $Id$
* #since 0.1
* #checkstyle ClassDataAbstractionCoupling (500 lines)
* #checkstyle ClassFanOutComplexity (500 lines)
*/
When I reformat my code with Ctrl+Alt+L, the #since is placed after the #checkstyle tags. Is there any way to disable javadoc tag rearrangement on code reformatting?
You can uncheck Enable JavaDoc formatting in Settings/Code Style/Java/JavaDoc, which should fix the problem.
However this means that no other formatting will be performed (wrapping, alignining, etc). I haven't found a way to disable just the rearranging of tags.
You can also use this plugin with disabled JavaDoc formatting in IDEA.
With that combination you still have an asterisk * inserted at newline, and you can configure all generated JavaDoc templates for each part of code.
It also has a feature of upgrade existing JavaDoc.

Doxygen Alias to Ignore Line

In an effort to adapt a company-wide header format to doxygen, I would like to create some custom tags that will be ignored by doxygen. I think I can do this with an alias, but so far have only been able to replace tags with others. What I am trying to accomplish:
/**
* #company Company Name
**/
with an alias like #company="". Unfortunately, this just prints the text with no section name.
Any ideas?
You could use HTML style comments to hide parts, i.e.
/** Show this <!-- but hide this --> and show this again */
Or you could use #if...#endif
/** Show this #if VISIBILE but hide this #endif and show this again */
To save typing you could define a pair of aliases
ALIASES = hide="#if VISIBLE" endhide="#endif"
and then write
/** Show this #hide but hide this #endhide and show this again */

Intellij Idea Code Indentetion Confuses at Comments

When I create a Java file a Javadoc command author is added to file by me. Intellij IDEA also adds date and time which are not yet implemented to Javadoc yet as a comment. When I do auto code indentation it becomes like that:
/**
* #author kamaci
* Date: 11.01.2013
* Time: 00:47
*/
instead of:
/**
* #author kamaci
* Date: 11.01.2013
* Time: 00:47
*/
How to achieve it?
You probably want to uncheck "align parameter descriptions" in Settings->Code Style->Java->JavaDoc(tab)
You can uncheck "Enable leading asterisks".
Reference: https://www.jetbrains.com/help/idea/2016.1/code-style-java.html?origin=old_help