Skip to content

Commit

Permalink
Fix documentation class-signature (#2729)
Browse files Browse the repository at this point in the history
Closes #2713
  • Loading branch information
paul-dingemans committed Jul 2, 2024
1 parent 91d8d44 commit 17a240d
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 56 deletions.
85 changes: 57 additions & 28 deletions documentation/release-latest/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,62 +462,80 @@ The other code styles allow an infinite amount of parameters on the same line (a
// Assume that the last allowed character is
// at the X character on the right X
class Foo0


// Entire class signature does not fit on single line
class Foo1(
a: Any,
aVeryLonggggggggggggggggggggggg: Any
)


// Entire class signature does fit on single line
class Foo2(a: Any)


// Entire class signature does not fit on single line
class Foo3(
a: Any,
b: Any,
aVeryLonggggggggggggggg: Any,
b: Any
)


// Entire class signature does fit on single line
class Foo4(a: Any, b: Any)


// Entire class signature does fit on single line
class Foo5(@Foo a: Any, b: Any, c: Any)


// Entire class signature does fit on single line
class Foo6(a: Any, b: Any, c: Any) :
FooBar(a, c)

class Foo7 : FooBar(
"bar1",
"bar2",
) {

// Entire class signature (without constructor invocation) does fit on single line
class Foo7 :
FooBar(
"bar1",
"bar2"
) {
// body
}
class Foo8(
val bar1: Bar,
val bar2: Bar,
) : FooBar(
bar1,
bar2
) {

// Entire class signature (without constructor invocation) does fit on single line
class Foo8(val bar1: Bar, val bar2: Bar) :
FooBar(
bar1,
bar2
) {
// body
}


// Entire class signature (without constructor invocation) does not fit on single line
class Foo9(
val bar1: Bar,
val bar2: Bar,
val aVeryLonggggggggggggggg: Bar,
val bar2: Bar
) : FooBar(
bar1,
bar2
),
) {
// body
}

class Foo10(val bar1: Bar, val bar2: Bar) :
FooBar(
bar1,
bar2
),
BarFoo1,
BarFoo2 {
// body
}

class Foo10
class Foo11
constructor(
val bar1: Bar,
val bar2: Bar,
val bar2: Bar
) : FooBar(bar1, bar2),
BarFoo1,
BarFoo2 {
// body
}

```

=== "[:material-heart-off-outline:](#) Disallowed (non ktlint_official)"
Expand All @@ -528,6 +546,14 @@ The other code styles allow an infinite amount of parameters on the same line (a
class Foo0()

class Foo6(a: Any, b: Any, c: Any) : FooBar(a, c)

// Entire class signature (without constructor invocation) does fit on single line
class Foo7 : FooBar(
"bar1",
"bar2",
) {
// body
}
```

| Configuration setting | ktlint_official | intellij_idea | android_studio |
Expand All @@ -536,6 +562,9 @@ The other code styles allow an infinite amount of parameters on the same line (a

Rule id: `standard:class-signature`

!!! warn
For code styles `android_studio` and `intellij_idea` this rule rewrites multiline class signature to a single line class signature in case the entire class signature fits on a single line by default. In case you want to leave it to the discretion of the developer to decider whether a single or a multiline class signature is used, please suppress or disable this rule.

Suppress or disable rule (1)
{ .annotate }

Expand Down
85 changes: 57 additions & 28 deletions documentation/snapshot/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,62 +462,80 @@ The other code styles allow an infinite amount of parameters on the same line (a
// Assume that the last allowed character is
// at the X character on the right X
class Foo0


// Entire class signature does not fit on single line
class Foo1(
a: Any,
aVeryLonggggggggggggggggggggggg: Any
)


// Entire class signature does fit on single line
class Foo2(a: Any)


// Entire class signature does not fit on single line
class Foo3(
a: Any,
b: Any,
aVeryLonggggggggggggggg: Any,
b: Any
)


// Entire class signature does fit on single line
class Foo4(a: Any, b: Any)


// Entire class signature does fit on single line
class Foo5(@Foo a: Any, b: Any, c: Any)


// Entire class signature does fit on single line
class Foo6(a: Any, b: Any, c: Any) :
FooBar(a, c)

class Foo7 : FooBar(
"bar1",
"bar2",
) {

// Entire class signature (without constructor invocation) does fit on single line
class Foo7 :
FooBar(
"bar1",
"bar2"
) {
// body
}
class Foo8(
val bar1: Bar,
val bar2: Bar,
) : FooBar(
bar1,
bar2
) {

// Entire class signature (without constructor invocation) does fit on single line
class Foo8(val bar1: Bar, val bar2: Bar) :
FooBar(
bar1,
bar2
) {
// body
}


// Entire class signature (without constructor invocation) does not fit on single line
class Foo9(
val bar1: Bar,
val bar2: Bar,
val aVeryLonggggggggggggggg: Bar,
val bar2: Bar
) : FooBar(
bar1,
bar2
),
) {
// body
}

class Foo10(val bar1: Bar, val bar2: Bar) :
FooBar(
bar1,
bar2
),
BarFoo1,
BarFoo2 {
// body
}

class Foo10
class Foo11
constructor(
val bar1: Bar,
val bar2: Bar,
val bar2: Bar
) : FooBar(bar1, bar2),
BarFoo1,
BarFoo2 {
// body
}

```

=== "[:material-heart-off-outline:](#) Disallowed (non ktlint_official)"
Expand All @@ -528,6 +546,14 @@ The other code styles allow an infinite amount of parameters on the same line (a
class Foo0()

class Foo6(a: Any, b: Any, c: Any) : FooBar(a, c)

// Entire class signature (without constructor invocation) does fit on single line
class Foo7 : FooBar(
"bar1",
"bar2",
) {
// body
}
```

| Configuration setting | ktlint_official | intellij_idea | android_studio |
Expand All @@ -536,6 +562,9 @@ The other code styles allow an infinite amount of parameters on the same line (a

Rule id: `standard:class-signature`

!!! warn
For code styles `android_studio` and `intellij_idea` this rule rewrites multiline class signature to a single line class signature in case the entire class signature fits on a single line by default. In case you want to leave it to the discretion of the developer to decider whether a single or a multiline class signature is used, please suppress or disable this rule.

Suppress or disable rule (1)
{ .annotate }

Expand Down

0 comments on commit 17a240d

Please sign in to comment.