Skip to content

Commit

Permalink
fix(okidoc-md): use unist-builder@1.0.2.
Browse files Browse the repository at this point in the history
- fix `unist-builder` usages
- update `@depracated` rendering
  • Loading branch information
bodia-uz committed Aug 20, 2018
1 parent add6a3e commit efd9d46
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/okidoc-md/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"precinct": "^4.0.0",
"remark": "^9.0.0",
"remark-html": "^7.0.0",
"unist-builder": "1.0.2",
"unist-builder": "^1.0.3",
"yamljs": "^0.3.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ exports[`buildMarkdown for API class should render markdown for methods with @de
## doShow()
DEPRECATED!
**DEPRECATED!**
use method \`show()\`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import remark from 'remark';

function parseMarkdown(markdown) {
return remark().parse(markdown);
const markdownAST = remark().parse(markdown);

// NOTE: unwrap from `root` node
if (markdownAST.children.length === 1) {
return markdownAST.children[0];
}

return {
type: 'paragraph',
children: markdownAST.children,
};
}

export default parseMarkdown;
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ function renderExamplesAndNotes(comment) {
return memo.concat(
exampleCaption
? [
u('blockquote', parseMarkdown(exampleCaption)),
u('blockquote', [parseMarkdown(exampleCaption)]),
u('code', { lang: 'javascript' }, exampleCode),
]
: [u('code', { lang: 'javascript' }, exampleCode)],
);
}

if (tag.title === 'note') {
return memo.concat([u('blockquote', parseMarkdown(tag.description))]);
return memo.concat([u('blockquote', [parseMarkdown(tag.description)])]);
}

return memo;
Expand All @@ -100,7 +100,9 @@ function renderExamplesAndNotes(comment) {
function renderDeprecated(comment) {
return (
!!comment.deprecated &&
[u('text', u('strong', 'DEPRECATED!'))].concat(comment.deprecated.children)
[u('strong', [u('text', 'DEPRECATED!')])].concat(
comment.deprecated.children,
)
);
}

Expand Down

0 comments on commit efd9d46

Please sign in to comment.