New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaladoc: implement parsing of tables #2059
Conversation
989228f
to
0617139
Compare
scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
Outdated
Show resolved
Hide resolved
tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
Outdated
Show resolved
Hide resolved
@olafurpg any other modifications you could suggest? otherwise, I'd merge, tag and add to the formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Feel free to merge and cut a new release, just two minor comments. It would be good to ensure that there are no unexpected exceptions for example for empty header alignment rows
|a|
||
val delimLine = hspaces0 ~ CharsWhileIn("+-") | ||
val sep = nl ~ (delimLine ~ nl).rep ~ tableSpaceSep | ||
val table = row.rep(2, sep = sep).map { x => | ||
val rest = x.tail.map(_.map(_.trim)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know x
is always non-empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will add a test but if i read the .rep(2)
above correctly, it should have at least 2 elements.
scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Feel free to merge and cut a new release, just two minor comments. It would be good to ensure that there are no unexpected exceptions for example for empty header alignment rows
|a| ||
these two should not be parsed as a table, will test.
scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
Outdated
Show resolved
Hide resolved
val delimLine = hspaces0 ~ CharsWhileIn("+-") | ||
val sep = nl ~ (delimLine ~ nl).rep ~ tableSpaceSep | ||
val table = row.rep(2, sep = sep).map { x => | ||
val rest = x.tail.map(_.map(_.trim)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will add a test but if i read the .rep(2)
above correctly, it should have at least 2 elements.
https://www.scala-lang.org/blog/2018/10/04/scaladoc-tables.html