Skip to content

Commit

Permalink
fix: add printWidth to description markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmd committed Jan 7, 2021
1 parent cd0e55f commit 754031f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/descriptionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function formatDescription(
text = format(text, {
...options,
parser: "markdown",
printWidth: printWidth - column,
}).trim();

if (isAddedFakeDash) {
Expand Down
21 changes: 19 additions & 2 deletions tests/__snapshots__/paragraph.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ exports[`description contain paragraph 4`] = `
exports[`description new line with dash 1`] = `
"/**
* We will allow the scroll view to give up its lock iff it acquired the lock
* during an animation. This is a very useful default that happens to satisfy
* many common user experiences.
* during an - animation. This is a very useful default that happens to
* satisfy many common user experiences.
*
* - Stop a scroll on the left edge, then turn that into an outer view's backswipe.
* - Stop a scroll mid-bounce at the top, continue pulling to have the outer view dismiss.
Expand Down Expand Up @@ -215,6 +215,23 @@ function scrollResponderHandleTerminationRequest() {
"
`;
exports[`description new line with dash 2`] = `
"/**
* Measures the \`HitRect\` node on activation. The Bounding rectangle is with
* respect to viewport - not page, so adding the \`pageXOffset/pageYOffset\`
* should result in points that are in the same coordinate system as an
* event's \`globalX/globalY\` data values.
*
* - Consider caching this for the lifetime of the component, or possibly being
* able to share this cache between any \`ScrollMap\` view.
*
* @private
*
* @sideeffects
*/
"
`;
exports[`numbers and code in description 1`] = `
"/**
* =========================== PressResponder Tutorial ===========================
Expand Down
30 changes: 28 additions & 2 deletions tests/paragraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test("description new line with dash", () => {
const result1 = subject(`
/**
* We will allow the scroll view to give up its lock iff it acquired the lock
* during an animation. This is a very useful default that happens to satisfy
* during an - animation. This is a very useful default that happens to satisfy
* many common user experiences.
*
* - Stop a scroll on the left edge, then turn that into an outer view's
Expand Down Expand Up @@ -127,8 +127,25 @@ test("description new line with dash", () => {
return !this.state.observedScrollSinceBecomingResponder;
}
`);

expect(result1).toMatchSnapshot();

const result2 = subject(`
/**
* Measures the \`HitRect\` node on activation. The Bounding rectangle is with
* respect to viewport - not page, so adding the \`pageXOffset/pageYOffset\`
* should result in points that are in the same coordinate system as an
* event's \`globalX/globalY\` data values.
*
* - Consider caching this for the lifetime of the component, or possibly being able to share this
* cache between any \`ScrollMap\` view.
*
* @private
*
* @sideeffects
*/
`);

expect(result2).toMatchSnapshot();
});

test("numbers and code in description", () => {
Expand Down Expand Up @@ -298,3 +315,12 @@ test("code in description", () => {

expect(result1).toMatchSnapshot();
});

/**
* If this is a vertical ScrollView scrolls to the bottom.
* If this is a horizontal ScrollView scrolls to the right.
*
* Use `scrollToEnd({ animated: true })` for smooth animated scrolling,
* `scrollToEnd({ animated: false })` for immediate scrolling.
* If no options are passed, `animated` defaults to true.
*/

0 comments on commit 754031f

Please sign in to comment.