// Get path from root
val rootToParentLis = tpl.toRoot
.tail
.reverse
.zipWithIndex
.map { case (pack, ind) =>
memberToHtml(pack, tpl, indentation = ind, isParent = (pack eq tpl.toRoot.tail.head))
}
val parent = tpl.toRoot match {
case _ :: parent :: _ if !parent.isRootPackage => Some(parent)
case _ => None
}
val parentSub = parent.fold(Seq[TemplateEntity with MemberEntity](tpl)) { p =>
p.templates.filter(_.isPackage).sortBy(_.name)
}
// If current entity is a package, take its containing entities - otherwise take parent's containing entities
val currentPackageTpls =
if (tpl.isPackage) tpl.templates
else parent.fold(Seq.empty[TemplateEntity with MemberEntity])(p => p.templates)
val (subsToTpl, subsAfterTpl) = parentSub.partition(_.name <= tpl.name)
val subsToTplLis = subsToTpl.map(memberToHtml(_, tpl, indentation = rootToParentLis.length))
val subsAfterTplLis = subsAfterTpl.map(memberToHtml(_, tpl, indentation = rootToParentLis.length))
val currEntityLis = currentPackageTpls
.filter(x => !x.isPackage && (x.isTrait || x.isClass || x.isAbstractType || x.isObject))
.sortBy(_.name)
.map(entityToUl(_, (if (tpl.isPackage) 0 else -1) + rootToParentLis.length))
val currSubLis = tpl.templates
.filter(_.isPackage)
.sortBy(_.name)
.map(memberToHtml(_, tpl, indentation = rootToParentLis.length + 1))
if (subsToTpl.isEmpty && !tpl.isPackage) // current Entity is not a package, show packages before entity listing
rootToParentLis ++ subsToTplLis ++ subsAfterTplLis ++ currSubLis ++ currEntityLis
else
rootToParentLis ++ subsToTplLis ++ currSubLis ++ currEntityLis ++ subsAfterTplLis
}
{ content }
def search =
{universe.settings.doctitle.value}{universe.settings.docversion.value}< Back
val valueMembers =
tpl.methods ++ tpl.values ++ tpl.templates.filter(x => x.isObject) sorted
val (absValueMembers, nonAbsValueMembers) =
valueMembers partition (_.isAbstract)
val (deprValueMembers, nonDeprValueMembers) =
nonAbsValueMembers partition (_.deprecation.isDefined)
val (concValueMembers, shadowedImplicitMembers) =
nonDeprValueMembers partition (!_.isShadowedOrAmbiguousImplicit)
val typeMembers =
tpl.abstractTypes ++ tpl.aliasTypes ++ tpl.templates.filter(x => x.isTrait || x.isClass) sorted (implicitly[Ordering[MemberEntity]])
val constructors = (tpl match {
case cls: Class => (cls.constructors: List[MemberEntity]).sorted
case _ => Nil
})
/* for body, there is a special case for AnyRef, otherwise AnyRef appears
* like a package/object this problem should be fixed, this implementation
* is just a patch. */
val content = {
val templateName = if (tpl.isRootPackage) "root package" else tpl.name
val displayName = tpl.companion match {
case Some(companion) if (companion.visibility.isPublic && companion.inSource != None) =>
{ templateName }
case _ =>
templateName
}
val owner = {
if (tpl.isRootPackage || tpl.inTemplate.isRootPackage)
NodeSeq.Empty
else
{
val imageClass = docEntityImageClass(tpl)
tpl.companion match {
case Some(companion) if (companion.visibility.isPublic && companion.inSource != None) =>
}
def memberToCommentHtml(mbr: MemberEntity, inTpl: DocTemplateEntity, isSelf: Boolean): NodeSeq = {
mbr match {
case dte: DocTemplateEntity if isSelf =>
// comment of class itself
case _ =>
// comment of non-class member or non-documentented inner class
val commentBody = memberToCommentBodyHtml(mbr, inTpl, isSelf = false)
if (commentBody.isEmpty)
NodeSeq.Empty
else {
val shortComment = memberToShortCommentHtml(mbr, isSelf)
val longComment = memberToUseCaseCommentHtml(mbr, isSelf) ++ memberToCommentBodyHtml(mbr, inTpl, isSelf)
val includedLongComment = if (shortComment.text.trim == longComment.text.trim)
NodeSeq.Empty
else
def memberToCommentBodyHtml(mbr: MemberEntity, inTpl: DocTemplateEntity, isSelf: Boolean, isReduced: Boolean = false): NodeSeq = {
val s = universe.settings
val memberComment =
if (mbr.comment.isEmpty) NodeSeq.Empty
else
{ commentToHtml(mbr.comment) }
val authorComment =
if (! s.docAuthor || mbr.comment.isEmpty ||
mbr.comment.isDefined && mbr.comment.get.authors.isEmpty) NodeSeq.Empty
else
{if (mbr.comment.get.authors.size > 1)
Authors:
else
Author:
}
{ mbr.comment.get.authors map bodyToHtml}
val paramComments = {
val prs: List[ParameterEntity] = mbr match {
case cls: Class => cls.typeParams ::: cls.valueParams.flatten
case trt: Trait => trt.typeParams
case dfe: Def => dfe.typeParams ::: dfe.valueParams.flatten
case ctr: Constructor => ctr.valueParams.flatten
case _ => Nil
}
def paramCommentToHtml(prs: List[ParameterEntity], comment: Comment): NodeSeq = prs match {
case (tp: TypeParam) :: rest =>
val paramEntry: NodeSeq = {
{ tp.name }
{ bodyToHtml(comment.typeParams(tp.name)) }
}
paramEntry ++ paramCommentToHtml(rest, comment)
case (vp: ValueParam) :: rest =>
val paramEntry: NodeSeq = {
{ vp.name }
{ bodyToHtml(comment.valueParams(vp.name)) }
}
paramEntry ++ paramCommentToHtml(rest, comment)
case _ =>
NodeSeq.Empty
}
mbr.comment.fold(NodeSeq.Empty) { comment =>
val cmtedPrs = prs filter {
case tp: TypeParam => comment.typeParams isDefinedAt tp.name
case vp: ValueParam => comment.valueParams isDefinedAt vp.name
}
if (cmtedPrs.isEmpty && comment.result.isEmpty) NodeSeq.Empty
else {
{
paramCommentToHtml(cmtedPrs, comment) ++ (
comment.result match {
case None => NodeSeq.Empty
case Some(cmt) =>
returns
{ bodyToHtml(cmt) }
})
}
}
}
}
val implicitInformation = mbr.byConversion match {
case Some(conv) =>
Implicit
++
{
val targetType = typeToHtml(conv.targetType, hasLinks = true)
val conversionMethod = conv.convertorMethod match {
case Left(member) => Text(member.name)
case Right(name) => Text(name)
}
// strip off the package object endings, they make things harder to follow
val conversionOwnerQualifiedNane = conv.convertorOwner.qualifiedName.stripSuffix(".package")
val conversionOwner = templateToHtml(conv.convertorOwner, conversionOwnerQualifiedNane)
val constraintText = conv.constraints match {
case Nil =>
NodeSeq.Empty
case List(constraint) =>
scala.xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint) ++ scala.xml.Text(".")
case List(constraint1, constraint2) =>
scala.xml.Text("This conversion will take place only if ") ++ constraintToHtml(constraint1) ++
scala.xml.Text(" and at the same time ") ++ constraintToHtml(constraint2) ++ scala.xml.Text(".")
case constraints =>
++ "This conversion will take place only if all of the following constraints are met:" ++ ++ {
var index = 0
constraints map { constraint => scala.xml.Text({ index += 1; index } + ". ") ++ constraintToHtml(constraint) ++ }
}
}
This member is added by an implicit conversion from { typeToHtml(inTpl.resultType, hasLinks = true) } to
{ targetType } performed by method { conversionMethod } in { conversionOwner }.
{ constraintText }
} ++ {
if (mbr.isShadowedOrAmbiguousImplicit) {
// These are the members that are shadowing or ambiguating the current implicit
// see ImplicitMemberShadowing trait for more information
val shadowingSuggestion = {
val params = mbr match {
case d: Def => d.valueParams map (_ map (_ name) mkString("(", ", ", ")")) mkString
case _ => "" // no parameters
}
++ scala.xml.Text("To access this member you can use a ") ++
type ascription ++ scala.xml.Text(":") ++
++
}
val shadowingWarning: NodeSeq =
if (mbr.isShadowedImplicit)
scala.xml.Text("This implicitly inherited member is shadowed by one or more members in this " +
"class.") ++ shadowingSuggestion
else if (mbr.isAmbiguousImplicit)
scala.xml.Text("This implicitly inherited member is ambiguous. One or more implicitly " +
"inherited members have similar signatures, so calling this member may produce an ambiguous " +
"implicit conversion compiler error.") ++ shadowingSuggestion
else NodeSeq.Empty
Shadowing
++
{ shadowingWarning }
} else NodeSeq.Empty
}
case _ =>
NodeSeq.Empty
}
// --- start attributes block vals
val attributes: NodeSeq = {
val fvs: List[comment.Paragraph] = visibility(mbr).toList
if (fvs.isEmpty || isReduced) NodeSeq.Empty
else {
case _ => NodeSeq.Empty
}
val annotations: NodeSeq = {
// A list of annotations which don't show their arguments, e. g. because they are shown separately.
val annotationsWithHiddenArguments = List("deprecated", "Deprecated", "migration")
def showArguments(annotation: Annotation) =
!(annotationsWithHiddenArguments.contains(annotation.qualifiedName))
if (!mbr.annotations.isEmpty) {
case _ => NodeSeq.Empty
}
val deprecation: NodeSeq =
mbr.deprecation match {
case Some(deprecation) if !isReduced =>
Deprecated
{ bodyToHtml(deprecation) }
case _ => NodeSeq.Empty
}
val migration: NodeSeq =
mbr.migration match {
case Some(migration) if !isReduced =>
Migration
{ bodyToHtml(migration) }
case _ => NodeSeq.Empty
}
val mainComment: NodeSeq = mbr.comment match {
case Some(comment) if (! isReduced) =>
def orEmpty[T](it: Iterable[T])(gen: =>NodeSeq): NodeSeq =
if (it.isEmpty) NodeSeq.Empty else gen
val example =
orEmpty(comment.example) {
Example{ if (comment.example.length > 1) "s" else ""}:
{
val exampleXml: List[NodeSeq] = for (ex <- comment.example) yield
{ bodyToHtml(ex) }
exampleXml.reduceLeft(_ ++ Text(", ") ++ _)
}
}
val version: NodeSeq =
orEmpty(comment.version) {
case _ => NodeSeq.Empty
}
val subclasses = mbr match {
case dtpl: DocTemplateEntity if isSelf && !isReduced =>
val subs = mutable.HashSet.empty[DocTemplateEntity]
def transitive(dtpl: DocTemplateEntity) {
for (sub <- dtpl.directSubClasses if !(subs contains sub)) {
subs add sub
transitive(sub)
}
}
transitive(dtpl)
if (subs.nonEmpty)