我似乎找到了一条奇怪的错误信息。我正在存储密码,我的评论是
/** A password hash is stored as `"algorithm$iterations$salt$hash"`
* with the number of iterations optional for some algorithms
当我尝试为我的项目创建一个分发jar时,我收到了这个警告:
Variable iterations undefined in comment for...
我将警告跟踪到特征package scala.tools.nsc.ast.DocComments
,在那里我发现显然可以在ScalaDoc中放置某种变量。不幸的是,谷歌搜索“Scaladoc中的变量”或“ScalaDoc美元符号”没有任何用处。
有谁知道我使用的功能不正确以及如何包含美元符号 在ScalaDoc评论中没有收到警告?
答案 0 :(得分:5)
我从“$$”开始,作为猜测。然后我会尝试使用反斜杠来逃避它,这就是答案。
标准的lib充满了这些宏。 (例如,在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] ^
那来自sample sanity build for pull requests。
所有这些错误都来自类doc,而不是成员doc,所以这可能是一个提示;或者它可能只是在那时停止抱怨。
该工具在其输出中发出了精彩的底漆,但不是您的问题:
[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是否在其html输出中实际包含$ROOT
字。
更新2:你知道吗?只是没关系。这是结果,哈:
A string that looks like a file path is normalized by replacing the leading segments (the root) with "$$ROOT"
更新3:实际上,\$
反斜杠转义工作正常。实际的屏幕实时输出:
with "$ROOT"