From 4040d8511e1632b640369b1f0d9f480aca69dbf6 Mon Sep 17 00:00:00 2001 From: Donna Malayeri Date: Wed, 6 Apr 2011 14:24:30 +0000 Subject: [scaladoc] Reduce horizontal lines in html outp... [scaladoc] Reduce horizontal lines in html output, refactor Template.css to improve readability. No review. --- .../scala/tools/nsc/doc/html/page/Template.scala | 233 ++++++++++++--------- .../tools/nsc/doc/html/resource/lib/template.css | 21 +- 2 files changed, 150 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index e2a5f7d1fd..88d3e61263 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -235,32 +235,37 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {

{ inlineToHtml(mbr.comment.get.short) }

def memberToCommentBodyHtml(mbr: MemberEntity, isSelf: Boolean, isReduced: Boolean = false): NodeSeq = { - NodeSeq.Empty ++ - { if (mbr.comment.isEmpty) NodeSeq.Empty else -
{ commentToHtml(mbr.comment) }
- } ++ - { val prs: List[ParameterEntity] = mbr match { + val memberComment = + if (mbr.comment.isEmpty) NodeSeq.Empty + else
{ commentToHtml(mbr.comment) }
+ + 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 mbrCmt = mbr.comment.get + def paramCommentToHtml(prs: List[ParameterEntity]): NodeSeq = prs match { - case Nil => - NodeSeq.Empty + case Nil => NodeSeq.Empty + case (tp: TypeParam) :: rest => val paramEntry: NodeSeq = {
{ tp.name }
{ bodyToHtml(mbrCmt.typeParams(tp.name)) }
} paramEntry ++ paramCommentToHtml(rest) + case (vp: ValueParam) :: rest => val paramEntry: NodeSeq = {
{ vp.name }
{ bodyToHtml(mbrCmt.valueParams(vp.name)) }
} paramEntry ++ paramCommentToHtml(rest) } + if (mbr.comment.isEmpty) NodeSeq.Empty else { val cmtedPrs = prs filter { @@ -268,7 +273,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { case vp: ValueParam => mbrCmt.valueParams isDefinedAt vp.name } if (cmtedPrs.isEmpty && mbrCmt.result.isEmpty) NodeSeq.Empty - else + else {
{ paramCommentToHtml(cmtedPrs) ++ ( mbrCmt.result match { @@ -277,123 +282,145 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
returns
{ bodyToHtml(cmt) }
}) }
+ } } - } ++ - { val fvs: List[comment.Paragraph] = visibility(mbr).toList ::: mbr.flags - if (fvs.isEmpty || isReduced) NodeSeq.Empty else -
- attributes: { fvs map { fv => { inlineToHtml(fv.text) ++ xml.Text(" ") } } } -
- } ++ - { val inDefTpls = mbr.inDefinitionTemplates - if ((inDefTpls.tail.isEmpty && (inDefTpls.head == mbr.inTemplate)) || isReduced) NodeSeq.Empty else { -
- definition classes: { templatesToHtml(inDefTpls, xml.Text(" → ")) } -
+ } + + // --- start attributes block vals + val attributes: Seq[scala.xml.Node] = { + val fvs: List[comment.Paragraph] = visibility(mbr).toList ::: mbr.flags + if (fvs.isEmpty || isReduced) NodeSeq.Empty + else { +
Attributes
+
{ fvs map { fv => { inlineToHtml(fv.text) ++ xml.Text(" ") } } }
} - } ++ - { mbr match { - case dtpl: DocTemplateEntity if (isSelf && !dtpl.selfType.isEmpty && !isReduced) => -
- self type: { typeToHtml(dtpl.selfType.get, hasLinks = true) } -
- case _ => NodeSeq.Empty + } + + val definitionClasses: Seq[scala.xml.Node] = { + val inDefTpls = mbr.inDefinitionTemplates + if ((inDefTpls.tail.isEmpty && (inDefTpls.head == mbr.inTemplate)) || isReduced) NodeSeq.Empty + else { +
Definition Classes
+
{ templatesToHtml(inDefTpls, xml.Text(" → ")) }
} - } ++ - { if (!mbr.annotations.isEmpty) { -
- annotations: { + } + + val selfType: Seq[scala.xml.Node] = mbr match { + case dtpl: DocTemplateEntity if (isSelf && !dtpl.selfType.isEmpty && !isReduced) => +
Self Type
+
{ typeToHtml(dtpl.selfType.get, hasLinks = true) }
+ case _ => NodeSeq.Empty + } + + val annotations: Seq[scala.xml.Node] = + if (!mbr.annotations.isEmpty) { +
Annotations
+
{ mbr.annotations.map { annot => @{ templateToHtml(annot.annotationClass) }{ argumentsToHtml(annot.arguments) } } } -
- } - else NodeSeq.Empty - } ++ - { mbr match { - case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => - val (absFile, line) = dtpl.inSource.get -
- source: { { Text(absFile.file.getName) } } -
- case _ => NodeSeq.Empty + + } else NodeSeq.Empty + + val sourceLink: Seq[scala.xml.Node] = mbr match { + case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => + val (absFile, line) = dtpl.inSource.get +
Source
+
{ { Text(absFile.file.getName) } }
+ case _ => NodeSeq.Empty + } + + val deprecation: Seq[scala.xml.Node] = + if (mbr.deprecation.isEmpty || isReduced) NodeSeq.Empty + else { +
Deprecated
+
{ bodyToHtml(mbr.deprecation.get) }
} - } ++ - { if (mbr.deprecation.isEmpty || isReduced) NodeSeq.Empty else -
    deprecated: - {
  1. { bodyToHtml(mbr.deprecation.get) }
  2. } -
- } ++ - { mbr.comment match { - case Some(comment) => - - { if(!comment.example.isEmpty && !isReduced) -
Example{ if (comment.example.length > 1) "s" else ""} : + + val mainComment: Seq[scala.xml.Node] = mbr.comment match { + case Some(comment) => + val example = + if(!comment.example.isEmpty && !isReduced) +
Example{ if (comment.example.length > 1) "s" else ""} :
    { - val exampleXml: List[scala.xml.NodeSeq] = - for(example <- comment.example ) yield -
  1. { bodyToHtml(example) }
  2. - exampleXml.reduceLeft(_ ++ Text(", ") ++ _) - }
+ val exampleXml: List[scala.xml.NodeSeq] = + for(example <- comment.example ) yield +
  • { bodyToHtml(example) }
  • + exampleXml.reduceLeft(_ ++ Text(", ") ++ _) + }
    - else NodeSeq.Empty - } - { if(!comment.version.isEmpty && !isReduced) -
      version - { for(body <- comment.version.toList) yield
    1. {bodyToHtml(body)}
    2. } -
    - else NodeSeq.Empty - } - { if(!comment.since.isEmpty && !isReduced) -
      since - { for(body <- comment.since.toList) yield
    1. {bodyToHtml(body)}
    2. } -
    - else NodeSeq.Empty + else NodeSeq.Empty + + val version: Seq[scala.xml.Node] = + if(!comment.version.isEmpty && !isReduced) { +
    Version
    +
    { for(body <- comment.version.toList) yield {bodyToHtml(body)} }
    + } else NodeSeq.Empty + + val sinceVersion: Seq[scala.xml.Node] = + if(!comment.since.isEmpty && !isReduced) { +
    Since
    +
    { for(body <- comment.since.toList) yield {bodyToHtml(body)} }
    + } else NodeSeq.Empty + + val seeAlso: Seq[scala.xml.Node] = + if(!comment.see.isEmpty && !isReduced) { +
    See also
    +
    { + val seeXml:List[scala.xml.NodeSeq]=(for(see <- comment.see ) yield {bodyToHtml(see)} ) + seeXml.reduceLeft(_ ++ Text(", ") ++ _) + }
    + } else NodeSeq.Empty + + { + example ++ version ++ sinceVersion ++ seeAlso + } + + case None => NodeSeq.Empty + } + // end attributes block vals --- + + val attributesBlock = +
    { + attributes ++ definitionClasses ++ selfType ++ annotations ++ sourceLink ++ deprecation ++ mainComment + }
    + + val linearization = + mbr match { + case dtpl: DocTemplateEntity if (isSelf && !isReduced && (!dtpl.linearizationTemplates.isEmpty || !dtpl.subClasses.isEmpty)) => + val linearSupertypes: Seq[scala.xml.Node] = + if (dtpl.linearizationTemplates.isEmpty) NodeSeq.Empty + else { +

    Linear Supertypes

    +

    { typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) }

    } - { if(!comment.see.isEmpty && !isReduced) -
      see also: - { val seeXml:List[scala.xml.NodeSeq]=(for(see <- comment.see ) yield
    1. {bodyToHtml(see)}
    2. ) - seeXml.reduceLeft(_ ++ Text(", ") ++ _) - } -
    - else NodeSeq.Empty + + val knownSubclasses: Seq[scala.xml.Node] = + if (dtpl.subClasses.isEmpty) NodeSeq.Empty + else { +

    Known Subclasses

    +

    { templatesToHtml(dtpl.subClasses, xml.Text(", ")) }

    } - - case None => NodeSeq.Empty - } - } ++ - { mbr match { - case dtpl: DocTemplateEntity if (isSelf && !isReduced && (!dtpl.linearizationTemplates.isEmpty || !dtpl.subClasses.isEmpty)) => +
    -
    +
    Show linear super types and known subclasses Hide linear super types and known subclasses
    -
    - - { - if(dtpl.linearizationTemplates.isEmpty) NodeSeq.Empty else { -
    - linear super types: { typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) } -
    - } - } - { - if(dtpl.subClasses.isEmpty) NodeSeq.Empty else { -
    - known subclasses: { templatesToHtml(dtpl.subClasses, xml.Text(", ")) } -
    - } - } -
    +
    + { + linearSupertypes ++ knownSubclasses + }
    case _ => NodeSeq.Empty } - } + + NodeSeq.Empty ++ memberComment ++ paramComments ++ attributesBlock ++ linearization + } def kindToString(mbr: MemberEntity): String = { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css index dbae50058e..038d835d43 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css @@ -83,6 +83,7 @@ a[href]:hover { #definition h1 > a { color: white; + font-size: 24pt; } #signature { @@ -112,10 +113,16 @@ a[href]:hover { display: none; } +div.superTypes > h1 { + font-style: italic; + padding-top: 0.5em; +} + .link { text-decoration: underline; cursor: pointer; color: #315479; + font-size: 11pt; } @@ -138,6 +145,18 @@ h3 { font-weight: bold; } +dl.attributes > dt { + display: block; + float: left; + font-style: italic; +} + +dl.attributes > dd { + display: block; + padding-left: 10em; + margin-bottom: 5px; +} + #template .values > h3 { background-color: #315479; /* grayish blue */ } @@ -390,7 +409,7 @@ div.fullcomment { div.fullcomment .block { padding: 5px 0 0; - border-top: 1px dashed silver; + border-top: 1px solid #EBEBEB; margin-top: 5px; } -- cgit v1.2.3