简体   繁体   English

如何包含依赖关系的 Javadoc 和源代码

[英]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:我目前在 Visual Studio Code 中使用 JSoup 依赖项,但我的 Visual Studio Code 中没有 Javadoc 或 Jsoup 的源代码:

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 JavaDoc

在此处输入图像描述

The javadoc is not shown未显示 javadoc

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 依赖项的JavaDocSources可在此处获得: 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 JSoup 在他们的代码中包含了 Javadoc: 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.在 VS Code v1.68.1 中,我的javadocs出于某种原因停止显示并导航到定义显示反汇编的源代码而不是打包的源代码。 Enabling the settings depicted below restored the javadocs and sources I was expecting.启用下面描述的设置恢复了我期望的javadocssources

Setting IDs设置 ID

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.没有办法实现您的目标,因为 jar 或依赖项本身没有文档字符串。

For example, when you click into println , the comment part is also the content when you hover over the println :例如,当您点击进入println时,评论部分也是您在println上 hover 时的内容:

在此处输入图像描述

But there's no such comment in jsoup, so java extension won't be able to catch the docstring and show it.但是 jsoup 中没有这样的注释,所以 java 扩展将无法捕获文档字符串并显示它。

[UPDATE] [更新]

jsoup/src/main/java/org/jsoup/nodes/Document.class: 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. jar中包含的文件全部编译为.class文件,函数前没有注释,所以Java语言服务器无法捕捉到它显示为tellis中的特征。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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