Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to properly structure method JavaDoc comment format using Doclet API

 
Michael K. Wilson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrote a custom doclet using the Doclet API.

The purpose for the doclet is to load Java source files and create stubs (which are identical Java source files but do not contain any method implementation details).

Need the JavaDoc comments (located inside the newly created stub source file) to be properly formatted / match the format with the original source file using this doclet that I created...

Here's my doclet:



For example, lets say I run it against this target source file:



The newly created Java source file's JavaDoc looks like this:



Notice how with the exception of the first line, the second line and subsequent lines are pushed to the left side of the screen and don't containing leading asterisks before them...

This is definitely some type of weird formatting issue...

What am I possibly doing wrong?

Is there any easier way to correctly format the JavaDoc comments to match the target source file which is loaded by MyDoclet?

Should I be using the com.sun.javadoc.SourcePosition.line() or com.sun.javadoc.SourcePosition.column() methods?

Happy programming,

Mike
 
Taariq San
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put a breakpoint at method.commentText() and inspect that value, I suspect it contains the entire comment, and you then print it all on one line....



You're not looping through a list of lines in the file, what you might consider doing is splitting that text with String's split method, pass it the new line character and print the TAB plus an asterisk for each line and then close the comment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic