mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 03:49:43 +02:00
chore: Prettier
This commit is contained in:
@@ -85,7 +85,7 @@ const LOGMSG_COPIED = `, and copied to ${FINAL_DOCS_DIR}`;
|
||||
|
||||
const WARN_DOCSDIR_DOESNT_MATCH = `Changed files were transformed in ${SOURCE_DOCS_DIR} but do not match the files in ${FINAL_DOCS_DIR}. Please run 'pnpm --filter mermaid run docs:build' after making changes to ${SOURCE_DOCS_DIR} to update the ${FINAL_DOCS_DIR} directory with the transformed files.`;
|
||||
|
||||
const prettierConfig = prettier.resolveConfig.sync('.') ?? {};
|
||||
const prettierConfig = (await prettier.resolveConfig('.')) ?? {};
|
||||
// From https://github.com/vuejs/vitepress/blob/428eec3750d6b5648a77ac52d88128df0554d4d1/src/node/markdownToVue.ts#L20-L21
|
||||
const includesRE = /<!--\s*@include:\s*(.*?)\s*-->/g;
|
||||
const includedFiles: Set<string> = new Set();
|
||||
@@ -326,7 +326,7 @@ export function transformMarkdownAst({
|
||||
*
|
||||
* @param file {string} name of the file that will be verified
|
||||
*/
|
||||
const transformMarkdown = (file: string) => {
|
||||
const transformMarkdown = async (file: string) => {
|
||||
const doc = injectPlaceholders(transformIncludeStatements(file, readSyncedUTF8file(file)));
|
||||
|
||||
let transformed = remark()
|
||||
@@ -347,7 +347,7 @@ const transformMarkdown = (file: string) => {
|
||||
transformed = doc;
|
||||
}
|
||||
|
||||
const formatted = prettier.format(transformed, {
|
||||
const formatted = await prettier.format(transformed, {
|
||||
parser: 'markdown',
|
||||
...prettierConfig,
|
||||
});
|
||||
@@ -454,7 +454,7 @@ async function transformJsonSchema(file: string) {
|
||||
|
||||
const transformed = transformer.stringify(await transformer.run(markdownAst as Root));
|
||||
|
||||
const formatted = prettier.format(transformed, {
|
||||
const formatted = await prettier.format(transformed, {
|
||||
parser: 'markdown',
|
||||
...prettierConfig,
|
||||
});
|
||||
@@ -472,7 +472,7 @@ async function transformJsonSchema(file: string) {
|
||||
*
|
||||
* @param filename {string} name of the HTML file to transform
|
||||
*/
|
||||
const transformHtml = (filename: string) => {
|
||||
const transformHtml = async (filename: string) => {
|
||||
/**
|
||||
* Insert the '...auto generated...' comment into an HTML file after the<html> element
|
||||
*
|
||||
@@ -496,7 +496,7 @@ const transformHtml = (filename: string) => {
|
||||
};
|
||||
|
||||
const transformedHTML = insertAutoGeneratedComment(filename);
|
||||
const formattedHTML = prettier.format(transformedHTML, {
|
||||
const formattedHTML = await prettier.format(transformedHTML, {
|
||||
parser: 'html',
|
||||
...prettierConfig,
|
||||
});
|
||||
@@ -541,7 +541,7 @@ export const processDocs = async () => {
|
||||
const mdFileGlobs = getGlobs([posix.join(sourceDirGlob, '*.md')]);
|
||||
const mdFiles = await getFilesFromGlobs(mdFileGlobs);
|
||||
console.log(`${action} ${mdFiles.length} markdown files...`);
|
||||
mdFiles.forEach(transformMarkdown);
|
||||
await Promise.all(mdFiles.map(transformMarkdown));
|
||||
|
||||
for (const includedFile of includedFiles) {
|
||||
rmSync(includedFile, { force: true });
|
||||
@@ -552,7 +552,7 @@ export const processDocs = async () => {
|
||||
const htmlFileGlobs = getGlobs([posix.join(sourceDirGlob, '*.html')]);
|
||||
const htmlFiles = await getFilesFromGlobs(htmlFileGlobs);
|
||||
console.log(`${action} ${htmlFiles.length} html files...`);
|
||||
htmlFiles.forEach(transformHtml);
|
||||
await Promise.all(htmlFiles.map(transformHtml));
|
||||
|
||||
const otherFileGlobs = getGlobs([sourceDirGlob, '!**/*.md', '!**/*.html']);
|
||||
const otherFiles = await getFilesFromGlobs(otherFileGlobs);
|
||||
@@ -591,9 +591,9 @@ export const processDocs = async () => {
|
||||
return;
|
||||
}
|
||||
if (isMd(path)) {
|
||||
transformMarkdown(path);
|
||||
void transformMarkdown(path);
|
||||
} else if (isHtml(path)) {
|
||||
transformHtml(path);
|
||||
void transformHtml(path);
|
||||
} else if (isOther(path)) {
|
||||
copyTransformedContents(path, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user