Redian新闻
>
Extracting JavaDoc comment?
avatar
Extracting JavaDoc comment?# Java - 爪哇娇娃
c*t
1
I am writing a program which needs to extract JavaDoc comments from
given source files. The thing is, I need to do it dynamically, like
showing the comment as a tooltip etc.
I know Eclipse/IntelliJ IDEA have the feature, I am wondering how
they did it, since I need to do the same for my program. I certainly
do not wish to write my own Java parser.
Any pointers? Thanks.
avatar
c*z
2
Not sure how that is done in IDE, but all these IDEs
keep parsing your file while you are editing to build the AST, I bet
that is when they get the doc too.

【在 c*****t 的大作中提到】
: I am writing a program which needs to extract JavaDoc comments from
: given source files. The thing is, I need to do it dynamically, like
: showing the comment as a tooltip etc.
: I know Eclipse/IntelliJ IDEA have the feature, I am wondering how
: they did it, since I need to do the same for my program. I certainly
: do not wish to write my own Java parser.
: Any pointers? Thanks.

avatar
m*t
3
I have never actually done this, but I imagine you can probably call the
javadoc API at run-time and plugin your own doclet to capture the tag
information.

【在 c*****t 的大作中提到】
: I am writing a program which needs to extract JavaDoc comments from
: given source files. The thing is, I need to do it dynamically, like
: showing the comment as a tooltip etc.
: I know Eclipse/IntelliJ IDEA have the feature, I am wondering how
: they did it, since I need to do the same for my program. I certainly
: do not wish to write my own Java parser.
: Any pointers? Thanks.

avatar
c*t
4
The thing is, from my understanding of JavaDoc API, essentially I have
to do it in two step process:
1. write a Doclet that extract the information from the Java code and
output information to a disk file.
2. execute JavaDoc with the Doclet. Then load the information from the
disk file.
I am wondering if I could execute JavaDoc within the same JVM, possibly
multiple times so that I could directly manipulate RootDoc structure
rather than pass data through a disk file.

【在 m******t 的大作中提到】
: I have never actually done this, but I imagine you can probably call the
: javadoc API at run-time and plugin your own doclet to capture the tag
: information.

avatar
g*g
5
I don't know much about JavaDoc API, but I believe it will allow
you to output to some OutputStream rather than files.

【在 c*****t 的大作中提到】
: The thing is, from my understanding of JavaDoc API, essentially I have
: to do it in two step process:
: 1. write a Doclet that extract the information from the Java code and
: output information to a disk file.
: 2. execute JavaDoc with the Doclet. Then load the information from the
: disk file.
: I am wondering if I could execute JavaDoc within the same JVM, possibly
: multiple times so that I could directly manipulate RootDoc structure
: rather than pass data through a disk file.

avatar
c*t
6
I need to know if it is possible to execute javadoc within the
same JVM multiple times, and how to launch it within JVM without
calling Runtime.exec...

【在 g*****g 的大作中提到】
: I don't know much about JavaDoc API, but I believe it will allow
: you to output to some OutputStream rather than files.

avatar
m*t
7
But what you do in your own doclet with the RootDoc tree is entirely up to
you. You don't have to write it to anywhere. You should be able to just hang
on to the data structure and expose it for other parts of your program to
query.

【在 c*****t 的大作中提到】
: The thing is, from my understanding of JavaDoc API, essentially I have
: to do it in two step process:
: 1. write a Doclet that extract the information from the Java code and
: output information to a disk file.
: 2. execute JavaDoc with the Doclet. Then load the information from the
: disk file.
: I am wondering if I could execute JavaDoc within the same JVM, possibly
: multiple times so that I could directly manipulate RootDoc structure
: rather than pass data through a disk file.

avatar
c*t
8
nvm, I got it solved. The question was basically related to
Running the Standard Doclet Programmatically
http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/standard-doclet.html#runningprogrammatically
which solved my problems. I can now get all the information within
the same JVM. Call JavaDoc multiple times as well... and suppress
warnings/errors.
What's so cool is that now I can write my own doclet for custom XML
parsers created using CookXml. The doclet generates a JavaDoc like
web page

【在 m******t 的大作中提到】
: But what you do in your own doclet with the RootDoc tree is entirely up to
: you. You don't have to write it to anywhere. You should be able to just hang
: on to the data structure and expose it for other parts of your program to
: query.

avatar
q*g
9
cool
thanks for sharing

【在 c*****t 的大作中提到】
: nvm, I got it solved. The question was basically related to
: Running the Standard Doclet Programmatically
: http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/standard-doclet.html#runningprogrammatically
: which solved my problems. I can now get all the information within
: the same JVM. Call JavaDoc multiple times as well... and suppress
: warnings/errors.
: What's so cool is that now I can write my own doclet for custom XML
: parsers created using CookXml. The doclet generates a JavaDoc like
: web page

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。