From 6e790fcc4a16cbf6a77cfb0df539081271214562 Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Thu, 14 Sep 2023 14:36:24 +0530 Subject: [PATCH] rename renderInline method to renderMarkdown --- .../pages/production-error/ErrorDecoder.js | 4 ++-- .../ApiBuilders/ComponentApiBuilder.ts | 23 +++++++++---------- .../ApiBuilders/HookApiBuilder.ts | 11 ++++----- packages/markdown/index.d.ts | 2 +- packages/markdown/index.js | 4 ++-- packages/markdown/parseMarkdown.js | 4 ++-- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/docs/src/pages/production-error/ErrorDecoder.js b/docs/src/pages/production-error/ErrorDecoder.js index e8f59535a8a0df..8231ebe61074dc 100644 --- a/docs/src/pages/production-error/ErrorDecoder.js +++ b/docs/src/pages/production-error/ErrorDecoder.js @@ -3,7 +3,7 @@ import { useRouter } from 'next/router'; import Link from '@mui/material/Link'; import Typography from '@mui/material/Typography'; import { styled } from '@mui/material/styles'; -import { renderInline as renderInlineMarkdown } from '@mui/markdown'; +import { renderMarkdown } from '@mui/markdown'; import MarkdownElement from 'docs/src/modules/components/MarkdownElement'; const ErrorMessageSection = styled('div')({ @@ -86,7 +86,7 @@ export default function ErrorDecoder() { return div.innerHTML; }); - return renderInlineMarkdown(readableMessage); + return renderMarkdown(readableMessage); }, [args, code, data.errorCodes]); if (data.state === 'loading') { diff --git a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts index bdacad4cfe08bc..59b348d8d09192 100644 --- a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts @@ -10,7 +10,7 @@ import remarkVisit from 'unist-util-visit'; import { Link } from 'mdast'; import { defaultHandlers, parse as docgenParse, ReactDocgenApi } from 'react-docgen'; import { unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils'; -import { renderInline as renderMarkdownInline } from '@mui/markdown'; +import { renderMarkdown } from '@mui/markdown'; import { LANGUAGES } from 'docs/config'; import { ComponentInfo, writePrettifiedFile } from '../buildApiUtils'; import muiDefaultPropsHandler from '../utils/defaultPropsHandler'; @@ -333,19 +333,19 @@ function extractClassConditions(descriptions: any) { if (conditions && conditions[6]) { classConditions[className] = { - description: renderMarkdownInline( + description: renderMarkdown( description.replace(stylesRegex, '$1{{nodeName}}$5{{conditions}}.'), ), - nodeName: renderMarkdownInline(conditions[3]), - conditions: renderMarkdownInline(conditions[6].replace(/`(.*?)`/g, '$1')), + nodeName: renderMarkdown(conditions[3]), + conditions: renderMarkdown(conditions[6].replace(/`(.*?)`/g, '$1')), }; } else if (conditions && conditions[3] && conditions[3] !== 'the root element') { classConditions[className] = { - description: renderMarkdownInline(description.replace(stylesRegex, '$1{{nodeName}}$5.')), - nodeName: renderMarkdownInline(conditions[3]), + description: renderMarkdown(description.replace(stylesRegex, '$1{{nodeName}}$5.')), + nodeName: renderMarkdown(conditions[3]), }; } else { - classConditions[className] = { description: renderMarkdownInline(description) }; + classConditions[className] = { description: renderMarkdown(description) }; } } }); @@ -517,13 +517,13 @@ const attachTranslations = (reactApi: ReactApi) => { const typeDescriptions: { [t: string]: string } = {}; (signatureArgs || []).concat(signatureReturn || []).forEach(({ name, description }) => { - typeDescriptions[name] = renderMarkdownInline(description); + typeDescriptions[name] = renderMarkdown(description); }); translations.propDescriptions[propName] = { - description: renderMarkdownInline(jsDocText), + description: renderMarkdown(jsDocText), requiresRef: requiresRef || undefined, - deprecated: renderMarkdownInline(deprecated) || undefined, + deprecated: renderMarkdown(deprecated) || undefined, typeDescriptions: Object.keys(typeDescriptions).length > 0 ? typeDescriptions : undefined, }; } @@ -631,8 +631,7 @@ const attachPropsTable = (reactApi: ReactApi) => { // undefined values are not serialized => saving some bytes required: requiredProp || undefined, deprecated: !!deprecation || undefined, - deprecationInfo: - renderMarkdownInline(deprecation?.groups?.info || '').trim() || undefined, + deprecationInfo: renderMarkdown(deprecation?.groups?.info || '').trim() || undefined, signature, additionalInfo: Object.keys(additionalPropsInfo).length === 0 ? undefined : additionalPropsInfo, diff --git a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts index fcdce26439932e..84b6758daae330 100644 --- a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts @@ -8,7 +8,7 @@ import traverse from '@babel/traverse'; import { defaultHandlers, parse as docgenParse, ReactDocgenApi } from 'react-docgen'; import kebabCase from 'lodash/kebabCase'; import upperFirst from 'lodash/upperFirst'; -import { renderInline as renderMarkdownInline } from '@mui/markdown'; +import { renderMarkdown } from '@mui/markdown'; import { LANGUAGES } from 'docs/config'; import { toGitHubPath, computeApiDescription } from './ComponentApiBuilder'; import { @@ -328,8 +328,7 @@ const attachTable = ( // undefined values are not serialized => saving some bytes required: requiredProp || undefined, deprecated: !!deprecation || undefined, - deprecationInfo: - renderMarkdownInline(deprecation?.groups?.info || '').trim() || undefined, + deprecationInfo: renderMarkdown(deprecation?.groups?.info || '').trim() || undefined, }, }; }) @@ -351,7 +350,7 @@ const attachTable = ( }; const generateTranslationDescription = (description: string) => { - return renderMarkdownInline(description.replace(/\n@default.*$/, '')); + return renderMarkdown(description.replace(/\n@default.*$/, '')); }; const attachTranslations = (reactApi: ReactApi) => { @@ -369,7 +368,7 @@ const attachTranslations = (reactApi: ReactApi) => { const deprecation = (description || '').match(/@deprecated(\s+(?.*))?/); if (deprecation !== null) { translations.parametersDescriptions[propName].deprecated = - renderMarkdownInline(deprecation?.groups?.info || '').trim() || undefined; + renderMarkdown(deprecation?.groups?.info || '').trim() || undefined; } } }); @@ -382,7 +381,7 @@ const attachTranslations = (reactApi: ReactApi) => { const deprecation = (description || '').match(/@deprecated(\s+(?.*))?/); if (deprecation !== null) { translations.parametersDescriptions[propName].deprecated = - renderMarkdownInline(deprecation?.groups?.info || '').trim() || undefined; + renderMarkdown(deprecation?.groups?.info || '').trim() || undefined; } } }); diff --git a/packages/markdown/index.d.ts b/packages/markdown/index.d.ts index 7f8047214d32e8..a5f9e850f5fe43 100644 --- a/packages/markdown/index.d.ts +++ b/packages/markdown/index.d.ts @@ -16,4 +16,4 @@ export function getHeaders(markdown: string): Record; export function getTitle(markdown: string): string; -export function renderInline(markdown: string): string; +export function renderMarkdown(markdown: string): string; diff --git a/packages/markdown/index.js b/packages/markdown/index.js index af4f8ce269fea1..35b45995fa51c4 100644 --- a/packages/markdown/index.js +++ b/packages/markdown/index.js @@ -1,3 +1,3 @@ -const { createRender, getHeaders, getTitle, renderInline } = require('./parseMarkdown'); +const { createRender, getHeaders, getTitle, renderMarkdown } = require('./parseMarkdown'); -module.exports = { createRender, getHeaders, getTitle, renderInline }; +module.exports = { createRender, getHeaders, getTitle, renderMarkdown }; diff --git a/packages/markdown/parseMarkdown.js b/packages/markdown/parseMarkdown.js index 79e06d19100656..dd58a4aca927ba 100644 --- a/packages/markdown/parseMarkdown.js +++ b/packages/markdown/parseMarkdown.js @@ -234,7 +234,7 @@ function getCodeblock(content) { /** * @param {string} markdown */ -function renderInline(markdown) { +function renderMarkdown(markdown) { // Check if the markdown contains an inline list. Unordered lists are block elements and cannot be parsed inline. if (/[-*+] `([A-Za-z]+)`/g.test(markdown)) { return marked.parse(markdown, markedOptions); @@ -475,5 +475,5 @@ module.exports = { getCodeblock, getHeaders, getTitle, - renderInline, + renderMarkdown, };