链接到 scaladoc 的来源? [英] Linking to sources from scaladoc?
问题描述
我需要从我的 scaladoc 链接到 github 上的源代码.我使用 sbt 的 doc
任务构建这些文档.
I need to link to sources on github from my scaladoc. I build those docs with the sbt's doc
task.
有两个问题 - 首先,我不喜欢为我的 .scala
文件创建几个嵌套的空目录,所以我通常将它们全部打包成一个 - 比如 src/main/scala/org.rogach.scallop
而不是 src/main/scala/org/rogach/scallop
.有没有办法在不拆分该目录的情况下使文档链接正常工作?
There are two problems - first, I do not like creating several nested empty directories for my .scala
files, so I usually pack them all in one - like src/main/scala/org.rogach.scallop
instead of src/main/scala/org/rogach/scallop
. Is there a way to make links to docs work without splitting that directory?
其次,当我在 build.sbt 中加入这一行时:
Second, when I put this line in my build.sbt:
scalacOptions in (Compile, doc) ++=
Opts.doc.sourceUrl("https://raw.github.com/Rogach/scallop/master/src/main/scala/")
文档包含指向源的链接,但所有这些链接都指向源根 url,而不是文件本身.我做错了什么?
docs contain links to sources, but all those links just point to the source root url, not files themselves. What am I doing wrong?
推荐答案
来自 scaladoc help
的输出:
-doc-source-url <url> A URL pattern used to build links to template
sources; use variables, for example:
€{TPL_NAME} ('Seq'),
€{TPL_OWNER} ('scala.collection'),
€{FILE_PATH} ('scala/collection/Seq')
(是的,那是欧元符号.)
(Yes that is the euro symbol.)
如果您的所有源都在一个包中定义,则类似以下内容应用作 sourceUrl 的参数:
Something like the following should work as an argument to sourceUrl if all of your sources are defined in a package:
https://raw.github.com/Rogach/scallop/master/src/main/scala/€{TPL_OWNER}.€{TPL_NAME}.scala
这篇关于链接到 scaladoc 的来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!