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
Add Scaladoc tables #6043
Add Scaladoc tables #6043
Conversation
This is an example of table markdown which includes all types of supported marks,
The unit test contains additional examples which include examples of multiline caption, header and cell content using inline wiki styling. Tables cannot contain other block elements. At this point I've dealt with all the defects I could anticipate with the exception of one described below in Known Issues. I'l like to get this out to a wider audience now so the next set of defects can be found. Known IssuesAlthough it could be charitably regarded as adherent to the "spec" the markdown parsing does not tolerate leading whitespace before marks. To avoid wasting user time a subsequent PR will allow this to parse.
Supporting this may require an extension to the Backlogged as a fast follower: scala/bug#10475 CSS StylingThe styling is a call to action for anyone with a passion for css. I will submit a PR if there is no interest from other quarters. Follow on actions include
|
cb5839c
to
7d9fd51
Compare
Cool! I'd prefer using GitHub-flavored markdown, as we do everywhere else. What do you think? From https://guides.github.com/features/mastering-markdown/
|
I surveyed a few markdown systems here: https://github.com/janekdb/scala/wiki/Table-Markdown-Survey I believe the MediaWiki style markdown is easier to work with having used both GH and MW. It requires less attention to syntax than GH flavoured markdown and has the benefit of supporting vertical layout of cells in addition to horizontal layout which will work well with larger runs of inline markdown. MW can do everything GH can do AFAIK with less fiddling so I think it should be preferred. Putting the choice into context here are the requirements I evaluated the markdown options against: https://github.com/janekdb/scala/wiki/Scaladoc-Tables-Requirements |
My opinion is that there's a strong case for standardization here, with feature completeness being a bit less urgent of a concern. Using GitHub markdown also makes it easier to preview |
In general I agree to bias towards GFM, but here maybe the limitations are too severe?
Would it be OK adapt GFM to our needs? On the other hand, the current proposal doesn't have functionality for left/center/right alignment. I played a bit with the current state. One thing that's annoying for small tables is that each row requires a
It actually works without the first A detail in presentation: if two tables follow each other, the are sticked together. Maybe every table should be wrapped in a The caption and header colors cold be a little less flashy :-) I didn't get code blocks ( |
@lrytz —
I have some views to share regarding GHFM or not, just need a bit of time to write them down. Thanks for the feedback. I am surprised the example was parsed but getting some feedback was the purpose of the PR! |
OK, thanks for the clarifications! I definitely think that allowing to use multiple lines for a cell's content (or even a row's) is very important. Otherwise the usefulness of this new feature would be severely limited. I guess a good source of real-world examples is scalatest's scaladoc, searching for Example: http://doc.scalatest.org/3.0.0/index.html#org.scalatest.AsyncFunSuite |
@lrytz — The identification of these pre-existing table is super useful. This will allow for some concrete feature validation. I will take a look over the next few days. |
@janekdb, which version would you like to schedule this for? For 2.12.4, the PR must be mergeable by Wed Sep 27 |
@adriaanm — 2.12.5 as it needs rethinking to accommodate,
|
a7d5962
to
11312cb
Compare
8668b21
to
8d27dfb
Compare
Not forgotten. Making gradual progress on more compact row markdown. Example of a three row table not using the
84/84 tests enabled and passing with new more-GHFM compact row markdown using cleaner parsing approach. |
7d72ba9
to
440bb46
Compare
1423ff5
to
4be8d29
Compare
and
|
All positive and negative tests passing locally, The parsing outcomes known to be incorrect are captured as-is in these test cases,
I'm intending to address these as fast follower bug fixes after this PR is merged. Outstanding work,
I'll need to do justice to those points tonight. Update: The CI build found two cases of incompatibility with the Scaladoc in this project, TreeInfo.scala
MarkupParsers.scala
Tables should only be recognized when the initial pipe is blocked to the left. There might be some whitespace trimming occurring that is causing this. For now I've removed the line breaks which I realise simply hides the problem. Update: TreeInfo and MarkupParsers have been restored and initial ws trimming removed,
This implementation of tables assumed blocking to the left, which reduces the chances of parsing non-table markdown. Leading whitespace being allowed on the first row was inconsistent with that. Allowing leading whitespaces on any row appears to be allowed by the GHFM table spec but will cause incompatibilities as we've seen. I will take this one as bug fix b/c it will require some thought and testing. One approach is to lookahead and require the line following the initial table row to be a delimiter row. This will head off any incompatibilities with Scaladoc found in the community I'm sure. |
b2e2794
to
d931e23
Compare
66d5edb
to
7f070e3
Compare
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! This is good to go once you're done with squashing and cleaning up.
|
||
val inlineTerminators = makeInlineTerminators(startMark) | ||
|
||
val content = Paragraph(inline(isInlineEnd = checkAny(inlineTerminators))) |
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.
Is it true that all terminators are single chars? Then this could be made more efficient by just checking the buffer's current char
instead of calling check
many times. (We can do this in a follow-up PR). A first simple improvement would be to test in check
if the chars
string has length 1, and avoid calling jump
in that case.
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'm doing the clean up now so will look at this.
6c5675c
to
ac6371b
Compare
Based on GitHub Flavored Markdown Spec, https://github.github.com/gfm/#tables-extension- Version 0.28-gfm (2017-08-01) A table is a block element consisting of, * A header row * A delimiter row separating the header from the data * Zero or more data rows Restrictions, Rows must begin and end with pipe symbols A blank line required after table Limitations, Escaping of pipe symbols is not yet supported Inline markdown can be used in header and data cells, block markdown cannot be used. Example, /** * |Nibbles|Main|Desert| * |:--:|:---:|----| * |Bread|Yak|Vodka| * |Figs|Cheese on toast^three ways^|Coffee| */ trait RepastOptions The accepted markdown is intended to be a strict subset of all possible GHFM tables.
ac6371b
to
5a72d7b
Compare
@lrytz - This is the merge candidate. Last actions,
Not done,
Every known instance of suboptimal parsing has a test case. This will make it easy to continue with the edge cases following merge. Compared to the pre-GHFM version this had only light testing, however in balance the parsing code is much simpler thanks to the stricter requirements. The community build @SethTisue will give us more information about how well this copes with existing markdown. I lay my offering down at the side of the lake and hope when the morning comes to see it gone. |
We gratefully and humbly accept your offerings! I have stood (by the sidelines) in awe at your diligence. |
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.
🚀
Phew! Thanks for everyone's help and patience. I'll remind myself to get early community feedback before I next plot a course. |
scala/community-build@69bca5e moves to a Scala SHA that includes this PR, so we'll know by tomorrow if anything blows up |
@janekdb I would like to tweet about this feature from https://twitter.com/scala_lang (and credit you by name when we do so). do you have a tweet about it I could quote-tweet? (and/or could you propose a screenshot to include?) |
@SethTisue How about this screenshot lifted from the forthcoming blog post You can crop off the intitial text leaving just the markdown and the table if you like. My tweet: https://twitter.com/janekdb/status/1045742653822955520 |
@SethTisue Here's a couple of alternative images, |
@janekdb I forgot about your blog post draft. rather than tweeting now, how about we publish the blog post and publicize the feature that way (including on Twitter)? |
@SethTisue Blog post is done pending review: scala/scala-lang#959 |
Parse a subset of GitHub flavoured markdown to define simple tables which can include inline wiki markdown. The specification for the table markdown is based on GitHub Flavored Markdown Spec, Version 0.28-gfm (2017-08-01).
The markdown used to structure the table follows GitHub Flavoured Markdown Table Extension with the restriction that pipe symbols at the start and end of row are mandatory and the clarification that delimiter row cells must have a minimum of three hyphens.
Note: Most of the following is irrelevant now the markdown is GHFM based..
Example.
A simple 2x2 table with a caption and header row,
Header and cell markdown can be repeated at the start of the heaer or row to allow | and ! to be included in content,
Fuller example including longer cell marks,
Caption, header and cell content can be broken over multiple lines and
include paragraphs and inline markdown,
Block level elements other than paragraphs are not yet parsed. Specifically these types are not yet supported,
A warning is issued when the rows and optional header do not all have the same number of cells.
This reserves an option to do something "wiki-ish" when cell counts differ.
Inspired by MediaWiki markdown with new row conciseness following GitHub flavoured markdown.
GitHub Project with subtasks: https://github.com/janekdb/scala/projects/1
Live Demo
http://janekdb.github.io/scala/PR-6043/scala/test/scaladoc/tables/code/index.html
This page contains the unit test tables with the table markdown duplicated into a code block,
I'm hoping this makes it easier to review the PR and also furnishes a good idea of what you get for what you give.
PR Status
WIP
Review Comments
TODO: Move to GHFM
TODO: Support multiline content cell with GHFM extension
TODO
table-warnings.check
parseCells0
Caption
asSeq[Block]
matchingCell
.CellsParagraphsB
and friends|-
because final cell termination is sufficientisNewlineAnyTableMarks
or the duplicateWONT
Acceptance Testing
Review
Target Outcome Over the Course of a few PRs :)
Follow Ons