java java文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6524816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:12:04  来源:igfitidea点击:

java documentation

javadocumentationjavadoc

提问by pardeep

i am not able to create documentation for this code,i think my coomad of javadoc is not right, i read about it but don't understand ,can anybody correct by javadoc cammand

我无法为此代码创建文档,我认为我的 javadoc coomad 不正确,我阅读了它但不明白,任何人都可以通过 javadoc cammand 进行纠正

class abc
{/** documentaion line 1
*
* */
public static void main(String a[])
{/** documentaion line 2
*
* */
System.out.println("documentation");
}
}
Error:
C:\Program Files\Java\jdk1.6.0\bin>javac abc.java

C:\Program Files\Java\jdk1.6.0\bin>java abc
documentation

C:\Program Files\Java\jdk1.6.0\bin>javadoc abc
Loading source files for package abc...
javadoc: warning - No source files for package abc
Constructing Javadoc information...
javadoc: warning - No source files for package abc
javadoc: error - No public or protected classes found to document.
1 error
2 warnings

回答by Pa?lo Ebermann

In your case, you would want to provide the file name instead of a package name.

在您的情况下,您需要提供文件名而不是包名。

javadoc abc.java

Then the no source fileserror message will disappear. The no public classeserror message will still be there - add publicbefore your class declaration. Alternatively, you can pass the -packageor -privateflag to Javadoc to include non-public classes too.

然后无源文件错误消息将消失。在没有公共课的错误消息依然存在-添加public类声明之前。或者,您可以将-package-private标志传递给 Javadoc 以包含非公共类。

Then move the documentation comments directly before the declarations you want to comment:

然后将文档注释直接移动到要注释的声明之前:

/**
 * class documentation here
 */
public class abc
{

    /** 
     * method documentation here 
     */
    public static void main(String a[])
    {
      /**
       * this will be ignored.
       */
       System.out.println("documentation");
    }

}

回答by Steve's a D

This is old, I know, but I found a solution that worked for me. It isn't package based but it took me forever to figure it out so I figured I'd share it:

这是旧的,我知道,但我找到了一个对我有用的解决方案。它不是基于包的,但我花了很长时间才弄明白,所以我想我会分享它:

javadoc -private *.java

The private option is the key here.

私有选项是这里的关键。

回答by SLaks

As the error message clearly says, Javadoc creates documentation for publicor protectedclasses and methods (members that are visible from outside your package).

随着错误消息明确表示,创建的Javadoc文档供publicprotected类和方法(成员是从你的包外可见)。

You don't have any.

你没有。

Also, Javadoc takes a package(folder or JAR file), not a classname.

此外,Javadoc 采用(文件夹或 JAR 文件),而不是类名。