Inherit javadoc without generating documents for inherited source

I would like class B inherit Javadoc from the interface it implements, interface A I have included the source for interface A in my Javadoc command, and class B inherits the documentation correctly.

Now I'm wondering if I can make the links that it generates, point to the interface A documentation on the Internet, and not duplicate it on my site, that is, the "Indicated:" links will link to an external page.

Is it possible?

+4
source share
2 answers

Probably yes. To be able to include legacy documentation, interface A source must be found in the javadoc source path, but not in the list of packages passed to javadoc to create the documentation. To link, use the -link . I just tried this (with ant javadoc task):

 <javadoc destdir="docs"> <sourcepath> <!-- source of your class B --> <pathelement location="src" /> <!-- source of external interface A --> <pathelement location="../example-src/src" /> </sourcepath> <!-- your packages, to generate the docs for --> <package name="com.personal.myproject.*" /> <!-- the location of the online documentation --> <link href="http://example.com/javadoc/"/> </javadoc> 

On the javadoc command line, I think it translates as follows (unix syntax, one line):

  javadoc -sourcepath ../example-src/src:src -d docs -link http://example.com/javadoc/ -subpackages com.personal.myproject (other options...) 

Where

  • class B is in the package com.personal.myproject ,
  • interface A is in the com.example package,
  • my own sources are in src ,
  • The sources for interface A are in ../example-src/src .

In the example created for this, javadoc copied the documentation from A.methodName() to B.methodName() , but the link to the online documentation at http://example.com/javadoc/com/example/A.html#methodName()

Thanks for asking this question, I always wanted to do this :-)

+3
source

The huge loan Paberlo Ebermann is responsible for pointing me in the right direction for my setting. Read this answer first as it makes sense while I just provide an additional way to customize the solution.


So I thought that I would share what I worked with for those who manage their project using maven and using the maven-javadoc-plugin as part of the build process to generate their documents.

As part of the plugin configuration, you can specify a group of links to include. Here is a bit that specifically covers link customization.

And here is a sample linking external documentation for selenium and java se for packaging in a jar for deployment with my project. The beauty is that these javadocs in my project just bind to external ones without visibility.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <links> <link>http://seleniumhq.imtqy.com/selenium/docs/api/java/</link> <link>https://docs.oracle.com/javase/${project.java.version}/docs/api/</link> </links> </configuration> </plugin> 

<h / "> By the way, if you find anything useful on this page, consult it somewhere. Searching this page on google was too complicated, and it is really nice.

0
source

Source: https://habr.com/ru/post/888857/


All Articles