Doclet lớp:
public class ExtractCommentsDoclet {
public static boolean start(RootDoc root) throws IOException {
for (ClassDoc c : root.classes()) {
print(c.qualifiedName(), c.commentText());
for (FieldDoc f : c.fields(false)) {
print(f.qualifiedName(), f.commentText());
}
for (MethodDoc m : c.methods(false)) {
print(m.qualifiedName(), m.commentText());
if (m.commentText() != null && m.commentText().length() > 0) {
for (ParamTag p : m.paramTags())
print(m.qualifiedName() + "@" + p.parameterName(), p.parameterComment());
for (Tag t : m.tags("return")) {
if (t.text() != null && t.text().length() > 0)
print(m.qualifiedName() + "@return", t.text());
}
}
}
}
return true;
}
private static void print(String name, String comment) throws IOException {
if (comment != null && comment.length() > 0) {
new FileWriter(name + ".txt").append(comment).close();
}
}
}
Và thực maven:
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
<configuration>
<doclet>ExtractCommentsDoclet</doclet>
<docletPath>${project.build.directory}/classes</docletPath>
<reportOutputDirectory>${project.build.outputDirectory}/META-INF</reportOutputDirectory>
<useStandardDocletOptions>false</useStandardDocletOptions>
</configuration>
</plugin>
đọc tài liệu từ classpath: META-INF/apidocs
Nguồn
2012-10-13 10:06:49
Kể từ khi 2 câu trả lời ở đây cho biết họ không thể được thực hiện với sự biên dịch mã, bạn sẽ có thể làm với mã nguồn. Và để làm điều đó, hãy thử tìm kiếm "trích xuất javadoc từ nguồn" và sau đó lấy một số công cụ nguồn mở và sửa đổi nó theo nhu cầu của bạn. –
Tôi nghĩ rằng việc đi với @Puce dễ dàng hơn nhiều vì tôi là chủ sở hữu của mã nguồn! –
Câu hỏi thực tế là: bạn cần những JavaDocs đó để làm gì? Trường hợp sử dụng là gì? – Thomas