Skip to content

Commit f749605

Browse files
committed
Added Typedoc Conversion Script
1 parent 3cfe5a4 commit f749605

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

scripts/exportjson.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path');
2+
const { exec } = require('child_process');
3+
4+
const clientLibraryPath = path.resolve(__dirname, '../../clientlibrary/js');
5+
const command = 'npx typedoc --plugin typedoc-plugin-missing-exports --json ../../docs/scripts/out.json --pretty';
6+
7+
exec(command, { cwd: clientLibraryPath }, (error, stdout, stderr) => {
8+
if (error) {
9+
console.error(`Error: ${error.message}`);
10+
return;
11+
}
12+
if (stderr) {
13+
console.error(`Stderr: ${stderr}`);
14+
return;
15+
}
16+
console.log('Documentation generated:', stdout);
17+
});
18+

scripts/jsdoc_to_docusaurus.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
const fs = require('fs');
3+
4+
let rawdata = fs.readFileSync('./out.json');
5+
let outJson = JSON.parse(rawdata);
6+
console.log("Json Parsed");
7+
8+
const codeboltChild = outJson.children[0].children.find(child => child.name === "Codebolt");
9+
10+
fs.writeFileSync('./newfile.json', JSON.stringify(codeboltChild, null, 2));
11+
12+
13+
if (codeboltChild && codeboltChild.children) {
14+
codeboltChild.children.forEach(CbProperties => {
15+
const dir = `../codeboltLib/docs/api/${CbProperties.name}`;
16+
if (!fs.existsSync(dir)){
17+
fs.mkdirSync(dir, { recursive: true });
18+
}
19+
fs.writeFileSync(`${dir}/_category_.json`, JSON.stringify({
20+
"label": CbProperties.name,
21+
"position": 2.5,
22+
"collapsible": true,
23+
"collapsed": true,
24+
"className": "red",
25+
"link": {
26+
"type": "generated-index",
27+
"title": CbProperties.name,
28+
"description": "Provides Functionality for "+CbProperties.name
29+
}
30+
}, null, 2));
31+
if (CbProperties.type && CbProperties.type.declaration && CbProperties.type.declaration.children) {
32+
CbProperties.type.declaration.children.forEach(CbFunctions => {
33+
let content = `${CbProperties.name} - ${CbFunctions.name}\n`;
34+
let description = CbFunctions.comment && CbFunctions.comment.summary && CbFunctions.comment.summary.length > 0 ? CbFunctions.comment.summary[0].text : '';
35+
let returndata = "";
36+
let parameterNames = [];
37+
if (CbFunctions.type && CbFunctions.type.declaration && CbFunctions.type.declaration.signatures) {
38+
CbFunctions.type.declaration.signatures.forEach(signature => {
39+
if (signature.parameters) {
40+
signature.parameters.forEach(param => {
41+
parameterNames.push(`${param.name}: ${param.type.name}`);
42+
console.log(`${param.name}: ${param.type.name}`);
43+
});
44+
}
45+
returndata = `Returns: ${signature.type.name}\n`;
46+
});
47+
}
48+
49+
fs.writeFileSync(`${dir}/${CbFunctions.name}.md`, content + '\n' + description + '\n' + parameterNames.join('\n') + "\n"+ returndata);
50+
});
51+
}
52+
});
53+
} else {
54+
console.log('codeboltChild has no children or does not exist.');
55+
}
56+
57+
58+
59+

0 commit comments

Comments
 (0)