简体   繁体   中英

How to include Javadoc and source code with dependency

I currently use the JSoup dependency into Visual Studio Code, but I don't have the Javadoc or the source code of Jsoup in my Visual Studio Code:

The dependency

    <dependency>
      <!-- jsoup HTML parser library @ https://jsoup.org/ -->
      <groupId>org.jsoup</groupId>
      <artifactId>jsoup</artifactId>
      <version>1.13.1</version>
    </dependency>

The result

JavaDoc

在此处输入图像描述

The javadoc is not shown

Source

在此处输入图像描述

The source is not shown

Question

Do you have any idea to solve this problem?

The JavaDoc and Sources of JSoup dependency are available here: https://repo1.maven.org/maven2/org/jsoup/jsoup/1.13.1/

JSoup included the Javadoc in their code: https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/nodes/Document.java

Do this:

<dependency>
  <!-- jsoup HTML parser library @ https://jsoup.org/ -->
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.13.1</version>
</dependency>
<dependency>
  <!-- jsoup HTML parser library @ https://jsoup.org/ -->
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.13.1</version>
  <classifier>sources</classifier>
</dependency>
<dependency>
  <!-- jsoup HTML parser library @ https://jsoup.org/ -->
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.13.1</version>
  <classifier>javadoc</classifier>
</dependency>

In VS Code v1.68.1 my javadocs for some reason stopped showing up and navigating to definition showed the disassembled sources instead of the packaged sources. Enabling the settings depicted below restored the javadocs and sources I was expecting.

Setting IDs

java.eclipse.downloadSources
java.maven.downloadSources

在此处输入图像描述

There's no way to achieve your goals because the jar or dependency itself doesn't have the docstring.

For example, when you click into println , the comment part is also the content when you hover over the println :

在此处输入图像描述

But there's no such comment in jsoup, so java extension won't be able to catch the docstring and show it.

[UPDATE]

jsoup/src/main/java/org/jsoup/nodes/Document.class: 在此处输入图像描述

The files included in jar are all compiled to.class file, there's no comments before functions, so Java language server can't catch it to show as the feature intellisense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM