scalameta / mdoc

Typechecked markdown documentation for Scala
https://scalameta.org/mdoc/
Apache License 2.0
395 stars 81 forks source link

support clipping (or scrolling) long errors #662

Open erikerlandson opened 2 years ago

erikerlandson commented 2 years ago

I have a code block that creates an error, but the long length of the error is a bit distracting. Is there a way to tell mdoc to clip the error message to the first n lines, or just tell it to have a maximum code block height, with a scroll bar? Setting something like mdoc:height=10 doesn't fix this particular problem.

Screen-shot of my long error:

image

erikerlandson commented 2 years ago

cc @armanbilge

armanbilge commented 2 years ago

@erikerlandson do you have a branch I can look at? We can support this at the rendering level by adding a custom CSS style.

Basically something like this:

pre {
  max-height: 100px;
  overflow: scroll;
}
erikerlandson commented 2 years ago

@armanbilge latest is merged into scala3 branch: https://github.com/erikerlandson/coulomb/blob/scala3/docs/index.md

armanbilge commented 2 years ago
erikerlandson commented 2 years ago

@armanbilge thanks!

For reference, what I ultimately ended up doing was this:

/* when mdoc renders "long" comments, clip them and provide a scrollbar */
.comment {
  /* set display as block or the other settings don't work */
  display: block;
  /* most comments are short, and display normally */
  max-height: 100px;
  /* add a scrollbar only when necessary */
  overflow: auto;
}

Which adds a scrollbar only for "long" comments, like this:

image

erikerlandson commented 2 years ago

Might be useful to have a special class for "multi-line-comment" or "mdoc-output-comment" to distinguish between comments the programmer wrote and comments generated by mdoc itself.

Or some new mdoc tag. ```scala mdoc:maxoutputlines=3:overflow=scroll:fail

erikerlandson commented 2 years ago

Possibly not related but now seeing this strange behavior: https://github.com/erikerlandson/coulomb/issues/309