summaryrefslogtreecommitdiff
path: root/src/scaladoc
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2015-04-02 17:15:57 +0200
committerAntoine Gourlay <antoine@gourlay.fr>2015-04-02 20:15:03 +0200
commit293f7c007e1cfdfe67a61a02f8d9eee0bc4fcc87 (patch)
treeba5e54e5abc218950c54a0801f624aa143cb0fd8 /src/scaladoc
parent83ea1250882108c82e0e47adbebca28f907de4f4 (diff)
downloadscala-293f7c007e1cfdfe67a61a02f8d9eee0bc4fcc87.tar.gz
scala-293f7c007e1cfdfe67a61a02f8d9eee0bc4fcc87.tar.bz2
scala-293f7c007e1cfdfe67a61a02f8d9eee0bc4fcc87.zip
SI-5795 empty scaladoc tags should be omitted from output
Empty scaladoc tags, like `@param`, `@return`, `@version`, etc. should be omitted from the output when they have no meaning by themselves. They are still parsed, for validation (warning that a tag doesn't exist and so on), but are removed, if empty, when building the Comment. The only ones that stay even when empty are `@deprecated`, so that the class name can be striked-through ("Deprecated" also appears in the header, even if there is no message with it), and `@throws`.
Diffstat (limited to 'src/scaladoc')
-rwxr-xr-xsrc/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
index 42ca98dc7a..fb4ed34571 100755
--- a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
@@ -318,18 +318,18 @@ trait CommentFactoryBase { this: MemberLookupBase =>
val bodyTags: mutable.Map[TagKey, List[Body]] =
mutable.Map(tagsWithoutDiagram mapValues {tag => tag map (parseWikiAtSymbol(_, pos, site))} toSeq: _*)
- def oneTag(key: SimpleTagKey): Option[Body] =
+ def oneTag(key: SimpleTagKey, filterEmpty: Boolean = true): Option[Body] =
((bodyTags remove key): @unchecked) match {
- case Some(r :: rs) =>
+ case Some(r :: rs) if !(filterEmpty && r.blocks.isEmpty) =>
if (!rs.isEmpty) reporter.warning(pos, "Only one '@" + key.name + "' tag is allowed")
Some(r)
- case None => None
+ case _ => None
}
def allTags(key: SimpleTagKey): List[Body] =
- (bodyTags remove key) getOrElse Nil
+ (bodyTags remove key).getOrElse(Nil).filterNot(_.blocks.isEmpty)
- def allSymsOneTag(key: TagKey): Map[String, Body] = {
+ def allSymsOneTag(key: TagKey, filterEmpty: Boolean = true): Map[String, Body] = {
val keys: Seq[SymbolTagKey] =
bodyTags.keys.toSeq flatMap {
case stk: SymbolTagKey if (stk.name == key.name) => Some(stk)
@@ -345,11 +345,11 @@ trait CommentFactoryBase { this: MemberLookupBase =>
reporter.warning(pos, "Only one '@" + key.name + "' tag for symbol " + key.symbol + " is allowed")
(key.symbol, bs.head)
}
- Map.empty[String, Body] ++ pairs
+ Map.empty[String, Body] ++ (if (filterEmpty) pairs.filterNot(_._2.blocks.isEmpty) else pairs)
}
def linkedExceptions: Map[String, Body] = {
- val m = allSymsOneTag(SimpleTagKey("throws"))
+ val m = allSymsOneTag(SimpleTagKey("throws"), filterEmpty = false)
m.map { case (name,body) =>
val link = memberLookup(pos, name, site)
@@ -375,7 +375,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
version0 = oneTag(SimpleTagKey("version")),
since0 = oneTag(SimpleTagKey("since")),
todo0 = allTags(SimpleTagKey("todo")),
- deprecated0 = oneTag(SimpleTagKey("deprecated")),
+ deprecated0 = oneTag(SimpleTagKey("deprecated"), filterEmpty = false),
note0 = allTags(SimpleTagKey("note")),
example0 = allTags(SimpleTagKey("example")),
constructor0 = oneTag(SimpleTagKey("constructor")),