Skip to content

Commit

Permalink
add typedefs and default values to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaquraish committed Jan 13, 2024
1 parent 9729b45 commit 90e0d62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions JS/HTMLGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ const genParam = (param) => {
let typeSpan = evalLinks(param.type, true);
paramSpan.appendChild(typeSpan);

if (param.default_value) {
paramSpan.appendText(" = ", "punctuation");
paramSpan.appendText(param.default_value, "default-value");
}

return paramSpan;
}

Expand Down Expand Up @@ -151,6 +156,16 @@ const genFunctionSummary = (node) => {
return functionSpan;
}

const genTypedefSummary = (child) => {
let typedefSpan = document.createElement('span');
typedefSpan.classList.add('typedef');
typedefSpan.appendText("typedef ", "keyword");
typedefSpan.appendText(child.name);
typedefSpan.appendText(" = ", "punctuation");
typedefSpan.appendChild(evalLinks(child.type));
return typedefSpan;
}

const genVariable = (node) => {
let variableSpan = document.createElement('span');
variableSpan.classList.add('variable');
Expand Down Expand Up @@ -293,3 +308,9 @@ const genFunction = (node) => {

return functionDiv;
}

const genTypedef = (node) => {
let div = document.createElement('div');
div.appendChild(genTypedefSummary(node));
return div;
}
15 changes: 15 additions & 0 deletions JS/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const nodeMap = new Map([
["unions", "Unions"],
["functions", "Functions"],
["methods", "Methods"],
["typedefs", "TypeDefs"],
])

window.addEventListener('hashchange', (event) => {
Expand Down Expand Up @@ -91,6 +92,13 @@ function addFunctionMethodContent(node, title) {
})
}

function addTypedefContent(node, title) {
main.appendChild(genHeader(title))
Object.values(node).forEach((child) => {
main.appendChild(genTypedefSummary(child));
});
}

function addMainContent(node) {
genSourceLink(node.source)
if (node.description) {
Expand Down Expand Up @@ -122,6 +130,10 @@ function addMainContent(node) {
main.appendChild(genFunction(node));
main.appendChild(document.createElement('br'))
break;
case "typedef":
main.appendChild(genTypedef(node));
main.appendChild(document.createElement('br'))
break;
}

nodeMap.forEach((value, key) => {
Expand All @@ -146,6 +158,9 @@ function addMainContent(node) {
case "methods":
addFunctionMethodContent(node[key], value);
break;
case "typedefs":
addTypedefContent(node[key], value);
break;
default:
console.log(node);
}
Expand Down

0 comments on commit 90e0d62

Please sign in to comment.