jdalton / docdown

A simple JSDoc to Markdown generator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Constructor entries break the parser

evanplaice opened this issue · comments

Attempting conversion on a source file that contains a class constructor or function marked w/ @constructor breaks the parser.

Cause

The issue starts here

organized = {},

Further down it attempts to dynamically assign the key organized.constructor

tocGroup = organized[category] || (organized[category] = []);

This results in a tocGroup receiving a TypeError as a value which throws when tocGroup.push is called here

tocGroup.push(entry);

Resolution

The issue is due to trying to use an object that inherits from Object as a key/value store. The name of organized (ie an array) tries and fails to overwrite the existing constructor function.

To fix this, organized can be initialized with an object literal that doesn't inherit any properties/methods from Object with.

 organized = Object.create(null),

It's possible this may also resolve #45