Skip to content

Commit 9db4532

Browse files
authored
Make style-only changes to doc comments for the standard library. (#24754)
The following style changes are made in this commit: 1. Use indicative mood (Returns, Builds, ... not imperative mood (Return, Build, ...). 2. Terminate initial sentence with a period. 3. Place code artifact names (for classes, methods, etc.) in backticks so they will render in code font. Only doc comments are changed, and only to make the above style changes. Reasoning: Indicative mood is recommended over imperative mood by the Scaladoc Style Guide: https://docs.scala-lang.org/style/scaladoc.html Which says: Document what the method does do not what the method should do. In other words, say “returns the result of applying f to x” rather than “return the result of applying f to x”. Subtle, but important. It is also what maybe 60% of Scaladoc comments in the standard library does, so this PR makes that consistent. It is also the way doc comments are written in Javadoc for the Java standard library. It is essentially writing the docoumentation as if you are explaining to a user (Returns something...) rather than an implementor (Return something...). The terminating period is also used some of the time, but not always, in the existing doc comments for the standard library> This makes it consistent. Some phrases are not full sentences, but you can think of the subject as "implicit." "Returns true" means "This method returns true." Also if you have a bullet list where some of the items are complete sentences, and others not, the style guide (Chicago Manual of Style) I go by suggests putting periods after all items. And the Java standard library documentation seems to do this. A few spots are missed in this PR, which I jotted down as I reviewed *every* changed file. But it hits most of them, so I'm hoping we can merge this into main and I can do further cleanup in later PRs.
1 parent d8605c3 commit 9db4532

File tree

214 files changed

+2027
-2027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+2027
-2027
lines changed

library-js/src/scala/Array.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object Array {
6161
val emptyObjectArray = new Array[Object](0)
6262
}
6363

64-
/** Provides an implicit conversion from the Array object to a collection Factory */
64+
/** Provides an implicit conversion from the Array object to a collection Factory. */
6565
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] = new ArrayFactory(dummy)
6666
@SerialVersionUID(3L)
6767
private class ArrayFactory[A : ClassTag](dummy: Array.type) extends Factory[A, Array[A]] with Serializable {
@@ -109,7 +109,7 @@ object Array {
109109
}
110110
}
111111

112-
/** Copy one array to another.
112+
/** Copies one array to another.
113113
* Equivalent to Java's
114114
* `System.arraycopy(src, srcPos, dest, destPos, length)`,
115115
* except that this also works for polymorphic and boxed arrays.
@@ -132,7 +132,7 @@ object Array {
132132
slowcopy(src, srcPos, dest, destPos, length)
133133
}
134134

135-
/** Copy one array to another, truncating or padding with default values (if
135+
/** Copies one array to another, truncating or padding with default values (if
136136
* necessary) so the copy has the specified length.
137137
*
138138
* Equivalent to Java's
@@ -154,7 +154,7 @@ object Array {
154154
case x: Array[Boolean] => java.util.Arrays.copyOf(x, newLength)
155155
}).asInstanceOf[Array[A]]
156156

157-
/** Copy one array to another, truncating or padding with default values (if
157+
/** Copies one array to another, truncating or padding with default values (if
158158
* necessary) so the copy has the specified length. The new array can have
159159
* a different type than the original one as long as the values are
160160
* assignment-compatible. When copying between primitive and object arrays,
@@ -192,7 +192,7 @@ object Array {
192192
result
193193
}
194194

195-
/** Returns an array of length 0 */
195+
/** Returns an array of length 0. */
196196
def empty[T: ClassTag]: Array[T] = new Array[T](0)
197197

198198
/** Creates an array with given elements.
@@ -212,7 +212,7 @@ object Array {
212212
array
213213
}
214214

215-
/** Creates an array of `Boolean` objects */
215+
/** Creates an array of `Boolean` objects. */
216216
// Subject to a compiler optimization in Cleanup, see above.
217217
def apply(x: Boolean, xs: Boolean*): Array[Boolean] = {
218218
val array = new Array[Boolean](xs.length + 1)
@@ -225,7 +225,7 @@ object Array {
225225
array
226226
}
227227

228-
/** Creates an array of `Byte` objects */
228+
/** Creates an array of `Byte` objects. */
229229
// Subject to a compiler optimization in Cleanup, see above.
230230
def apply(x: Byte, xs: Byte*): Array[Byte] = {
231231
val array = new Array[Byte](xs.length + 1)
@@ -238,7 +238,7 @@ object Array {
238238
array
239239
}
240240

241-
/** Creates an array of `Short` objects */
241+
/** Creates an array of `Short` objects. */
242242
// Subject to a compiler optimization in Cleanup, see above.
243243
def apply(x: Short, xs: Short*): Array[Short] = {
244244
val array = new Array[Short](xs.length + 1)
@@ -251,7 +251,7 @@ object Array {
251251
array
252252
}
253253

254-
/** Creates an array of `Char` objects */
254+
/** Creates an array of `Char` objects. */
255255
// Subject to a compiler optimization in Cleanup, see above.
256256
def apply(x: Char, xs: Char*): Array[Char] = {
257257
val array = new Array[Char](xs.length + 1)
@@ -264,7 +264,7 @@ object Array {
264264
array
265265
}
266266

267-
/** Creates an array of `Int` objects */
267+
/** Creates an array of `Int` objects. */
268268
// Subject to a compiler optimization in Cleanup, see above.
269269
def apply(x: Int, xs: Int*): Array[Int] = {
270270
val array = new Array[Int](xs.length + 1)
@@ -277,7 +277,7 @@ object Array {
277277
array
278278
}
279279

280-
/** Creates an array of `Long` objects */
280+
/** Creates an array of `Long` objects. */
281281
// Subject to a compiler optimization in Cleanup, see above.
282282
def apply(x: Long, xs: Long*): Array[Long] = {
283283
val array = new Array[Long](xs.length + 1)
@@ -290,7 +290,7 @@ object Array {
290290
array
291291
}
292292

293-
/** Creates an array of `Float` objects */
293+
/** Creates an array of `Float` objects. */
294294
// Subject to a compiler optimization in Cleanup, see above.
295295
def apply(x: Float, xs: Float*): Array[Float] = {
296296
val array = new Array[Float](xs.length + 1)
@@ -303,7 +303,7 @@ object Array {
303303
array
304304
}
305305

306-
/** Creates an array of `Double` objects */
306+
/** Creates an array of `Double` objects. */
307307
// Subject to a compiler optimization in Cleanup, see above.
308308
def apply(x: Double, xs: Double*): Array[Double] = {
309309
val array = new Array[Double](xs.length + 1)
@@ -316,7 +316,7 @@ object Array {
316316
array
317317
}
318318

319-
/** Creates an array of `Unit` objects */
319+
/** Creates an array of `Unit` objects. */
320320
def apply(x: Unit, xs: Unit*): Array[Unit] = {
321321
val array = new Array[Unit](xs.length + 1)
322322
array(0) = x
@@ -328,23 +328,23 @@ object Array {
328328
array
329329
}
330330

331-
/** Creates array with given dimensions */
331+
/** Creates array with given dimensions. */
332332
def ofDim[T: ClassTag](n1: Int): Array[T] =
333333
new Array[T](n1)
334-
/** Creates a 2-dimensional array */
334+
/** Creates a 2-dimensional array. */
335335
def ofDim[T: ClassTag](n1: Int, n2: Int): Array[Array[T]] = {
336336
val arr: Array[Array[T]] = (new Array[Array[T]](n1): Array[Array[T]])
337337
for (i <- 0 until n1) arr(i) = new Array[T](n2)
338338
arr
339339
// tabulate(n1)(_ => ofDim[T](n2))
340340
}
341-
/** Creates a 3-dimensional array */
341+
/** Creates a 3-dimensional array. */
342342
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
343343
tabulate(n1)(_ => ofDim[T](n2, n3))
344-
/** Creates a 4-dimensional array */
344+
/** Creates a 4-dimensional array. */
345345
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
346346
tabulate(n1)(_ => ofDim[T](n2, n3, n4))
347-
/** Creates a 5-dimensional array */
347+
/** Creates a 5-dimensional array. */
348348
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
349349
tabulate(n1)(_ => ofDim[T](n2, n3, n4, n5))
350350

@@ -662,7 +662,7 @@ object Array {
662662
*/
663663
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable { self =>
664664

665-
/** The length of the array */
665+
/** The length of the array. */
666666
def length: Int = throw new Error()
667667

668668
/** The element at given index.
@@ -676,7 +676,7 @@ final class Array[T](_length: Int) extends java.io.Serializable with java.lang.C
676676
*/
677677
def apply(i: Int): T = throw new Error()
678678

679-
/** Update the element at given index.
679+
/** Updates the element at given index.
680680
*
681681
* Indices start at `0`; `xs.update(i, x)` replaces the i^th^ element in the array.
682682
* Note the syntax `xs(i) = x` is a shorthand for `xs.update(i, x)`.
@@ -687,7 +687,7 @@ final class Array[T](_length: Int) extends java.io.Serializable with java.lang.C
687687
*/
688688
def update(i: Int, x: T): Unit = { throw new Error() }
689689

690-
/** Clone the Array.
690+
/** Clones the Array.
691691
*
692692
* @return A clone of the Array.
693693
*/

library-js/src/scala/Console.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ object Console extends AnsiColor {
138138
protected def setErrDirect(err: PrintStream): Unit = errVar.value = err
139139
protected def setInDirect(in: BufferedReader): Unit = inVar.value = in
140140

141-
/** The default output, can be overridden by `withOut`
141+
/** The default output, can be overridden by `withOut`.
142142
* @group io-default
143143
*/
144144
def out = outVar.value
145-
/** The default error, can be overridden by `withErr`
145+
/** The default error, can be overridden by `withErr`.
146146
* @group io-default
147147
*/
148148
def err = errVar.value
149-
/** The default input, can be overridden by `withIn`
149+
/** The default input, can be overridden by `withIn`.
150150
* @group io-default
151151
*/
152152
def in = inVar.value
@@ -181,7 +181,7 @@ object Console extends AnsiColor {
181181
def withOut[T](out: OutputStream)(thunk: =>T): T =
182182
withOut(new PrintStream(out))(thunk)
183183

184-
/** Set the default error stream for the duration
184+
/** Sets the default error stream for the duration
185185
* of execution of one thunk.
186186
* @example {{{
187187
* withErr(Console.out) { err.println("This goes to default _out_") }

library-js/src/scala/Enumeration.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
149149
*/
150150
final def apply(x: Int): Value = vmap(x)
151151

152-
/** Return a `Value` from this `Enumeration` whose name matches
152+
/** Returns a `Value` from this `Enumeration` whose name matches
153153
* the argument `s`. The names are determined automatically via reflection.
154154
*
155155
* @param s an `Enumeration` name
@@ -207,9 +207,9 @@ abstract class Enumeration (initial: Int) extends Serializable {
207207
/** The type of the enumerated values. */
208208
@SerialVersionUID(7091335633555234129L)
209209
abstract class Value extends Ordered[Value] with Serializable {
210-
/** the id and bit location of this enumeration value */
210+
/** The id and bit location of this enumeration value. */
211211
def id: Int
212-
/** a marker so we can tell whose values belong to whom come reflective-naming time */
212+
/** A marker so we can tell whose values belong to whom come reflective-naming time. */
213213
private[Enumeration] val outerEnum = thisenum
214214

215215
override def compare(that: Value): Int =
@@ -222,7 +222,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
222222
}
223223
override def hashCode: Int = id.##
224224

225-
/** Create a ValueSet which contains this value and another one */
225+
/** Creates a ValueSet which contains this value and another one. */
226226
def + (v: Value) = ValueSet(this, v)
227227
}
228228

@@ -255,7 +255,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
255255
}
256256
}
257257

258-
/** An ordering by id for values of this set */
258+
/** An ordering by id for values of this set. */
259259
implicit object ValueOrdering extends Ordering[Value] {
260260
def compare(x: Value, y: Value): Int = x compare y
261261
}
@@ -308,18 +308,18 @@ abstract class Enumeration (initial: Int) extends Serializable {
308308
super[SortedSet].collect[B](pf)
309309
}
310310

311-
/** A factory object for value sets */
311+
/** A factory object for value sets. */
312312
@SerialVersionUID(3L)
313313
object ValueSet extends SpecificIterableFactory[Value, ValueSet] {
314314
private final val ordMsg = "No implicit Ordering[${B}] found to build a SortedSet[${B}]. You may want to upcast to a Set[Value] first by calling `unsorted`."
315315
private final val zipOrdMsg = "No implicit Ordering[${B}] found to build a SortedSet[(Value, ${B})]. You may want to upcast to a Set[Value] first by calling `unsorted`."
316316

317-
/** The empty value set */
317+
/** The empty value set. */
318318
val empty = new ValueSet(immutable.BitSet.empty)
319319
/** A value set containing all the values for the zero-adjusted ids
320-
* corresponding to the bits in an array */
320+
* corresponding to the bits in an array. */
321321
def fromBitMask(elems: Array[Long]): ValueSet = new ValueSet(immutable.BitSet.fromBitMask(elems))
322-
/** A builder object for value sets */
322+
/** A builder object for value sets. */
323323
def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.Builder[Value, ValueSet] {
324324
private[this] val b = new mutable.BitSet
325325
def addOne (x: Value) = { b += (x.id - bottomId); this }

library-js/src/scala/collection/immutable/NumericRange.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ sealed class NumericRange[T](
9393
else if(isInclusive) new NumericRange.Inclusive(start + step, end, step)
9494
else new NumericRange.Exclusive(start + step, end, step)
9595

96-
/** Create a new range with the start and end values of this range and
96+
/** Creates a new range with the start and end values of this range and
9797
* a new `step`.
9898
*/
9999
def by(newStep: T): NumericRange[T] = copy(start, end, newStep)
100100

101101

102-
/** Create a copy of this range.
102+
/** Creates a copy of this range.
103103
*/
104104
def copy(start: T, end: T, step: T): NumericRange[T] =
105105
new NumericRange(start, end, step, isInclusive)

library-js/src/scala/collection/immutable/Range.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ sealed abstract class Range(
157157
final protected def copy(start: Int = start, end: Int = end, step: Int = step, isInclusive: Boolean = isInclusive): Range =
158158
if(isInclusive) new Range.Inclusive(start, end, step) else new Range.Exclusive(start, end, step)
159159

160-
/** Create a new range with the `start` and `end` values of this range and
160+
/** Creates a new range with the `start` and `end` values of this range and
161161
* a new `step`.
162162
*
163163
* @return a new range with a different step
@@ -364,7 +364,7 @@ sealed abstract class Range(
364364
if (isEmpty) this
365365
else new Range.Inclusive(last, start, -step)
366366

367-
/** Make range inclusive.
367+
/** Makes range inclusive.
368368
*/
369369
final def inclusive: Range =
370370
if (isInclusive) this
@@ -566,21 +566,21 @@ object Range {
566566
def count(start: Int, end: Int, step: Int): Int =
567567
count(start, end, step, isInclusive = false)
568568

569-
/** Make a range from `start` until `end` (exclusive) with given step value.
569+
/** Makes a range from `start` until `end` (exclusive) with given step value.
570570
* @note step != 0
571571
*/
572572
def apply(start: Int, end: Int, step: Int): Range.Exclusive = new Range.Exclusive(start, end, step)
573573

574-
/** Make a range from `start` until `end` (exclusive) with step value 1.
574+
/** Makes a range from `start` until `end` (exclusive) with step value 1.
575575
*/
576576
def apply(start: Int, end: Int): Range.Exclusive = new Range.Exclusive(start, end, 1)
577577

578-
/** Make an inclusive range from `start` to `end` with given step value.
578+
/** Makes an inclusive range from `start` to `end` with given step value.
579579
* @note step != 0
580580
*/
581581
def inclusive(start: Int, end: Int, step: Int): Range.Inclusive = new Range.Inclusive(start, end, step)
582582

583-
/** Make an inclusive range from `start` to `end` with step value 1.
583+
/** Makes an inclusive range from `start` to `end` with step value 1.
584584
*/
585585
def inclusive(start: Int, end: Int): Range.Inclusive = new Range.Inclusive(start, end, 1)
586586

library-js/src/scala/collection/mutable/ArrayBuilder.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ sealed abstract class ArrayBuilder[T]
5454

5555
protected[this] def resize(size: Int): Unit
5656

57-
/** Add all elements of an array */
57+
/** Adds all elements of an array. */
5858
def addAll(xs: Array[_ <: T]): this.type = addAll(xs, 0, xs.length)
5959

60-
/** Add a slice of an array */
60+
/** Adds a slice of an array. */
6161
def addAll(xs: Array[_ <: T], offset: Int, length: Int): this.type = {
6262
ensureSize(this.size + length)
6363
Array.copy(xs, offset, elems.nn, this.size, length)
@@ -146,7 +146,7 @@ object ArrayBuilder {
146146
this
147147
}
148148

149-
/** Add a slice of an array */
149+
/** Adds a slice of an array. */
150150
override def addAll(xs: Array[_ <: T], offset: Int, length: Int): this.type = {
151151
val end = offset + length
152152
var i = offset

library-js/src/scala/collection/mutable/Buffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ trait Buffer[A]
5252
@`inline` final def appendAll(xs: IterableOnce[A]): this.type = addAll(xs)
5353

5454

55-
/** Alias for `prepend` */
55+
/** Alias for `prepend`. */
5656
@`inline` final def +=: (elem: A): this.type = prepend(elem)
5757

5858
def prependAll(elems: IterableOnce[A]): this.type = { insertAll(0, elems); this }
5959

6060
@deprecated("Use prependAll instead", "2.13.0")
6161
@`inline` final def prepend(elems: A*): this.type = prependAll(elems)
6262

63-
/** Alias for `prependAll` */
63+
/** Alias for `prependAll`. */
6464
@inline final def ++=:(elems: IterableOnce[A]): this.type = prependAll(elems)
6565

6666
/** Inserts a new element at a given index into this buffer.

library-js/src/scala/reflect/ClassTag.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial
6161
*/
6262
def runtimeClass: jClass[_]
6363

64-
/** Produces a `ClassTag` that knows how to instantiate an `Array[Array[T]]` */
64+
/** Produces a `ClassTag` that knows how to instantiate an `Array[Array[T]]`. */
6565
def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(runtimeClass))
6666

67-
/** Produces a new array with element type `T` and length `len` */
67+
/** Produces a new array with element type `T` and length `len`. */
6868
def newArray(len: Int): Array[T] =
6969
java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]]
7070

0 commit comments

Comments
 (0)