Avoiding duplication in JavaDoc comments
I am writing a class where the same xml is used between some methods.
e.g.
/**
* Sample Response:
* <xmp>
* &l开发者_C百科t;myXML>
* <stuff> data </stuff>
* </myXML>
* </xmp>
*/
CommonXML Method1();
/**
* Sample Submission:
* <xmp>
* <myXML>
* <stuff> data </stuff>
* </myXML>
* </xmp>
*/
void Method2(CommonXML xml);
I would like to write my documentation so that if the xml changes I have one resource to modify, rather than updating all of the JavaDoc for the affected methods.
Does anyone know how to accomplish this?
Why not have your documentation read:
/**
* Returns an XML file conforming to the CommonXML schema, available here
* (link-to-schema).
**/
Then, if you update your XML, you just update your schema?
What about using @see
to refer to the other method?
I would document (under duress - actually i think documentation is a waste of time, as its almost always wrong - use tests to document what your system does) the CommonXML object, rather than each method that takes an object of this type.
You shouldn't be using Javadoc to repeat specifications that are defined elsewhere. Refer to the specification.
You could use Doclava's include or sample tag to do this. These tags copy sample text from an arbitrary file into the output javadoc html. The @include
tag copies the text verbatim from the given file. The @sample
tag copies the text from the given file with some modifications.
精彩评论