From bc0fddf02a0df377d73490181adf3c87416d759a Mon Sep 17 00:00:00 2001 From: Marco Bonelli Date: Wed, 20 Mar 2024 14:22:37 +0100 Subject: [PATCH] Show "void" for 0-arg signatures in compact form --- www/index.js | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/www/index.js b/www/index.js index 6ff9fb7..e5fd722 100644 --- a/www/index.js +++ b/www/index.js @@ -362,25 +362,32 @@ function fillRow(row, tag, sc, maxArgs) { const sig = document.createElement('td') row.appendChild(sig) - for (let i = 0; i < sc.signature.length; i++) { - const arg = sc.signature[i] - const spaceIdx = arg.trimEnd().lastIndexOf(' ') - - if (spaceIdx === -1) { - sig.append(document.createTextNode(arg)) - } else { - const type = document.createElement('span') - const name = document.createElement('span') - type.classList.add('argtype') - name.classList.add('argname') - type.textContent = arg.slice(0, spaceIdx) - name.textContent = arg.slice(spaceIdx) - sig.appendChild(type) - sig.appendChild(name) + if (sc.signature.length > 0) { + for (let i = 0; i < sc.signature.length; i++) { + const arg = sc.signature[i] + const spaceIdx = arg.trimEnd().lastIndexOf(' ') + + if (spaceIdx === -1) { + sig.append(document.createTextNode(arg)) + } else { + const type = document.createElement('span') + const name = document.createElement('span') + type.classList.add('argtype') + name.classList.add('argname') + type.textContent = arg.slice(0, spaceIdx) + name.textContent = arg.slice(spaceIdx) + sig.appendChild(type) + sig.appendChild(name) + } + + if (i < sc.signature.length - 1) + sig.append(document.createTextNode(', ')) } - - if (i < sc.signature.length - 1) - sig.append(document.createTextNode(', ')) + } else { + const type = document.createElement('span') + type.classList.add('argtype') + type.textContent = 'void' + sig.appendChild(type) } } else { // Expanded signature: one column per argument