Skip to content

Commit 38aec8f

Browse files
committed
Fix scaladoc for elements broken in scalameta#2700
1 parent 3e7d6d7 commit 38aec8f

File tree

17 files changed

+218
-116
lines changed

17 files changed

+218
-116
lines changed

readme/src/main/scala/org/scalafmt/readme/Readme.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ object Readme {
4343

4444
/** repl session, inspired by tut.
4545
*
46-
* Example: code="1 + 1" returns "scala> 1 + 1 res0: Int = 2"
46+
* Example: {{{code="1 + 1"}}} returns
47+
* {{{
48+
* scala> 1 + 1
49+
* res0: Int = 2
50+
* }}}
4751
*/
4852
def repl(code: String) = {
4953
import scala.meta._

scalafmt-cli/src/main/scala/org/scalafmt/cli/CliOptions.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ object CliOptions {
1717
/** Tries to read configuration from
1818
*
1919
* 1. .scalafmt.conf in root dir of current git repo IF the following
20-
* setting is enabled: project.git = true 2. .scalafmt.conf from
21-
* init.common.workingDirectory
20+
* setting is enabled: project.git = true
21+
* 1. .scalafmt.conf from init.common.workingDirectory
2222
*
2323
* I am happy to add alternative fallback methods for other VCS.
2424
*

scalafmt-cli/src/main/scala/org/scalafmt/cli/TermDisplay.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ object Terminal {
5555

5656
/** Clear the current line
5757
*
58-
* n=0: clear from cursor to end of line n=1: clear from cursor to start of
59-
* line n=2: clear entire line
58+
* - n=0: clear from cursor to end of line
59+
* - n=1: clear from cursor to start of line
60+
* - n=2: clear entire line
6061
*/
6162
def clearLine(n: Int): Unit = control(n, 'K')
6263
}

scalafmt-cli/src/main/scala/org/scalafmt/cli/WriteMode.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package org.scalafmt.cli
22

33
/** Determines the mode in which Scalafmt will behave
44
*
5-
* Override = Replace the file with its formatted form Stdout = Print the
6-
* formatted file to Stdout (leaving the original file untouched)
5+
* - Override: Replace the file with its formatted form
6+
* - Stdout: Print the formatted file to Stdout (leaving the original file
7+
* untouched)
78
*/
89
sealed trait WriteMode
910

scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala

+32-26
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,54 @@ import metaconfig.generic.Surface
77
/** @param openParenCallSite
88
* If true AND bin-packing is true, then call-site arguments won't be aligned
99
* by the opening parenthesis. For example, this output will be disallowed
10-
*
11-
* function(a, b, c)
10+
* {{{
11+
* function1(a,
12+
* b,
13+
* c)
14+
* }}}
1215
* @param openParenDefnSite
1316
* Same as [[openParenCallSite]], except definition site.
1417
* @param tokens
1518
* The tokens to vertically align by. The "owner" is the
1619
* scala.meta.Tree.getClass.getName of the deepest tree node that "owns" the
1720
* token to align by.
21+
* - Examples:
22+
* {{{
23+
* align.tokens = ["="] // align = owned by any tree node (not recommended)
1824
*
19-
* Examples:
20-
*
21-
* align.tokens = ["="] // align = owned by any tree node (not recommended)
22-
*
23-
* align.tokens = [ { code = "=", owner = "Param" } // align = when owned by
24-
* parameter tree nodes ]
25-
*
26-
* Pro tip. if you use for example
27-
*
28-
* preset = defaultWithAlign
29-
*
30-
* and want to add one extra token (for example "|>") to align by, write
31-
*
32-
* align.tokens."+" = [ "|> ]
33-
*
34-
* NOTE. Adding more alignment tokens may potentially decrease the vertical
35-
* alignment in formatted output. Customize at your own risk, I recommend you
36-
* try and stick to the default settings.
25+
* align.tokens = [
26+
* { code = "=", owner = "Param" } // align = when owned by parameter tree nodes
27+
* ]
28+
* }}}
29+
* - Pro tip. if you use for example {{{preset = defaultWithAlign}}} and want
30+
* to add one extra token (for example "|>") to align by, write
31+
* {{{
32+
* align.tokens."+" = [ "|> ]
33+
* }}}
34+
* - NOTE. Adding more alignment tokens may potentially decrease the vertical
35+
* alignment in formatted output. Customize at your own risk, I recommend
36+
* you try and stick to the default settings.
3737
* @param arrowEnumeratorGenerator
3838
* If true, aligns by `<-` in for comprehensions.
3939
* @param openParenCtrlSite
4040
* If true, aligns by ( in if/while/for. If false, indents by continuation
4141
* indent at call site.
4242
* @param tokenCategory
4343
* Customize which token kinds can align together. By default, only tokens
44-
* with the same `Token.productPrefix` align. To for example align = and <-,
45-
* set the values to: Map("Equals" -> "Assign", "LeftArrow" -> "Assign")
46-
* Note. Requires mixedTokens to be true.
44+
* with the same `Token.productPrefix` align. For example, to align = and <-,
45+
* set the values to:
46+
* {{{
47+
* Map("Equals" -> "Assign", "LeftArrow" -> "Assign")
48+
* }}}
49+
* Note: Requires mixedTokens to be true.
4750
* @param treeCategory
4851
* Customize which tree kinds can align together. By default, only trees with
49-
* the same `Tree.productPrefix` align. To for example align Defn.Val and
50-
* Defn.Var, set the values to: Map("Defn.Var" -> "Assign", "Defn.Val" ->
51-
* "Assign") Note. Requires mixedOwners to be true.
52+
* the same `Tree.productPrefix` align. For example, to align Defn.Val and
53+
* Defn.Var, set the values to:
54+
* {{{
55+
* Map("Defn.Var" -> "Assign", "Defn.Val" -> "Assign")
56+
* }}}
57+
* Note. Requires mixedOwners to be true.
5258
* @param stripMargin
5359
* If set, indent lines with a strip-margin character in a multiline string
5460
* constant relative to the opening quotes (or the strip-margin character if

scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala

+16-9
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ import metaconfig.generic.Surface
8080
* }}}
8181
* @param alwaysBeforeElseAfterCurlyIf
8282
* if true, add a new line between the end of a curly if and the following
83-
* else. For example if(someCond) { // ... } else //...
83+
* else. For example
84+
* {{{
85+
* if(someCond) {
86+
* // ...
87+
* }
88+
* else //...
89+
* }}}
8490
* @param beforeMultilineDef
8591
* If unfold (or true), add a newline before the body of a multiline def
8692
* without curly braces. See #1126 for discussion. For example,
@@ -114,15 +120,16 @@ import metaconfig.generic.Surface
114120
* }
115121
* }}}
116122
* @param source
117-
* Controls how line breaks in the input source are handled If `classic`
118-
* (default), the old mixed behaviour will be used If `keep`, try to keep
119-
* source newlines If `fold`, ignore source and try to remove line breaks If
120-
* `unfold`, ignore source and try to break lines
123+
* Controls how line breaks in the input source are handled
124+
* - If `classic` (default), the old mixed behaviour will be used
125+
* - If `keep`, try to keep source newlines
126+
* - If `fold`, ignore source and try to remove line breaks
127+
* - If `unfold`, ignore source and try to break lines
121128
* @param afterInfix
122-
* Controls how line breaks around operations are handled If `keep` (default
123-
* for source=classic,keep), preserve existing If `some` (default for
124-
* source=fold), break after some infix ops If `many` (default for
125-
* source=unfold), break after many infix ops
129+
* Controls how line breaks around operations are handled
130+
* - If `keep` (default for source=classic,keep), preserve existing
131+
* - If `some` (default for source=fold), break after some infix ops
132+
* - If `many` (default for source=unfold), break after many infix ops
126133
* @param afterInfixBreakOnNested
127134
* Force breaks around nested (enclosed in parentheses) expressions
128135
* @param afterInfixMaxCountPerFile

scalafmt-core/shared/src/main/scala/org/scalafmt/config/OptIn.scala

+6-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ case class OptIn(
118118
/** See https://github.com/scalameta/scalafmt/issues/1712
119119
*
120120
* Setting behavior and name were mirrored. After deprecation and right
121-
* naming we need to: if `forceBlankLineBeforeDocstring` (new name) has
122-
* default value (true) fallback to `blankLineBeforeDocstring` (old config)
123-
* which may be configured in .scalafmt.conf if
124-
* `forceBlankLineBeforeDocstring` configured to non-default value don't look
125-
* at the old name
121+
* naming we need to:
122+
* - if `forceBlankLineBeforeDocstring` (new name) has default value
123+
* (true), fallback to `blankLineBeforeDocstring` (old config) which may
124+
* be configured in .scalafmt.conf
125+
* - if `forceBlankLineBeforeDocstring` configured to non-default value,
126+
* don't look at the old name
126127
*/
127128
lazy val forceNewlineBeforeDocstringSummary: Boolean =
128129
forceBlankLineBeforeDocstring && !blankLineBeforeDocstring

scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtConfig.scala

+34-18
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,48 @@ import org.scalafmt.util.ValidationOps
3030
* @param danglingParentheses
3131
* If true AND @binPackArguments is true AND @configStyleArguments is false,
3232
* then this
33-
*
34-
* function( longerArg1, longerArg3)
35-
*
33+
* {{{
34+
* function(
35+
* longerArg1,
36+
* longerArg3)
37+
* }}}
3638
* is formatted like this
37-
*
38-
* function( longerArg1, longerArg3 )
39+
* {{{
40+
* function(
41+
* longerArg1,
42+
* longerArg3
43+
* )
44+
* }}}
3945
* @param rewriteTokens
4046
* Map of tokens to rewrite. For example, Map("⇒" -> "=>") will rewrite
4147
* unicode arrows to regular ascii arrows.
4248
* @param importSelectors
4349
* Controls formatting of import selectors with multiple names from the same
44-
* package; If [[org.scalafmt.config.ImportSelectors.binPack]], import
45-
* selectors are arranged to fit within the maximum line width If
46-
* [[org.scalafmt.config.ImportSelectors.noBinPack]], import selectors are
47-
* broken to one per line If
48-
* [[org.scalafmt.config.ImportSelectors.singleLine]], import selectors are
49-
* kept on a single line The default setting is currently `noBinPack`.
50+
* package
51+
* - If [[org.scalafmt.config.ImportSelectors.binPack]], import selectors are
52+
* arranged to fit within the maximum line width
53+
* - If [[org.scalafmt.config.ImportSelectors.noBinPack]], import selectors
54+
* are broken to one per line
55+
* - If [[org.scalafmt.config.ImportSelectors.singleLine]], import selectors
56+
* are kept on a single line The default setting is currently `noBinPack`.
5057
* @param indentYieldKeyword
51-
* If true, indents `yield` by two spaces for (i <- j) yield banana If false,
52-
* treats `yield` like `else` for (i <- j) yield banana
58+
* - If true, indents `yield` by two spaces
59+
* {{{
60+
* for (i <- j)
61+
* yield banana
62+
* }}}
63+
* - If false, treats `yield` like `else`
64+
* {{{
65+
* for (i <- j)
66+
* yield banana
67+
* }}}
5368
* @param lineEndings
54-
* If [[LineEndings.unix]], output will include only unix line endings If
55-
* [[LineEndings.windows]], output will include only windows line endings If
56-
* [[LineEndings.preserve]], output will include endings included in original
57-
* file (windows if there was at least one windows line ending, unix if there
58-
* was zero occurrences of windows line endings)
69+
* - If [[LineEndings.unix]], output will include only unix line endings
70+
* - If [[LineEndings.windows]], output will include only windows line
71+
* endings
72+
* - If [[LineEndings.preserve]], output will include endings included in
73+
* original file (windows if there was at least one windows line ending,
74+
* unix if there was zero occurrences of windows line endings)
5975
* @param includeCurlyBraceInSelectChains
6076
* NB: failure unless newlines.source=classic If true, includes curly brace
6177
* applications in select chains/pipelines.

scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtOptimizer.scala

+16-10
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@ import metaconfig._
2424
* Do not optimize inside certain areas such as term apply.
2525
* @param pruneSlowStates
2626
* Eliminate solutions that move slower than other solutions.
27+
* - If a solution reaches a point X first and other solution that reaches
28+
* the same point later, the first solution is preferred if it can be
29+
* verified to be always better (see
30+
* [[org.scalafmt.internal.State.alwaysBetter]]).
31+
* - Note. This affects the output positively because it breaks a tie between
32+
* two equally expensive solutions by eliminating the slower one.
2733
*
28-
* If a solution reaches a point X first and other solution that reaches the
29-
* same point later, the first solution is preferred if it can be verified to
30-
* be always better (see [[org.scalafmt.internal.State.alwaysBetter]]).
31-
*
32-
* Note. This affects the output positively because it breaks a tie between two
33-
* equally expensive solutions by eliminating the slower one.
34-
*
35-
* Example, solution 1 is preferred even though both solutions cost the same:
36-
*
37-
* // solution 1 a + b + c + d // solution 2 a + b + c + d
34+
* - Example: solution 1 is preferred even though both solutions cost the
35+
* same:
36+
* {{{
37+
* // solution 1
38+
* a + b +
39+
* c + d
40+
* // solution 2
41+
* a +
42+
* b + c + d
43+
* }}}
3844
* @param recurseOnBlocks
3945
* Recursively format { ... } blocks inside no optimization zones.
4046
*

scalafmt-core/shared/src/main/scala/org/scalafmt/config/Spaces.scala

+26-10
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,40 @@ import metaconfig._
99
* @param afterTripleEquals
1010
* If true, formats ===( as === (
1111
* @param inImportCurlyBraces
12-
* If true, formats `import a.b.{ c, d }`. If false, formats `import a.b.{c,
13-
* d}`.
12+
* - If true, formats
13+
* {{{
14+
* import a.b.{ c, d}
15+
* }}}
16+
* - If false, formats
17+
* {{{
18+
* import a.b.{c, d}
19+
* }}}
1420
* @param inInterpolatedStringCurlyBraces
15-
* If true, formats `s"\${var1} \${var2.sub}"` as `s"\${ var1 } \${ var2.sub
16-
* }"`.
21+
* If true, formats
22+
* {{{
23+
* s"\${var1} \${var2.sub}"
24+
* }}}
25+
* as
26+
* {{{
27+
* s"\${ var1 } \${ var2.sub }"
28+
* }}}
1729
* @param inParentheses
1830
* If true, formats `foo(a, b)` as `foo( a, b )`.
1931
* @param neverAroundInfixTypes
20-
* If ["##"] is specified as operator then formats `Generic[Foo] ## Repr` as
21-
* `Generic[Foo]##Repr`.
32+
* If ["##"] is specified as operator then formats {{{Generic[Foo] ## Repr}}}
33+
* as {{{Generic[Foo]##Repr}}}.
2234
* @param afterKeywordBeforeParen
2335
* if false, does not add a space between a keyword and a parenthesis. For
24-
* example: if(a) println("HELLO!") while(a) println("HELLO!")
36+
* example:
37+
* {{{
38+
* if(a) println("HELLO!")
39+
* while(a) println("HELLO!")
40+
* }}}
2541
* @param inByNameTypes
26-
* If false, removes space in by-name parameter. `def foo(a: =>A)`
42+
* If false, removes space in by-name parameter: {{{def foo(a: =>A)}}}
2743
* @param afterSymbolicDefs
28-
* If true, adds a single space after an operator method For example: def <=>
29-
* [T](that: T): Boolean
44+
* If true, adds a single space after an operator method. For example:
45+
* {{{def <=> [T](that: T): Boolean}}}
3046
*/
3147
case class Spaces(
3248
beforeContextBoundColon: Spaces.BeforeContextBound =

scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Indent.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ object Length {
3636
/** Indent up to the column of the left token.
3737
*
3838
* Example: the opening parenthesis below indents by [[StateColumn]].
39-
*
40-
* foobar(arg1, arg2)
39+
* {{{
40+
* foobar1(arg1,
41+
* arg2)
42+
* }}}
4143
*/
4244
case object StateColumn extends Length {
4345
override def withStateOffset(offset: Int): Int = offset

0 commit comments

Comments
 (0)