~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/compiler/scala/tools/nsc/doc/base/comment/Comment.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* NSC -- new Scala compiler
 
2
 * Copyright 2007-2013 LAMP/EPFL
 
3
 * @author  Manohar Jonnalagedda
 
4
 */
 
5
 
 
6
package scala.tools.nsc
 
7
package doc
 
8
package base
 
9
package comment
 
10
 
 
11
import scala.collection._
 
12
 
 
13
/** A Scaladoc comment and all its tags.
 
14
  *
 
15
  * '''Note:''' the only instantiation site of this class is in [[CommentFactory]].
 
16
  *
 
17
  * @author Manohar Jonnalagedda
 
18
  * @author Gilles Dubochet */
 
19
abstract class Comment {
 
20
 
 
21
  /** The main body of the comment that describes what the entity does and is.  */
 
22
  def body: Body
 
23
 
 
24
  private def closeHtmlTags(inline: Inline) = {
 
25
    val stack = mutable.ListBuffer.empty[HtmlTag]
 
26
    def scan(i: Inline) {
 
27
      i match {
 
28
        case Chain(list) =>
 
29
          list foreach scan
 
30
        case tag: HtmlTag => {
 
31
          if (stack.length > 0 && tag.canClose(stack.last)) {
 
32
            stack.remove(stack.length-1)
 
33
          } else {
 
34
            tag.close match {
 
35
              case Some(t) =>
 
36
                stack += t
 
37
              case None =>
 
38
                ;
 
39
            }
 
40
          }
 
41
        }
 
42
        case _ =>
 
43
          ;
 
44
      }
 
45
    }
 
46
    scan(inline)
 
47
    Chain(List(inline) ++ stack.reverse)
 
48
  }
 
49
 
 
50
  /** A shorter version of the body. Usually, this is the first sentence of the body. */
 
51
  def short: Inline = {
 
52
    body.summary match {
 
53
      case Some(s) =>
 
54
        closeHtmlTags(s)
 
55
      case _ =>
 
56
        Text("")
 
57
    }
 
58
  }
 
59
 
 
60
  /** A list of authors. The empty list is used when no author is defined. */
 
61
  def authors: List[Body]
 
62
 
 
63
  /** A list of other resources to see, including links to other entities or
 
64
    * to external documentation. The empty list is used when no other resource
 
65
    * is mentionned. */
 
66
  def see: List[Body]
 
67
 
 
68
  /** A description of the result of the entity. Typically, this provides additional
 
69
    * information on the domain of the result, contractual post-conditions, etc. */
 
70
  def result: Option[Body]
 
71
 
 
72
  /** A map of exceptions that the entity can throw when accessed, and a
 
73
    * description of what they mean. */
 
74
  def throws: Map[String, Body]
 
75
 
 
76
  /** A map of value parameters, and a description of what they are. Typically,
 
77
    * this provides additional information on the domain of the parameters,
 
78
    * contractual pre-conditions, etc. */
 
79
  def valueParams: Map[String, Body]
 
80
 
 
81
  /** A map of type parameters, and a description of what they are. Typically,
 
82
    * this provides additional information on the domain of the parameters. */
 
83
  def typeParams: Map[String, Body]
 
84
 
 
85
  /** The version number of the entity. There is no formatting or further
 
86
    * meaning attached to this value. */
 
87
  def version: Option[Body]
 
88
 
 
89
  /** A version number of a containing entity where this member-entity was introduced. */
 
90
  def since: Option[Body]
 
91
 
 
92
  /** An annotation as to expected changes on this entity. */
 
93
  def todo: List[Body]
 
94
 
 
95
  /** Whether the entity is deprecated. Using the `@deprecated` Scala attribute
 
96
    * is prefereable to using this Scaladoc tag. */
 
97
  def deprecated: Option[Body]
 
98
 
 
99
  /** An additional note concerning the contract of the entity. */
 
100
  def note: List[Body]
 
101
 
 
102
  /** A usage example related to the entity. */
 
103
  def example: List[Body]
 
104
 
 
105
  /** The comment as it appears in the source text. */
 
106
  def source: Option[String]
 
107
 
 
108
  /** A description for the primary constructor */
 
109
  def constructor: Option[Body]
 
110
 
 
111
  /** A set of diagram directives for the inheritance diagram */
 
112
  def inheritDiagram: List[String]
 
113
 
 
114
  /** A set of diagram directives for the content diagram */
 
115
  def contentDiagram: List[String]
 
116
 
 
117
  /** The group this member is part of */
 
118
  def group: Option[String]
 
119
 
 
120
  /** Member group descriptions */
 
121
  def groupDesc: Map[String,Body]
 
122
 
 
123
  /** Member group names (overriding the short tag) */
 
124
  def groupNames: Map[String,String]
 
125
 
 
126
  /** Member group priorities */
 
127
  def groupPrio: Map[String,Int]
 
128
 
 
129
  override def toString =
 
130
    body.toString + "\n" +
 
131
    (authors map ("@author " + _.toString)).mkString("\n") +
 
132
    (result map ("@return " + _.toString)).mkString("\n") +
 
133
    (version map ("@version " + _.toString)).mkString
 
134
}