Skip to content

Commit 37de5f3

Browse files
authored
bugfix: make sure docblock length is only retrieved when its an array
1 parent 74dc2d3 commit 37de5f3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

shdoc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,28 +337,22 @@ function docblock_concat(key, value) {
337337
# @param value Added item value.
338338
#
339339
# @set docblock[docblock_name] docblock with value added as its last item.
340-
function docblock_push(key, value, target) {
341-
if (!isarray(target)) {
342-
docblock_push(key, value, docblock)
343-
return
344-
}
345-
new_item_index = length(target[key])
340+
function docblock_push(key, value) {
341+
new_item_index = length(docblock[key])
346342
# Reinitialize docblock key value if it is empty to allow for array storage.
347-
if(new_item_index == 0)
348-
{
349-
delete target[key]
343+
if(new_item_index == 0) {
344+
delete docblock[key]
350345
}
351-
if(isarray(value))
352-
{
346+
if(isarray(value)) {
353347

354348
# Value is an array. Add its contents key by key to the docblock.
355349
# Note that is only allow for single dimension value array.
356350
for (i in value) {
357-
target[key][new_item_index][i] = value[i]
351+
docblock[key][new_item_index][i] = value[i]
358352
}
359353
}
360354
else {
361-
target[key][new_item_index] = value
355+
docblock[key][new_item_index] = value
362356
}
363357
}
364358

@@ -975,8 +969,9 @@ match($0, /^([[:blank:]]*#[[:blank:]]+)@(stdin|stdout|stderr)[[:blank:]]+(.*[^[:
975969
/^[^#]*$/ {
976970
debug("→ break")
977971

978-
if(file_intro_enabled && in_file_block && length(docblock)){
972+
if(file_intro_enabled && in_file_block && isarray(docblock) && length(docblock)){
979973
# support a subset of additional annotations for @file sections.
974+
debug("handle file docblock")
980975
docblock_filter["example"] = 1
981976
docblock_filter["see"] = 1
982977
docblock_filter["set"] = 1

0 commit comments

Comments
 (0)