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 ability to parse line breaks into <br/> for Docgen description in… #2053
Add ability to parse line breaks into <br/> for Docgen description in… #2053
Conversation
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PropTable multiLineText should have 2 br tags for 3 lines of text 1`] = ` | ||
Array [ |
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.
ESlint rules seem to prevent these from being one line each
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.
Eslint shouldn't do anything with js.snap files. Please check your editor settings
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.
It's actually this that ESlint doesn't want me to make a 1 liner. https://github.com/storybooks/storybook/pull/2053/files#diff-93c8453ec93a245a8bc84801b42540c7R96. That is causing this snapshot to be so big (not that that really matters)
adfd81a
to
1fe6754
Compare
1fe6754
to
6273258
Compare
Codecov Report
@@ Coverage Diff @@
## release/3.3 #2053 +/- ##
===============================================
+ Coverage 22.3% 22.33% +0.03%
===============================================
Files 326 326
Lines 6537 6555 +18
Branches 810 829 +19
===============================================
+ Hits 1458 1464 +6
+ Misses 4476 4474 -2
- Partials 603 617 +14
Continue to review full report at Codecov.
|
@@ -82,6 +82,22 @@ const propsFromPropTypes = type => { | |||
return props; | |||
}; | |||
|
|||
export const multiLineText = text => { | |||
if (!text) return ''; |
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.
Does anyone have a preference here to return null
and therefore render <td/>
versus an empty string(''
) and <td></td>
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 think I'd prefer the short version
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.
👍
@@ -82,6 +82,22 @@ const propsFromPropTypes = type => { | |||
return props; | |||
}; | |||
|
|||
export const multiLineText = text => { | |||
if (!text) return ''; | |||
const arrayOfText = text.replace(/\r?\n|\r/g, '--newline--').split('--newline--'); |
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.
Why not just split on global regexp?
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.
Done
… rather than return an empty string
Please update test snapshot and merge as soon as CI jobs pass |
Will do when I get home tonight |
Awesome, great work @dangreenisrael !! 💪 |
Issue: #1311
What I did
Added automatic parsing of line breaks into
<br/>
for the Docgen descriptions. I opted for this route over full blown parsing markdown to prevent any weird formatting issues with the table.How to test
Is this testable with jest or storyshots?
This is fully tested with jest
Does this need a new example in the kitchen sink apps?
The Docgen button was updated
Does this need an update to the documentation?
No