Skip to content

Commit baa4104

Browse files
authored
Merge pull request #550 from som-snytt/issue/docstar
Swap star-space for space-star
2 parents 59f1e17 + 2aceb33 commit baa4104

File tree

1 file changed

+54
-46
lines changed

1 file changed

+54
-46
lines changed

style/scaladoc.md

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,29 @@ experienced users, but can be invaluable for newcomers).
2222
The general format for a Scaladoc comment should be as follows:
2323

2424
/** 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+
*/
2929
def myMethod = {}
3030

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+
3138
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:
3340

3441
/** Does something very simple */
3542
def simple = {}
3643

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.
4048

4149
See the
4250
[AuthorDocs](https://wiki.scala-lang.org/display/SW/Writing+Documentation)
@@ -100,23 +108,23 @@ notation:
100108

101109
package my.package
102110
/** 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+
*/
120128
package complex {}
121129

122130
## Classes, Objects, and Traits
@@ -138,11 +146,11 @@ If the class should be created using a constructor, document it using
138146
the `@constructor` syntax:
139147

140148
/** 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+
*/
146154
class Person(name: String, age: Int) {
147155
}
148156

@@ -161,32 +169,32 @@ sure to indicate the actual method names:
161169
/** Factory for [[mypackage.Person]] instances. */
162170
object Person {
163171
/** 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+
*/
168176
def apply(name: String, age: Int) = {}
169177

170178
/** 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+
*/
177185
def apply(name: String, birthDate: java.util.Date) = {}
178186
}
179187

180188
If your object holds implicit conversions, provide an example in the
181189
Scaladoc:
182190

183191
/** 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+
*/
190198
object ComplexImplicits {}
191199

192200
#### Traits

0 commit comments

Comments
 (0)