@@ -178,29 +187,29 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
}
}
{ mbr match {
- case dtpl: DocTemplateEntity if isSelf =>
- val subClss = dtpl.subClasses
- if (subClss.isEmpty) NodeSeq.Empty else
-
- known subclasses: { templatesToHtml(dtpl.subClasses, xml.Text(", ")) }
-
+ case dtpl: DocTemplateEntity if (isSelf && !dtpl.subClasses.isEmpty) =>
+
+ known subclasses: { templatesToHtml(dtpl.subClasses, xml.Text(", ")) }
+
case _ => NodeSeq.Empty
}
}
+ { mbr match {
+ case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined) =>
+ val sourceUrl = tpl.sourceUrl.get
+
+ case _ => NodeSeq.Empty
+ }
+ }
+ { if(mbr.deprecation.isEmpty) NodeSeq.Empty else
+
deprecated:
+ { - { bodyToHtml(mbr.deprecation.get) }
}
+
+ }
{ for(comment <- mbr.comment.toList) yield {
- { if(!comment.deprecated.isEmpty)
- deprecated:
- { for(body <- comment.deprecated.toList) yield - {bodyToHtml(body)}
}
-
- else NodeSeq.Empty
- }
- { if(mbr.isDeprecated)
- deprecated:
- { for(str <- mbr.deprecationMessage.toList) yield - {str}
}
-
- else NodeSeq.Empty
- }
{ if(!comment.version.isEmpty)
version
{ for(body <- comment.version.toList) yield - {bodyToHtml(body)}
}
@@ -231,15 +240,6 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
}
}}
- { tpl.companion match {
- case Some(companion) if isSelf =>
-
- case _ =>
- NodeSeq.Empty
- }
- }
def kindToString(mbr: MemberEntity): String = mbr match {
@@ -260,12 +260,11 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
/** name, tparams, params, result */
def signature(mbr: MemberEntity, isSelf: Boolean): NodeSeq = {
- val isDeprecated = mbr.isDeprecated || (!mbr.comment.isEmpty && !mbr.comment.get.deprecated.isEmpty)
def inside(hasLinks: Boolean): NodeSeq =
{ kindToString(mbr) }
- { if (mbr.isConstructor) tpl.name else mbr.name }{
+ { if (mbr.isConstructor) tpl.name else mbr.name }{
def tparamsToHtml(tpss: List[TypeParam]): NodeSeq =
if (tpss.isEmpty) NodeSeq.Empty else {
def tparam0(tp: TypeParam): NodeSeq =
diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
index 53ac6740c..7be902cd5 100644
--- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
@@ -43,9 +43,8 @@ trait MemberEntity extends Entity {
def definitionName: String
def visibility: Option[Paragraph]
def flags: List[Paragraph]
+ def deprecation: Option[Body]
def inheritedFrom: List[TemplateEntity]
- def isDeprecated: Boolean
- def deprecationMessage: Option[String]
def resultType: TypeEntity
def isDef: Boolean
def isVal: Boolean
@@ -61,6 +60,7 @@ trait MemberEntity extends Entity {
trait DocTemplateEntity extends TemplateEntity with MemberEntity {
def toRoot: List[DocTemplateEntity]
def inSource: Option[(io.AbstractFile, Int)]
+ def sourceUrl: Option[java.net.URL]
def typeParams: List[TypeParam]
def parentType: Option[TypeEntity]
def linearization: List[TemplateEntity]
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 90632259b..4fb65d776 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -18,14 +18,14 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
private var droppedPackages = 0
def templatesCount = templatesCache.size - droppedPackages
-
+
/** */
def makeModel: Package =
makePackage(RootPackage, null) getOrElse { throw new Error("no documentable class found in compilation units") }
object commentator {
- private val factory = new CommentFactory(reporter)
+ val factory = new CommentFactory(reporter)
private val commentCache = mutable.HashMap.empty[(Symbol, TemplateImpl), Comment]
@@ -94,8 +94,6 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
def inDefinitionTemplates =
if (inTpl == null)
makePackage(RootPackage, null).toList
- else if (sym.owner == inTpl.sym)
- inTpl :: Nil
else
makeTemplate(sym.owner) :: (sym.allOverriddenSymbols map { inhSym => makeTemplate(inhSym.owner) })
def visibility = {
@@ -121,11 +119,18 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
if (!sym.isModule && (sym hasFlag Flags.FINAL)) fgs += Paragraph(Text("final"))
fgs.toList
}
+ def deprecation =
+ if (sym.isDeprecated && sym.deprecationMessage.isDefined)
+ Some(commentator.factory.parseWiki(sym.deprecationMessage.get, NoPosition))
+ else if (sym.isDeprecated)
+ Some(Body(Nil))
+ else if (comment.isDefined)
+ comment.get.deprecated
+ else
+ None
def inheritedFrom =
if (inTemplate.sym == this.sym.owner || inTemplate.sym.isPackage) Nil else
makeTemplate(this.sym.owner) :: (sym.allOverriddenSymbols map { os => makeTemplate(os.owner) })
- def isDeprecated = sym.isDeprecated
- def deprecationMessage = sym.deprecationMessage
def resultType = makeType(sym.tpe.finalResultType, inTemplate, sym)
def isDef = false
def isVal = false
@@ -150,6 +155,18 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
override def definitionName = optimize(inDefinitionTemplates.head.qualifiedName + "." + name)
override def toRoot: List[DocTemplateImpl] = this :: inTpl.toRoot
def inSource = if (sym.sourceFile != null) Some(sym.sourceFile, sym.pos.line) else None
+ def sourceUrl = {
+ def fixPath(s: String) = s.replaceAll(java.io.File.separator, "/")
+ val assumedSourceRoot: String = {
+ val fixed = fixPath(settings.sourcepath.value)
+ if (fixed endsWith "/") fixed.dropRight(1) else fixed
+ }
+ if (!settings.docsourceurl.isDefault)
+ inSource map { case (file, _) =>
+ new java.net.URL(settings.docsourceurl.value + "/" + fixPath(file.path).replaceFirst("^" + assumedSourceRoot, ""))
+ }
+ else None
+ }
def typeParams = if (sym.isClass) sym.typeParams map (makeTypeParam(_, this)) else Nil
def parentType =
if (sym.isPackage) None else
@@ -169,7 +186,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
subClassesCache += sc
}
def subClasses = subClassesCache.toList
- protected def memberSyms =
+ protected lazy val memberSyms =
// Only this class's constructors are part of its members, inherited constructors are not.
sym.info.nonPrivateMembers.filter(x => (!x.isConstructor || x.owner==sym))
val members = memberSyms flatMap (makeMember(_, this))
@@ -231,7 +248,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
override def qualifiedName = "_root_"
override def inheritedFrom = Nil
override def isRootPackage = true
- override protected def memberSyms =
+ override protected lazy val memberSyms =
(bSym.info.members ++ EmptyPackage.info.members) filter { s =>
s != EmptyPackage && s != RootPackage
}
@@ -358,13 +375,13 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { extractor =
})
else if (bSym.isPackage)
inTpl match { case inPkg: PackageImpl => makePackage(bSym, inPkg) }
- else if ((bSym.isClass || bSym.isModule) && (bSym.sourceFile != null) && bSym.isPublic && !bSym.isLocal) {
+ else if ((bSym.isClass || bSym.isModule) && bSym.isPublic && !bSym.isLocal) {
(inTpl.toRoot find (_.sym == bSym )) orElse Some(makeDocTemplate(bSym, inTpl))
}
else
None
}
- if (!aSym.isPublic || (aSym hasFlag Flags.SYNTHETIC) || (aSym hasFlag Flags.BRIDGE) || aSym.isLocal || aSym.isModuleClass || aSym.isPackageObject || aSym.isMixinConstructor)
+ if ((!aSym.isPackage && aSym.sourceFile == null) || !aSym.isPublic || (aSym hasFlag Flags.SYNTHETIC) || aSym.isLocal || aSym.isModuleClass || aSym.isPackageObject || aSym.isMixinConstructor)
Nil
else {
val allSyms = useCases(aSym, inTpl.sym) map { case (bSym, bComment, bPos) =>
diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
index 15fc99f92..51a8b0b34 100644
--- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
@@ -29,10 +29,10 @@ final class CommentFactory(val reporter: Reporter) { parser =>
throw FatalError("program logic: " + msg)
protected val CleanHtml =
- new Regex("""?(p|h\d|pre|dl|dt|dd|ol|ul|li|blockquote|div|hr|br|br)\s*/?>""")
+ new Regex("""?(p|h\d|pre|dl|dt|dd|ol|ul|li|blockquote|div|hr|br|br).*/?>""")
protected val ShortLineEnd =
- new Regex("""\.|(p|h\d|pre|dd|li|div|blockquote)>|<(hr|table)\s*/?>""")
+ new Regex("""\.|?.*>""")
/** The body of a comment, dropping start and end markers. */
protected val CleanComment =
@@ -220,7 +220,7 @@ final class CommentFactory(val reporter: Reporter) { parser =>
* * Removed start-of-line star and one whitespace afterwards (if present).
* * Removed all end-of-line whitespace.
* * Only `endOfLine` is used to mark line endings. */
- protected def parseWiki(string: String, pos: Position): Body =
+ def parseWiki(string: String, pos: Position): Body =
new WikiParser(string.toArray, pos).document()
/** TODO