Skip to content

Cannot read property 'parseExtension' of undefined #869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dasblitz opened this issue Aug 9, 2017 · 6 comments
Open

Cannot read property 'parseExtension' of undefined #869

dasblitz opened this issue Aug 9, 2017 · 6 comments
Assignees

Comments

@dasblitz
Copy link

dasblitz commented Aug 9, 2017

First of all thx for this great library, I've been using it with no problems for the past few months however since upgrading to the latest version I'm running into an error.

I'm using documentation version 5.1.1 installed as an npm module. But when I try to run
node generate-docs.js (see file content of generate-docs below)

I'm getting the following error:

Cannot read property 'parseExtension' of undefined

The error happens in documentation/lib/merge_config.js at line 72 where the config passed into the mergeConfig function is undefined.

I've had the script working on an older version where instead of the returned promise documentation.build() was using callback functions. I've tried to search stackoverflow but documentation is not the easiest search term :) From the documentation I understood that the config.yml was optional. Any help on a possible solution would be greatly appreciated :)

/* generate-docs.js */
/* eslint-disable no-console */
process.env.NODE_ENV = 'production';

var documentation = require('documentation');
var paths = require('../config/paths');
var streamArray = require('stream-array');
var vfs = require('vinyl-fs');

var files = [
    'src/index.js',
    'src/entities/player.js'
];

console.log('Building API documentation...');

documentation.build(files, {shallow: true})
.then(documentation.formats.html)
.then(function(output){
    streamArray(output).pipe(vfs.dest(paths.appBuildDocs));
    console.log('API docs generated');
})
.catch(function(err){
    console.log(err);
});

Edit: some additional info, it works for version 4.0.0-beta.18 with the following code:

/* eslint-disable no-console */
process.env.NODE_ENV = 'production';

var documentation = require('documentation');
var paths = require('../config/paths');
var streamArray = require('stream-array');
var vfs = require('vinyl-fs');

var files = [
    'src/index.js',
    'src/entities/player.js'
];

console.log('Building API documentation...');

documentation.build(files, {shallow: true}, function(err, res) {
    if(err) {
        console.error(err);
        return;
    }
    documentation.formats.html(res, {}, function(err, output) {
        streamArray(output).pipe(vfs.dest(paths.appBuildDocs));
        console.log('API docs generated');
    });
});
@ahutchings
Copy link
Member

I ran into this as well with the markdown formatter. It seems the formatter's options parameter (second parameter) is required.

You should be able to use it like this:

/* generate-docs.js */
/* eslint-disable no-console */
process.env.NODE_ENV = 'production';

var documentation = require('documentation');
var paths = require('../config/paths');
var streamArray = require('stream-array');
var vfs = require('vinyl-fs');

var files = [
    'src/index.js',
    'src/entities/player.js'
];

console.log('Building API documentation...');

documentation.build(files, {shallow: true})
.then(comments => documentation.formats.html(comments, {}))
.then(function(output){
    streamArray(output).pipe(vfs.dest(paths.appBuildDocs));
    console.log('API docs generated');
})
.catch(function(err){
    console.log(err);
});

Maintainers, do the docs needs to be updated for the formatters? Or is the intent that the options should be optional?

@anthony-redFox
Copy link
Member

I think we need to make optional the second parameter.

@kalinchernev
Copy link

I encounter the same issue in 5.3.5.

@b4dnewz
Copy link

b4dnewz commented Jul 8, 2018

This still happen today using ^8.0.0 and copy paste node markdown example execute it and you get a:

TypeError: Cannot read property 'parseExtension' of undefined
node_modules\documentation\lib\merge_config.js:92:35)

Even using a empty object as second parameter

Edit: Actually using v6.2.0, which is the latest release as github says, it works! I dunno why npm installed the v8.x when running npm install documentation

@callingmybluff
Copy link

Version 9.1.1 and this happens again during the standard HTML generation. Adding the second option: {shallow: false} fixes it

@tmcw tmcw reopened this Jan 31, 2019
@va-deem
Copy link

va-deem commented Jun 11, 2020

Version 13.0.1, same when trying to generate markdown. {shallow: false} as a second option fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants