Skip to content

empty docObject passed to processTags #15

@nlundquist

Description

@nlundquist

When processing documentation tags in comments of a JS source file bit-docs-js passes an empty docObject. This is done here:

processTags({
comment: options.comment,
scope: options.scope,
docMap: options.docMap,
docObject: {},
tags: options.tags || {},
siteConfig: options.siteConfig || {}
}, function(newDoc, newScope){
callback(newDoc, newScope);
});

This causes usage of tags like @sourceref to fail, since it expects to be able to reference the src property of the docObject.

This issue is easily reproduced by trying to use @sourceref in any documentation comment of a JS file and then attempting to generate the docs. This will result in an error like the following:

TypeError: Cannot read property 'path' of undefined
    at Object.add (/Users/nlundqu/canjs/node_modules/bit-docs/lib/configure/node_modules/bit-docs-tag-sourceref/sourceref.js:18:21)
    at module.exports (/Users/nlundqu/canjs/node_modules/bit-docs/lib/configure/node_modules/bit-docs-process-tags/process-tags.js:95:29)
    at module.exports (/Users/nlundqu/canjs/node_modules/bit-docs/lib/configure/node_modules/bit-docs-js/process/code_and_comment.js:54:3)
    at /Users/nlundqu/canjs/node_modules/bit-docs/lib/configure/node_modules/bit-docs-js/process/javascript.js:26:13
    at Array.map (<anonymous>)
    at module.exports (/Users/nlundqu/canjs/node_modules/bit-docs/lib/configure/node_modules/bit-docs-js/process/javascript.js:25:29)
    at /Users/nlundqu/canjs/node_modules/bit-docs/lib/process/file.js:80:17
    at Array.some (<anonymous>)
    at processFile (/Users/nlundqu/canjs/node_modules/bit-docs/lib/process/file.js:79:40)
    at /Users/nlundqu/canjs/node_modules/bit-docs/lib/process/process.js:79:9

I attempted a naive fix by changing line 61 of code_and_comment.js above to docObject: options.docObject || {}, since options.docObject was defined while I was debugging, however this introduced new errors while processing the tags of other source files in the CanJS docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions