Skip to content

Commit 80155bb

Browse files
devvaannshabose
authored andcommitted
Fix: Remove redundant functions
1 parent a7397b4 commit 80155bb

File tree

1 file changed

+5
-42
lines changed

1 file changed

+5
-42
lines changed

build/api-docs-generator.js

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const inputDir = path.join(__dirname, '../src');
99
const outputDir = path.join(__dirname, './dev-temp'); // this directory will be automatically removed (required for automative processes, the final output will be in API directory).
1010

1111

12-
1312
/**
1413
* Checks if a file contains a specific line.
1514
* This function is called to check if a file has @ INCLUDE_IN_API_DOCS
@@ -314,7 +313,7 @@ function processJsFile(file, config) {
314313
// Run jsdoc-to-mdx
315314
execSync(`npx jsdoc-to-mdx -c ${path.relative(__dirname, configFile)}`, { cwd: __dirname });
316315

317-
console.log(`${path.basename(file)} is successfully converted to MDX`);
316+
console.log(`${file} is successfully converted to MDX`);
318317

319318
// Merge generated MDX files
320319
mergeMdxFiles(outDir, `${fileName}.mdx`, path.join(mdxApiDir, relativeDir));
@@ -544,36 +543,8 @@ const copyMarkdownFiles = (sourceDir, destDir) => {
544543
copyMarkdownFiles(docsDir, mdxApiDir);
545544

546545

547-
const eventManagerPath = './build/api/utils/EventManager.mdx';
548546
const notificationUIPath = './build/api/widgets/NotificationUI.mdx';
549547

550-
551-
/**
552-
* Function to fix all <extensionName> tags from the EventManager.mdx file as Docusaurus doesn't validate it and throws error
553-
* removing links where docusaurus throws error.
554-
* @param {string} filePath
555-
*/
556-
function fixEventManagerFile(filePath) {
557-
try {
558-
// Read the file content
559-
let content = fs.readFileSync(filePath, 'utf8');
560-
561-
// Use a regular expression to find and remove all <extensionName> tags
562-
let updatedContent = content.replace(/<extensionName>/g, '<extensionName />');
563-
564-
updatedContent = updatedContent.replace('[&quot;http://mydomain.com&quot;]=true;', '');
565-
566-
updatedContent = updatedContent.replace('["http://mydomain.com"]', '');
567-
568-
// Write the updated content back to the file
569-
fs.writeFileSync(filePath, updatedContent, 'utf8');
570-
console.log("Successfully fixed all issues inside eventManager file");
571-
} catch (error) {
572-
console.error(`Error processing file ${filePath}: ${error.message}`);
573-
}
574-
}
575-
576-
577548
/**
578549
* fix notification UI broken areas
579550
* NotificationUI file has some issues and mdx is not being rendered properly. Fixing it.
@@ -586,26 +557,18 @@ function fixNotificationUiFile(filePath) {
586557
// Read the file synchronously
587558
let content = fs.readFileSync(filePath, 'utf8');
588559

589-
let updatedContent = content;
590-
591560
// Fix notification UI broken areas
592-
updatedContent = updatedContent.replace('ame="badge badge--info margin-left--sm">static</span><br/><a href="#done">done</a><span className="badge badge--info margin-left--sm">static</span></div></div>\n</div>', '');
593-
594-
updatedContent = updatedContent.replace('Click me to </br>locate the file in file tree', 'Click me to locate the file in file tree');
595-
596-
// Replace second occurrence
597-
updatedContent = updatedContent.replace('Click me to </br>locate the file in file tree', 'Click me to locate the file in file tree');
561+
content = content.replace('ame="badge badge--info margin-left--sm">static</span><br/><a href="#done">done</a><span className="badge badge--info margin-left--sm">static</span></div></div>\n</div>', '');
598562

599563
// Write the file synchronously
600-
fs.writeFileSync(filePath, updatedContent, 'utf8');
564+
fs.writeFileSync(filePath, content, 'utf8');
601565

602-
console.log("Successfully fixed all issues inside notificationUI file");
566+
console.log("Successfully fixed the issues inside notificationUI file");
603567
} catch (err) {
604-
console.error('Error:', err);
568+
console.error('Error while fixing notificationUI file', err);
605569
}
606570
}
607571

608-
fixEventManagerFile(eventManagerPath);
609572
fixNotificationUiFile(notificationUIPath);
610573

611574

0 commit comments

Comments
 (0)