diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-10-11 15:58:50 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-10-11 16:33:51 +0200 |
commit | 4a8ece2534ad72668be0016084dd15083b96b3f0 (patch) | |
tree | b417cd777487fcbbdce11954f8365383875d4539 /docs/ucode.js | |
parent | fcd39e290f58e3c598b976fb78a8fefaad3946ba (diff) |
docs: use CSS and local JavaScript fixups to improve formatting
- Reduced margins
- Better visual separation of method descriptions
- Improved display of argument and return value attributes
- Improved display of object and array type descriptions
- Shortened absolute module name paths
The local JavaScript fixups are a stop-gap measure for now, in the long
it likely makes more sense to fork the used JSDoc theme to apply the
desired changes directly to the markup.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'docs/ucode.js')
-rw-r--r-- | docs/ucode.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/ucode.js b/docs/ucode.js index 6728cdb..2377c7e 100644 --- a/docs/ucode.js +++ b/docs/ucode.js @@ -4,4 +4,36 @@ document.addEventListener('DOMContentLoaded', (ev) => { if (accordionState == null || accordionState == '{}') document.querySelectorAll('[data-isopen="false"]') .forEach(item => item.setAttribute('data-isopen', 'true')); + + const moduleName = location.pathname.match(/\/module-(.+)\.html$/)?.[1]; + + if (moduleName) { + const modulePrefix = `module:${moduleName}.`; + + document.querySelectorAll(`a[href^="module-${CSS.escape(moduleName)}."]`).forEach(a => { + if (a.text?.indexOf(modulePrefix) == 0) + a.text = a.text.substring(modulePrefix.length); + }); + } + + document.querySelectorAll('.param-type, .type-signature').forEach(span => { + let replaced; + do { + replaced = false; + span.innerHTML = span.innerHTML.replace(/\b(Object|Array)\.<((?:(?!&[lg]t;).)+)>/, + (m, t, st) => { + replaced = true; + + if (t == 'Object') + return `Object<${st.replace(/,\s*/, ': ')}>`; + else + return `${st}[]`; + }); + } while (replaced); + }); + + document.querySelectorAll('.type-signature').forEach(span => { + span.innerHTML = span.innerHTML.replace(/\(nullable\) (.+)$/, + '$1<span class="signature-attributes">nullable</span>'); + }); }); |