在带有 data.properties 文件的 javadoc 中使用 @value
Using @value in javadoc with a data.properties file
我正在使用 Javadoc 来制作文档。目前我有一些看起来像这样的东西
/**
* Test Doco
*
*/
public class testClass() {
public void testMethod() {
/** More test doco
*/
customFunction()
}
}
我还有一个非常简单的 data.properties 文件:
basic.entry=test
second.entry=test2
third.entry=test3
我想知道是否有办法 link 我的 Javadoc 从 data.properties 文件中提取一个值?
我试过:
/**
* {@value /properties/data.properties#basic.entry)
*/
JavaDoc 规范和 IntelliJ IDEA 都不支持来自外部文件的值。
您始终可以编写自己的 JavaDoc 预处理器来扫描您的代码以查找特殊标记,并从它们引用的任何文件或您需要的任何其他内容中插入值,作为有效的 JavaDoc 注释,然后 运行 针对您的代码的 JavaDoc 工具。
示例:
/**
* The values from the file are:
*/
//[filetocsv /properties/data.properties#basic.entry]
您的预处理器可以读取该文件,生成您想要的值,并用上面的 JavaDoc 的第一行(或其他任何内容)替换所有内容,如下所示:
/**
* The values from the file are:
* basic.entry=test,
* second.entry=test2,
* third.entry=test3
*/
//[filetocsv /properties/data.properties#basic.entry]
现在 JavaDoc 可以扫描您的代码并生成 HTML 文档。
很简单。不需要做太多工作。
我正在使用 Javadoc 来制作文档。目前我有一些看起来像这样的东西
/**
* Test Doco
*
*/
public class testClass() {
public void testMethod() {
/** More test doco
*/
customFunction()
}
}
我还有一个非常简单的 data.properties 文件:
basic.entry=test
second.entry=test2
third.entry=test3
我想知道是否有办法 link 我的 Javadoc 从 data.properties 文件中提取一个值?
我试过:
/**
* {@value /properties/data.properties#basic.entry)
*/
JavaDoc 规范和 IntelliJ IDEA 都不支持来自外部文件的值。
您始终可以编写自己的 JavaDoc 预处理器来扫描您的代码以查找特殊标记,并从它们引用的任何文件或您需要的任何其他内容中插入值,作为有效的 JavaDoc 注释,然后 运行 针对您的代码的 JavaDoc 工具。 示例:
/**
* The values from the file are:
*/
//[filetocsv /properties/data.properties#basic.entry]
您的预处理器可以读取该文件,生成您想要的值,并用上面的 JavaDoc 的第一行(或其他任何内容)替换所有内容,如下所示:
/**
* The values from the file are:
* basic.entry=test,
* second.entry=test2,
* third.entry=test3
*/
//[filetocsv /properties/data.properties#basic.entry]
现在 JavaDoc 可以扫描您的代码并生成 HTML 文档。 很简单。不需要做太多工作。