Disabling Eclipse code formatting for the javadoc part

I have a Java class for which the javadoc part is actually generated as part of the build process: the return value of the method (static String value) is inserted into the source file, like the $Revision: $ tags in version control software.

Although this behavior may be questionable, such duplication of information is required for the structure used (WEKA machine learning library). I would like the formatting of the Eclipse code not to interfere with the generated comments. I am using the Eclipse Indigo release.

I can enable / disable formatting with special comments //@formatter:on and //@formatter:off . However, @formatter tags @formatter function in "normal" comments, not in javadoc comments. Obviously, they can be easily confused for javadoc tags. This means that I cannot turn off formatting (for example, automatic line @formatter ) for the generated part of the javadoc comment and leave it to the rest, because @formatter directives should be placed around the javadoc comment.

Is there any way around code to format code inside javadoc comments?

+8
eclipse code-generation javadoc weka eclipse-jdt
source share
2 answers

You can turn off formatting for the header, but I don't think you can selectively turn off formatting for javadoc comments without a header.

+1
source share

Some time passed since this was asked / answered and helped me clarify the following answer, hopefully additionally useful. I use this alternative since I wanted to run Javascript in Javadocs.

Eclipse provides @formatter: off and @formatter: for which you need to enable via Windows-> Preferences-> java-> code style-> formatter: edit button: tab "off / on tags", They can be used in any comments.

Around the doc document

 // @formatter:off /** * javadoc */ // @formatter:on 

But if you want the formatter in javadoc to use @formatter: xxx in the html <!-- xxxxx --> comments to indicate what you are trying to do. Use <code>...</code> bloack to not format and include code as javascript.

Changed the code instructions in the example since I wanted this to work on eclipse and netbeans. I found the formatter: off, but then stopped working on another version of eclipse (yes, I use several versions of the IDE).

 /** * <br><!-- @formatter:off --> * <code> * <script type="text/javascript"> * // hash structure for holding variable as name and its text * var hashText = {}; * * // function causes a hyper-link to be created * function insertLink(varName, text){ * var link22; * * hashText[varName] = text; * * link22 = '<a href="./ConsoleCapture.html#' + varName + '">' + hashText[varName] + '</a>'; * * document.write(link22); * } * function insertLinkA(varName){ * var link22; * * link22 = '<a href="./ConsoleCapture.html#' + varName + '">' + hashText[varName] + '</a>'; * * document.write(link22); * } * * function setLinkPoint(varName, text){ * hashText[varName] = text; * * document.write('<a id="' + varName + '"><U>' + hashText[varName] + '</U></a>'); * } * * function setLinkPointA(varName){ * document.write('<a id="' + varName + '"><U>' + hashText[varName] + '</U></a>'); * } * </script> * <code> * <!-- @formatter:on --> * * */ 
+6
source share

All Articles