简体   繁体   English

如何在编译时获取Javadoc类描述?

[英]How can I get the Javadoc class descriptions at compile time?

I'm trying to build up some documentation for my Wicket Web Application. 我正在尝试为我的Wicket Web应用程序构建一些文档。 I have created a page to grab all of my mounted pages and display them in /sitemap.xml. 我创建了一个页面来抓取所有已安装的页面并将它们显示在/sitemap.xml中。 In the vein of documentation I've added a new tag to the file <siteMap:Description> now I want to fill that description with the javadoc entry that describes the class file. 在文档方面,我已经向文件<siteMap:Description>添加了一个新标签,现在我想用描述类文件的javadoc条目来填充该描述。

I know there is know direct way to access them at runtime. 我知道有一种直接的方法可以在运行时访问它们。 So Instead I'm hoping to copy them at compile time into a List where they will then be accessible from runtime. 因此,我希望将它们在编译时复制到List中,然后可以从运行时对其进行访问。 How would I do that? 我该怎么做?

I'm using Maven for my build. 我正在使用Maven进行构建。

EDIT 编辑
I should probably Also mention that I do have an AntTask Already defined as part of my build process to save the compile Dates/times to a property file. 我可能还应该提到,在构建过程中,我确实已经定义了AntTask,以将编译日期/时间保存到属性文件中。
It seems to me an Task to scan my Class and then put the information into a file is probably the way to go. 在我看来,执行任务是扫描我的班级,然后将信息放入文件中。 Problem is I'm not sure how to proceed. 问题是我不确定如何继续。

My Ant-Task is defined like in my pom.xml so: 我的Ant任务的定义就像在pom.xml中一样,因此:

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <dependencies>
       <dependency>
         <groupId>ant</groupId>
         <artifactId>ant-nodeps</artifactId>
         <version>1.6.5</version>
       </dependency>
     </dependencies>
    <executions>
       <execution>
         <id>set-build-time</id>
         <phase>process-sources</phase>
         <configuration>
           <tasks>
             <tstamp>
               <format property="build.timestamp" pattern="yyyy/MM/dd HH:mm:ss"/>
               <format property="build.time" pattern="HH:mm:ss" />
               <format property="build.date" pattern="MM/dd/yyyy" />
               <format property="build.year" pattern="yyyy"/>
             </tstamp>
             <replaceregexp byline="true">
               <regexp pattern="copyYear\=.*" />
               <!--suppress MavenModelInspection -->
               <substitution expression="copyYear=${build.year}" />
               <fileset dir="src/main/java/" includes="**/*.properties" />
             </replaceregexp>
             <replaceregexp byline="true">
               <regexp pattern="buildTime\=.*" />
               <!--suppress MavenModelInspection -->
               <substitution expression="buildTime=${build.date} ${build.time}" />
               <fileset dir="src/main/java/" includes="**/*.properties" />
             </replaceregexp>
           </tasks>
         </configuration>
         <goals>
           <goal>run</goal>
         </goals>
       </execution>
     </executions>
   </plugin>

After doing more research I determined I was barking up the wrong tree. 经过更多的研究后,我确定我正在树错树皮。

I since I was trying to get Javadoc comments A Doclet was the better answer. 自从尝试获取Javadoc注释以来,我就选择了Doclet是更好的答案。 So I implemented a custom doclet and wired it up to run automatically as described in the follow up question and answer below. 因此,我实现了一个自定义doclet,并将其连接起来以自动运行,如下面的后续问题和解答所述。
How can I compile and run my Custom Doclet class in my project? 如何在项目中编译和运行我的Custom Doclet类?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用特定的Annotation获取所有方法的javadoc,方法名称和包/类名? - How can I get the javadoc of all methods with a specific Annotation, with the method name and package/class name? 如何让Ant Javadoc类排除两个文件? - How can I make an Ant Javadoc class exclude two files? Java:如何使用Javadoc创建外观漂亮的类文档? - Java: How can I create good looking class docs with Javadoc? 如何在javadoc代码块中显示泛型? - How can I get generics in javadoc code block displayed? 如何在运行时获取方法的JavaDoc? - How to get a JavaDoc of a method at run time? JavaDoc:减少同一类中重复方法描述的冗余 - JavaDoc: Reduce redundancy for Repeated Method Descriptions within the Same Class javadoc:显示父类的方法描述 - javadoc: show also descriptions of methods from parent class 我可以将类的名称作为编译时常量获取而不用字符串文字对其进行硬编码吗? - Can I get a class's name as a compile-time constant without hardcoding it in a string literal? 我可以从TypeVariable或VariableElement获取基础类上的方法列表在编译时的注释处理器中 - Can I get from a TypeVariable or VariableElement to a list of Methods on the underlying class In an annotation processor at compile time 如果我在编译时不知道该类,如何获取Enum的值? - How do I get the value of an Enum, if I don't know the class at compile time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM