Skip to content
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

Error while building docs with this plugin #3

Open
kopach opened this issue Feb 9, 2017 · 8 comments
Open

Error while building docs with this plugin #3

kopach opened this issue Feb 9, 2017 · 8 comments

Comments

@kopach
Copy link

kopach commented Feb 9, 2017

When I include this plugin in my esdoc config - build fails with an error: TypeError: Class constructor DocBuilder cannot be invoked without 'new'

Anyway, I've pulled the repo locally, installed all the dependencies, builded it and linked to my project - and it works now.

So, looks like the problem just in published version to npmjs registry.

P.S.
Exactly the same problem I have with your another plugin https://github.com/typhonjs-node-esdoc/esdoc-plugin-dependency-graphs/

@typhonrt
Copy link
Member

typhonrt commented Feb 9, 2017

Any chance you can provide a stack trace and your ESDoc config file? Also what version of ESDoc? I haven't had this plugin fail before and use it regularly. What version of Node as well?

Also a FYI. In a week or so I'll be releasing a spiritual successor of ESDoc called TJSDoc with many enhancements and significantly improved architecture. This nav replacement plugin for instance will be rolled into the core functionality of TJSDoc.

@kopach
Copy link
Author

kopach commented Feb 9, 2017

Here is my eslint config:

{
	"source": "./src",
	"destination": "./docs/build",
	"plugins": [
		{
			"name": "esdoc-plugin-enhanced-navigation"
		}
	]
}

node --version
v6.5.0

I'm running esdoc as npm script defined in package.json like: "docs": "esdoc -c docs/esdoc-config.json"

"esdoc": "0.5.2", - but I've tried also with version 0.4.0 as per description in README.md - the same result

stack trace:

/Users/<path-to-my-project>/node_modules/esdoc-plugin-enhanced-navigation/dist/EnhancedNavDocBuilder.js:60
      var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(EnhancedNavDocBuilder).call(this, data, config));
                                                                                                ^

TypeError: Class constructor DocBuilder cannot be invoked without 'new'
    at new EnhancedNavDocBuilder (/Users/<path-to-my-project>/node_modules/esdoc-plugin-enhanced-navigation/dist/EnhancedNavDocBuilder.js:60:97)
    at Object.onHandleTag (/Users/<path-to-my-project>/node_modules/esdoc-plugin-enhanced-navigation/dist/plugin.js:163:13)
    at Plugin._execHandler (/Users/<path-to-my-project>/node_modules/esdoc/out/src/Plugin/Plugin.js:57:26)
    at Plugin.onHandleTag (/Users/<path-to-my-project>/node_modules/esdoc/out/src/Plugin/Plugin.js:130:10)
    at Function.generate (/Users/<path-to-my-project>/node_modules/esdoc/out/src/ESDoc.js:134:32)
    at ESDocCLI.exec (/Users/<path-to-my-project>/node_modules/esdoc/out/src/ESDocCLI.js:75:23)
    at Object.<anonymous> (/Users/<path-to-my-project>/node_modules/esdoc/out/src/ESDocCLI.js:186:7)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)

npm ERR! Darwin 16.0.0
npm ERR! argv "/Users/<my-user-name-here>/.nvm/versions/node/v6.5.0/bin/node" "/Users/<my-user-name-here>/.nvm/versions/node/v6.5.0/bin/npm" "run" "docs"
npm ERR! node v6.5.0
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE

@typhonrt
Copy link
Member

typhonrt commented Feb 9, 2017

So it seems to do with extending the ES5 transpiled version of ESDoc via ES6 classes in the plugin. That is why it is mentioning "DocBuilder" which is the ESDoc transpiled source being extended. When a project doesn't use Babel / IE vanilla Node then it will fail seemingly. It just so happens I use Babel for all of my projects and haven't seen this case. Apparently this is something commonly biting a lot of projects if you search for babel cannot be invoked without new.

You can read a little about it here:
babel/babel#4269

Things would be different if ESDoc shipped the source code in the NPM module like all TyphonJS modules do.

I planned on deprecating all of my ESDoc plugins next week when launching TJSDoc. Any chance you can give tjsdoc a try next week? I just made the repo public - https://github.com/typhonjs-doc/tjsdoc

There will be a huge initial commit rather soon and subsequently published to NPM.

@sonsoleslp
Copy link

Any updates on this? I would reeeally like to use this plugin with the latest version of ESDoc but I can't get it to work. Everything worked properly before adding this plugin. This is what I get after running esdoc -c esdoc.json

module.js:471
    throw err;
    ^

Error: Cannot find module 'esdoc/out/src/Publisher/Builder/DocBuilder.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (...\node_modules\esdoc-plugin-enhanced-navigation\dist\EnhancedNavDocBuilder.js:23:20)

My esdoc.json

{
  "source": ".",
  "destination": "./esdoc",
  "includes": ["^_editor", "^_visor", "^common", "^core", "^plugins", "^reducers"],
  "plugins": [
    {
      "name": "esdoc-standard-plugin",
      "option": {
        "lint": {"enable": true}
      }
    },
    {
      "name": "esdoc-react-plugin"
    },
    {
      "name": "esdoc-jsx-plugin",
      "option": {
        "enable": true
      }
    },
    {
      "name": "esdoc-plugin-enhanced-navigation"
    }
  ]
}

@typhonrt
Copy link
Member

@sonsoleslp alas, I am no longer maintaining any of my esdoc plugins including this one. The good news is that I'm getting closer to releasing a significant fork of ESDoc called TJSDoc. It is a complete overhaul and across the board improvement in many areas including many new features with an aim at creating a production quality tool. The left-hand navigation experience in TJSDoc is an improved version of what this plugin provided / prototyped. I've been working on TJSDoc all year and much of it is on Github with just a bit of work left on the publishing model.

Re: Error: Cannot find module 'esdoc/out/src/Publisher/Builder/DocBuilder.js'

This plugin definitely won't work with ESDoc v1+ as it depended on extending DocBuilder as that is the only way to easily access the doc DB. ESDoc at one point was a mono-repo.

@sonsoleslp
Copy link

Thanks for your reply. I will consider using your new repo only if it works well with React/Redux ;)

@typhonrt
Copy link
Member

It will work better than ESDoc especially for 3rd party plugin producers and be fixed much quicker if it doesn't for particular problems. I probably made the most complex ESDoc plugins and there were a lot of pain points / fragility; none of them fixed by v1.x, but all of them addressed w/ TJSDoc.

It may be a couple of months before the publicly announced launch of TJSDoc, but it's now at final work with a theme system and finishing the overhauled publisher. You might subscribe to typhonjs-node-tjsdoc/tjsdoc#2 as you'll get the latest news on the launch progress.

@sonsoleslp
Copy link

Thanks again, I will surely check it out as soon as it is launched. In the meantime I will get by with ESDoc messy navigation. 🤒

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

No branches or pull requests

3 participants