【问题标题】:@see marker, link other classes methods@see 标记,链接其他类方法
【发布时间】:2012-05-09 14:32:04
【问题描述】:

比如说我想用一个html标签来链接java.lang.Double的equals方法:

@see <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html#equals(java.lang.Object)">

没关系,但我不明白如何链接非标准类。
例如,我正在开发两个类,分别名为 AbstractVehicle 和 Vehicle。但是没有 AbstractVehicle 的 javadoc 文档,因为它的文档还需要生成。
那我如何链接它的方法或类引用?考虑一下:

@see mypackage.AbstractVehilce

这没有放置类 URL,我会在生成文档之前知道如何获取 URL 或它的引用。
我希望问题很清楚,否则请告诉我。

【问题讨论】:

    标签: java javadoc netbeans-7


    【解决方案1】:

    要为特定类创建link,您可以使用{@link mypackage.AbstractVehicle} 标签。同样,您可以使用{@link mypackage.AbstractVehicle#someMethod}AbstractVehicle 类中创建指向someMethod() 的链接。

    更多 javadoc 建议可以在 Oracle 的 javadoc - The Java API Documentation Generator 页面找到。

    【讨论】:

    • 如果JavaDoc添加到同一个包的不同类中,是否需要指定完整的包名?
    【解决方案2】:

    javadoc 的手册页解释了-link-linkoffline,它们控制如何为未传递给javadoc 的包生成链接。

       -link extdocURL
              Creates  links to existing javadoc-generated documentation
              of external referenced classes.  It takes one argument.
    
              extdocURL is the absolute or relative URL of the directory
              containing  the  external  javadoc-generated documentation
              you want to link to. Examples are shown below.  The  pack-
              age-list  file must be found in this directory (otherwise,
              use -linkoffline). The  Javadoc  tool  reads  the  package
              names  from  the package-list file and then links to those
              packages at that URL. When the Javadoc tool  is  run,  the
              extdocURL  value  is  copied  literally  into the <A HREF>
              links that are created. Therefore, extdocURL must  be  the
              URL to the directory, not to a file.
    
              You  can use an absolute link for extdocURL to enable your
              docs to link to a document on any website, or  can  use  a
              relative link to link only to a relative location. If rel-
              ative, the value you pass in should be the  relative  path
              from the destination directory (specified with -d ) to the
              directory containing the packages being linked to.
    
              When specifying an absolute link you normally use an http:
              link.   However, if you want to link to a file system that
              has no web server, you can use a file: link - however,  do
              this only if everyone wanting to access the generated doc-
              umentation shares the same file system.
    
              You can specify multiple -link options in a given  javadoc
              run to link to multiple documents.
    
              Choosing between -linkoffline and -link - One or the other
              option is appropriate when linking to an API document that
              is external to the current javadoc run.
    
              Use  -link: when using a relative path to the external API
              document, or when using an absolute URL  to  the  external
              API  document,  if  you  shell does not allow a program to
              open a connection to that URL for reading.
    
              Use -linkoffline : when  using  an  absolute  URL  to  the
              external API document, if your shell does not allow a pro-
              gram to open a connection to that URL for  reading.   This
              can  occur  if  you are behind a firewall and the document
              you want to link to is on the other side.
    
              ...
    

    -link 要求您在生成文档时连接到网络,以便它可以通过网络检索包列表,-linkoffline 不需要但要求您自己提供包列表:

       -linkoffline extdocURL  packagelistLoc
              This option is a varition of -link; they both create links
              to javadoc-generated documentation for external referenced
              classes.  Use the -linkoffline option when  linking  to  a
              document  on  the  web  when  the  Javadoc  tool itself is
              "offline" - that is, it cannot access the document through
              a web connection.
    
              ...
    

    【讨论】:

      【解决方案3】:

      @see 之后可以添加的内容在javadoc tool documentation 中进行了说明。您永远不应该放置任何外部类或方法文档的 URL。相反,您应该输入类/方法名称,并使用-link option 让 javadoc 为您找出合适的 URL。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-07
        • 1970-01-01
        相关资源
        最近更新 更多