@@ -22,21 +22,29 @@ experienced users, but can be invaluable for newcomers).
22
22
The general format for a Scaladoc comment should be as follows:
23
23
24
24
/** This is a brief description of what's being documented.
25
- *
26
- * This is further documentation of what we're documenting. It should
27
- * provide more details as to how this works and what it does.
28
- */
25
+ *
26
+ * This is further documentation of what we're documenting. It should
27
+ * provide more details as to how this works and what it does.
28
+ */
29
29
def myMethod = {}
30
30
31
+ An alternative Scaladoc comment style right-aligns the column of asterisks
32
+ under the second asterisk, in the third column.
33
+ The Scaladoc tool also accepts Javadoc comment formatting,
34
+ with text following the single asterisks, separated by a single space.
35
+ Because the comment markup is sensitive to whitespace,
36
+ the tool must be able to infer the left margin.
37
+
31
38
For methods and other type members where the only documentation needed
32
- is a simple, short description, this format can be used:
39
+ is a simple, short description, a one-line format can be used:
33
40
34
41
/** Does something very simple */
35
42
def simple = {}
36
43
37
- Note, especially for those coming from Java, that the left-hand margin
38
- of asterisks falls under the \_ third\_ column, not the second, as is
39
- customary in Java.
44
+ Note that, in contrast to the Javadoc convention, the text begins
45
+ on the first line of the comment but that subsequent text remains aligned.
46
+ In particular, text is aligned on a multiple of two columns,
47
+ since Scala source is usually indented by two columns.
40
48
41
49
See the
42
50
[ AuthorDocs] ( https://wiki.scala-lang.org/display/SW/Writing+Documentation )
@@ -100,23 +108,23 @@ notation:
100
108
101
109
package my.package
102
110
/** Provides classes for dealing with complex numbers. Also provides
103
- * implicits for converting to and from `Int`.
104
- *
105
- * ==Overview==
106
- * The main class to use is [[my.package.complex.Complex]], as so
107
- * {{ "{{{" }}
108
- * scala> val complex = Complex(4,3)
109
- * complex: my.package.complex.Complex = 4 + 3i
110
- * }}}
111
- *
112
- * If you include [[my.package.complex.ComplexConversions]], you can
113
- * convert numbers more directly
114
- * {{ "{{{" }}
115
- * scala> import my.package.complex.ComplexConversions._
116
- * scala> val complex = 4 + 3.i
117
- * complex: my.package.complex.Complex = 4 + 3i
118
- * }}}
119
- */
111
+ * implicits for converting to and from `Int`.
112
+ *
113
+ * ==Overview==
114
+ * The main class to use is [[my.package.complex.Complex]], as so
115
+ * {{ "{{{" }}
116
+ * scala> val complex = Complex(4,3)
117
+ * complex: my.package.complex.Complex = 4 + 3i
118
+ * }}}
119
+ *
120
+ * If you include [[my.package.complex.ComplexConversions]], you can
121
+ * convert numbers more directly
122
+ * {{ "{{{" }}
123
+ * scala> import my.package.complex.ComplexConversions._
124
+ * scala> val complex = 4 + 3.i
125
+ * complex: my.package.complex.Complex = 4 + 3i
126
+ * }}}
127
+ */
120
128
package complex {}
121
129
122
130
## Classes, Objects, and Traits
@@ -138,11 +146,11 @@ If the class should be created using a constructor, document it using
138
146
the ` @constructor ` syntax:
139
147
140
148
/** A person who uses our application.
141
- *
142
- * @constructor create a new person with a name and age.
143
- * @param name the person's name
144
- * @param age the person's age in years
145
- */
149
+ *
150
+ * @constructor create a new person with a name and age.
151
+ * @param name the person's name
152
+ * @param age the person's age in years
153
+ */
146
154
class Person(name: String, age: Int) {
147
155
}
148
156
@@ -161,32 +169,32 @@ sure to indicate the actual method names:
161
169
/** Factory for [[mypackage.Person]] instances. */
162
170
object Person {
163
171
/** Creates a person with a given name and age.
164
- *
165
- * @param name their name
166
- * @param age the age of the person to create
167
- */
172
+ *
173
+ * @param name their name
174
+ * @param age the age of the person to create
175
+ */
168
176
def apply(name: String, age: Int) = {}
169
177
170
178
/** Creates a person with a given name and birthdate
171
- *
172
- * @param name their name
173
- * @param birthDate the person's birthdate
174
- * @return a new Person instance with the age determined by the
175
- * birthdate and current date.
176
- */
179
+ *
180
+ * @param name their name
181
+ * @param birthDate the person's birthdate
182
+ * @return a new Person instance with the age determined by the
183
+ * birthdate and current date.
184
+ */
177
185
def apply(name: String, birthDate: java.util.Date) = {}
178
186
}
179
187
180
188
If your object holds implicit conversions, provide an example in the
181
189
Scaladoc:
182
190
183
191
/** Implicit conversions and helpers for [[mypackage.Complex]] instances.
184
- *
185
- * {{ "{{{" }}
186
- * import ComplexImplicits._
187
- * val c: Complex = 4 + 3.i
188
- * }}}
189
- */
192
+ *
193
+ * {{ "{{{" }}
194
+ * import ComplexImplicits._
195
+ * val c: Complex = 4 + 3.i
196
+ * }}}
197
+ */
190
198
object ComplexImplicits {}
191
199
192
200
#### Traits
0 commit comments