作为猜测,我会从“$$”开始。然后我会尝试反斜杠来逃避它,这就是答案。
标准库中充满了这些宏。(例如,在immutable.MapLike
,
* @define Coll immutable.Map
对于用法$Coll
,对于继承的文档。)
你会认为StringInterpolator
会展示如何包含一美元。
[scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:17: warning: Variable name undefined in comment for class StringContext in class StringContext
[scaladoc] * println(s"Hello, $name") // Hello, James
[scaladoc] ^
[scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:23: warning: Variable name undefined in comment for class StringContext in class StringContext
[scaladoc] * s"Hello, $name"
[scaladoc] ^
[scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:41: warning: Variable a undefined in comment for class StringContext in class StringContext
[scaladoc] * val x: JSONObject = json"{ a: $a }"
[scaladoc] ^
这是来自pull requests 的示例健全性构建。
所有这些错误都来自类文档,而不是成员文档,所以这可能是一个提示;或者也许它只是在那一点上停止抱怨。
该工具在其输出中发出了精彩的入门,但不是您的问题:
[scaladoc] Quick crash course on using Scaladoc links
[scaladoc] ==========================================
[scaladoc] Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:
[scaladoc] - [[scala.collection.immutable.List!.apply class List's apply method]] and
[scaladoc] - [[scala.collection.immutable.List$.apply object List's apply method]]
[scaladoc] Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:
[scaladoc] - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]
[scaladoc] - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]
[scaladoc] Notes:
[scaladoc] - you can use any number of matching square brackets to avoid interference with the signature
[scaladoc] - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)
[scaladoc] - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.
更新 1:猜猜看,这个猜测似乎有效。它不再$ROOT
在此输出中抱怨:
docs.partest:
[scaladoc] Documenting 33 source files to /home/apm/projects/snytt/build/scaladoc/partest
[scaladoc] model contains 110 documentable templates
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:14: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 1. Create subdirectory in test/files/jvm for your test. Let's name it $TESTDIR.
[scaladoc] ^
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:15: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 2. Create $TESTDIR/BytecodeSrc_1.scala that contains Scala source file that you
[scaladoc] ^
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:18: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 3. Create $TESTDIR/Test.scala:
[scaladoc] ^
[scaladoc] Document succeeded with 3 warnings; see the documenter output for details.
[scaladoc] three warnings found
[stopwatch] [docs.partest.timer: 19.486 sec]
现在我会去$TESTDIR
。
哇,这真的很给力。感谢您的提问!
首先让我去检查一下 scaladoc 是否真的$ROOT
在它的 html 输出中包含了这个词。
更新2:你知道吗?只是没关系。结果是这样的,哈:
A string that looks like a file path is normalized by replacing the leading segments (the root) with "$$ROOT"
更新 3:实际上,\$
反斜杠转义工作正常。实际屏幕实时输出:
with "$ROOT"