any way to let javadoc read comments from outside the source codes?
By Weijun on Mar 11, 2005
i am doing experiments on javadoc comments translation now. it's easy to extract the comments into some plain files, and, after some heavy labours of translations, how to put them back into the doc system?
in order to generate the doc tree, we need to run the javadoc tool. and currently javadoc reads comment lines from the source codes using the javac parser / scanner things. it seems silly to put the translation back into the source codes again, since they are internationalized strings, and there seems to be no standard on the encoding of java souce codes. so there must be a way to instruct javadoc to read comments directly from the plain text files.
is it easy?
seems there maybe 2 points we can hook in. first, the place the scanner reads the comment. second, the doclet uses the comment. i prefer the second one, which may means changing the constructors of various DocImpl classes or how the constructors are called. in either way, the document string from the source codes will be ignored and directly read from text files themselves. it won't be difficult to change the codes, but there should be a way to make this smarter, like a standard way of adding hooks. the comments may come from plain text files, or they may come from a database, or, even more funny, comes from the current System.in or other mysterious network sockets.
it seems a system level registered object can do this. looks like a glocal cookie handler.
more experiments will reveal more maybe.