diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-10-17 09:12:22 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-10-17 09:12:22 +0200 |
commit | 6ca08b05a93d6286e5d6a1e5ef779913fa6d644a (patch) | |
tree | 3b61ca620ca7fb3299cc3efeed3a1c8fe31a98d7 /jsdoc | |
parent | 2a67f22b354793840bb15944353fd3a411658a42 (diff) |
jsdoc: properly handle indented documentation blocks
Fix the jsdoc C transpiler plugin to properly detect the start of indented
multi line comment blocks.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'jsdoc')
-rw-r--r-- | jsdoc/c-transpiler.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/jsdoc/c-transpiler.js b/jsdoc/c-transpiler.js index 55bc617..3360c7e 100644 --- a/jsdoc/c-transpiler.js +++ b/jsdoc/c-transpiler.js @@ -18,6 +18,20 @@ 'use strict'; +function isCommentStart(source, offset) { + if (source[offset++] != '\n') + return false; + + while (source[offset] == ' ' || source[offset] == '\t') + offset++; + + return ( + source[offset++] == '/' && + source[offset++] == '*' && + source[offset++] == '*' + ); +} + exports.handlers = { beforeParse: function(e) { if (!e.filename.match(/\.(c|h)$/)) @@ -28,7 +42,7 @@ exports.handlers = { let i = 0; for (i = 0; i < e.source.length; i++) { - if (!chunk.comment && e.source[i] == '\n' && e.source[i+1] == '/' && e.source[i+2] == '*' && e.source[i+3] == '*') { + if (!chunk.comment && isCommentStart(e.source, i)) { chunk.end = i; chunk = { start: i, end: -1, comment: true }; chunks.push(chunk); |