如果我正在使用从其他互联网获取的一段代码或资源,我喜欢在类或函数文档中指出这一点,并提供指向原始源的链接。但是,在编写代码以提高可读性时,我还想坚持每行最多 80 个字符的原则。有没有办法将源中的长 URL 解析为多行,并且在 Eclipse 等 IDE 中使用 javadoc 时仍保持原始地址可用?可用的意思是单击 javadoc 工具提示中的 URL 会打开正确的页面。
例如,您将如何格式化以下内容:
/**
* Class to do some cool stuff
* Original source:
* http://stackoverflow.com/questions/and-huge-amouts-of-URL-address-which-does-not-fit-to-80-chars
*/
public class ExampleClass {
}
最佳答案
如果您不想使用 URL 缩短器,您可以用 <pre></pre>
将您的 url 括起来。标签如下:
/**
* Class to do some cool stuff
* Original source:
* <pre>
* See <a href="http://stackoverflow.com/questions/
and-huge-amouts-of-URL-address-which-does-not-fit-to-80-chars">NameOfyourLink</a>
* </pre>
*/
这将满足例如 checkstyle 并让您保留原始 URL。
https://stackoverflow.com/questions/41056517/