【问题标题】:Best way to access documentation inside my code在我的代码中访问文档的最佳方式
【发布时间】:2016-06-08 22:43:52
【问题描述】:

我正在尝试添加一个功能,用户可以在其中查找命令文档 - 它是一个基于命令行的程序,其中包含他们可以输入的各种命令。

我认为最简单的做法是将文档存储在外部文件中,但我不确定我的最佳选择是什么。文本文件似乎有点草率,csv 更像是我的想法,但在文档中处理逗号也不理想。字典(如 json)会很棒,但我不确定如何用 Java 阅读它。我不能使用第三部分库。

【问题讨论】:

  • 您想要一个简单的Readme 文件,用户可以将其加载到他们喜欢的文本编辑器中并阅读,还是您的程序将提供某种机制(如手册页)?
  • 程序全部在命令行中。它基本上是“人”功能。

标签: java file csv text


【解决方案1】:

我认为您需要编写 javadocs cmets 然后将其导出(如果需要)。 用户还可以在使用您的库时访问命令文档。

Tutorial

例子:

/**
 * Returns an Image object that can then be painted on the screen. 
 * The url argument must specify an absolute {@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 * @param  url  an absolute URL giving the base location of the image
 * @param  name the location of the image, relative to the url argument
 * @return      the image at the specified URL
 * @see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }

Export javadocs to html

【讨论】:

    猜你喜欢
    • 2021-06-07
    • 1970-01-01
    • 2011-09-26
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 2021-05-14
    • 1970-01-01
    相关资源
    最近更新 更多