Skip to content

Scaladoc removes indentation of first line, making code incorrect #21429

Closed
@JD557

Description

@JD557

Compiler version

3.5.0

Minimized code

See for example

```scala
trait Ord:
type Self
trait SemiGroup:
type Self
extension (x: Self) def combine(y: Self): Self
trait Monoid extends SemiGroup:
def unit: Self
object Monoid:
def unit[M](using m: Monoid { type Self = M}): M
trait Functor:
type Self[A]
extension [A](x: Self[A]) def map[B](f: A => B): Self[B]
trait Monad extends Functor:
def pure[A](x: A): Self[A]
extension [A](x: Self[A])
def flatMap[B](f: A => Self[B]): Self[B]
def map[B](f: A => B) = x.flatMap(f `andThen` pure)
def reduce[A: Monoid](xs: List[A]): A =
xs.foldLeft(Monoid.unit)(_ `combine` _)
trait ParserCombinator:
type Self
type Input
type Result
extension (self: Self)
def parse(input: Input): Option[Result] = ...
def combine[A: ParserCombinator, B: ParserCombinator { type Input = A.Input }] = ...
```

or

```scala
given Int is Ord ...
given Int is Monoid ...
type Reader = [X] =>> Env => X
given Reader is Monad ...
object Monoid:
def unit[M](using m: M is Monoid): M
```

Output

imagem

Which is copied as:

trait Ord:
    type Self

  trait SemiGroup:
    type Self
    extension (x: Self) def combine(y: Self): Self

  trait Monoid extends SemiGroup:
    def unit: Self
  object Monoid:
    def unit[M](using m: Monoid { type Self = M}): M

  trait Functor:
    type Self[A]
    extension [A](x: Self[A]) def map[B](f: A => B): Self[B]

  trait Monad extends Functor:
    def pure[A](x: A): Self[A]
    extension [A](x: Self[A])
      def flatMap[B](f: A => Self[B]): Self[B]
      def map[B](f: A => B) = x.flatMap(f `andThen` pure)

  def reduce[A: Monoid](xs: List[A]): A =
    xs.foldLeft(Monoid.unit)(_ `combine` _)

  trait ParserCombinator:
    type Self
    type Input
    type Result
    extension (self: Self)
      def parse(input: Input): Option[Result] = ...

  def combine[A: ParserCombinator, B: ParserCombinator { type Input = A.Input }] = ...

or

imagem

which is copied as

given Int is Ord ...
  given Int is Monoid ...

  type Reader = [X] =>> Env => X
  given Reader is Monad ...

  object Monoid:
    def unit[M](using m: M is Monoid): M

Expectation

I would expect the code to show (and be copied) just as it was written in the markdown.
Either keep the indentation for all lines or remove the indentation from all lines by the same amount.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions