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

JsDoc improvements #854

Closed
janhancic opened this issue Jul 18, 2014 · 27 comments
Closed

JsDoc improvements #854

janhancic opened this issue Jul 18, 2014 · 27 comments
Assignees
Milestone

Comments

@janhancic
Copy link
Contributor

When creating a link to a module: {@link module:my/Module}, the default text of the link should be my/Module, not module:my/Module.

Same for return types and argument types.

@janhancic
Copy link
Contributor Author

Also, move the namespace/package list to the top.

@janhancic
Copy link
Contributor Author

@andyberry88 I don't know if I understood your correctly, so correct me if this is wrong.

If you link to a CommonJS module, you do it like so: module:some/Module, whereas if you link to a namespaced class you link it like so: some.Class. And you can't use the dotted notation to link to a module and vice-versa.

If that is true, then I think we need a workaround that will allow us to do that. Otherwise people will have to constantly update their JsDoc when the thing they are linking to changes from namespaced-js to commonJS (and it is going to be hard to catch when that happens).

@andy-berry-dev andy-berry-dev modified the milestones: 0.11, v0.12 Jul 22, 2014
@andy-berry-dev
Copy link
Member

When creating a link to a module: {@ link module:my/Module}, the default text of the link should be my/Module, not module:my/Module.

This has been done and should be in the v0.11 release (dd2b9f5). In order to make sure the change is in the template rather than core JSDoc we now remove any instance of module: in link text. The downside of this is that no link text can start with module: regardless of if you actually want it to.

Also, move the namespace/package list to the top.

Done. Just a template change. (11af58b)

If you link to a CommonJS module, you do it like so: module:some/Module, whereas if you link to a namespaced class you link it like so: some.Class. And you can't use the dotted notation to link to a module and vice-versa.

Correct. I don't think there is any workaround for this and I don't think we should attempt to create one by hacking the JsDoc core. This is simply a side effect of using both commonJS and namespacedJS style code. Ultimately JSDoc needs to be able to identify any symbol, and the module: prefix is part of this unique name.

@janhancic
Copy link
Contributor Author

Correct. I don't think there is any workaround for this and I don't think we should attempt to create one by hacking the JsDoc core. This is simply a side effect of using both commonJS and namespacedJS style code. Ultimately JSDoc needs to be able to identify any symbol, and the module: prefix is part of this unique name.

As per my original comment, I don't think this is acceptable. We had a conversation with @james-shaw-turner and he agreed.

@andy-berry-dev
Copy link
Member

I think we need to get on a call at some point to discuss this then. IMO, from a BRJS point of view, we shouldn't be changing the core behaviour of tools we rely on. If this is a CT requirement then it can be done as a CT change rather than in the core of BRJS.

@janhancic
Copy link
Contributor Author

This is a user issue. A developer using BRJS or CT that links to documentation in the SDK shouldn't have to care what type it is. And like I said, it will randomly break when libs are updated to CommonJS.

@andy-berry-dev andy-berry-dev modified the milestones: 0.12, 0.13 Aug 4, 2014
@thecapdan
Copy link
Contributor

Following the upgrade to jsdoc:

brjs jsdoc appname

command is taking a very long time. 15 minutes for large apps that previously took around 1 minute.

When testing on a small app in brjs it was difficult to see the issue since it was taking around 20 secs for smaller apps. But when running with bigger apps and more libraries we saw that it was taking a LOT longer.

needs further investigation to see what about the jsdoc toolkit is taking so much longer

@thecapdan
Copy link
Contributor

Also, when it fails to produce a jsdoc for a class it doesn't fail gracefully - it just hangs on the command line:


Unicode modifier letter, Unicode other letter, Unicode titlecase letter or Unicode uppercase letter but "'" found.
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "virtual" from undefined
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3689)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3667)
    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3695)
    at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3714)
    at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3726)
    at org.mozilla.javascript.ScriptRuntime.getObjectPropNoWarn(ScriptRuntime.java:1509)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_lib_jsdoc_util_templateHelper_js_74._c_anonymous_26(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_lib_jsdoc_util_templateHelper_js_74.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73._c_anonymous_17(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73.call(Unknown Source)
    at org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:1589)
    at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:318)
    at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73._c_addSignatureReturns_16(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73._c_anonymous_47(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72._c_anonymous_3(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72._c_anonymous_82(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72.call(Unknown Source)
    at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2429)
    at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
    at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
    at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72._c_anonymous_6(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_node_modules_taffydb_taffy_js_72.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73._c_anonymous_39(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_brjs_template_publish_js_73.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18._c_anonymous_26(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18._c_anonymous_23(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18._c_anonymous_16(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18._c_anonymous_9(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_cli_js_18.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1._c_anonymous_3(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1.call(Unknown Source)
    at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1._c_script_0(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1.call(Unknown Source)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3090)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1.call(Unknown Source)
    at org.mozilla.javascript.gen.file__D__re_ct_ct_core_sdk_jsdoc_toolkit_resources_jsdoc_toolkit_jsdoc_js_1.exec(Unknown Source)
    at org.mozilla.javascript.commonjs.module.Require.executeModuleScript(Require.java:355)
    at org.mozilla.javascript.commonjs.module.Require.getExportedModuleInterface(Require.java:288)
    at org.mozilla.javascript.commonjs.module.Require.requireMain(Require.java:137)
    at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:525)
    at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:176)
    at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:100)
    at org.mozilla.javascript.Context.call(Context.java:489)
    at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)
    at org.mozilla.javascript.tools.shell.Main.exec(Main.java:158)
    at org.mozilla.javascript.tools.shell.Main.main(Main.java:136)
undefined

@dchambers
Copy link
Contributor

I agree with @andyberry88 that the kind of changes @janhancic is suggesting (referring to classes and modules using the same syntax) are not changes we should be making, but should be raised directly against the upstream project.

That being said, I think what @janhancic is saying makes sense since as it happens both CommonJs and NamespacedJs classes are served to the browser as CommonJs modules, and are both modelled internally as modules (they are both instances of SourceModule). Therefore, is the problem actually that we are running the jsdoc command on the source code rather than the transpiled source code?

@thecapdan
Copy link
Contributor

Checklist of improvements (in no particular order)

  • investigate poor performance
  • fail more gracefully when incorrect syntax is used
  • improved ability to search the main jsdoc page (now that it's no longer a tree)
  • more consistency between commonjs/namespacedjs (JanH)

@thecapdan
Copy link
Contributor

Some more notes on this one:

Found that one class that was taking more than most was ComponentFixture.js - could look into what in terms of jsdoc it has moreso than other classes - at first glance it looks to have a lot of '@see's.

Also, worth noting that the command requires a working set of well over a gigabyte in memory

@jeremyherr
Copy link
Contributor

In brjs API docs as well as CT, for modules, the constructor name is shown as a brackets-enclosed require statement.

The first thing the user sees when looking at modules looks like garbage at first glance. Here is an example: http://apidocs.bladerunnerjs.org/v0.11/js/KnockoutComponent.html

I propose that this should read new KnockoutComponent(sTemplateId, oViewModel) instead of new (require("br/knockout/KnockoutComponent"))(sTemplateId, oViewModel)
We have the same problem in CT for all of our modules. Since all classes in CommonJS are in modules, this affects all of our new code.

@jeremyherr
Copy link
Contributor

Also for modules JSDoc, there is a redundant link to source code underneath the constructor. Again as an example: http://apidocs.bladerunnerjs.org/v0.11/js/KnockoutComponent.html.

There are 2 links next to each other, one to line 3, another to line 25.

@jeremyherr
Copy link
Contributor

@interface doesn't work. This page seems to indicate that it is something that could be made to work by modifying templates? https://code.google.com/p/jsdoc-toolkit/issues/detail?id=229

@hegemonic
Copy link

Hi, I'm the maintainer of JSDoc, and I just stumbled across this issue.

I've made some changes to JSDoc over the past couple of weeks that should drastically improve performance for large docsets. I haven't investigated memory usage, though. Please try the current version of JSDoc on master and let me know if you're still seeing performance and/or memory issues. (If you can run JSDoc on Node.js, rather than Mozilla Rhino, that will also give you much better performance.)

Also, the @interface and @implements tags are now available in JSDoc on master. (The link above points to the issue tracker for JSDoc 2, which is extremely out of date and should be turned off. See https://github.com/jsdoc3/jsdoc/issues for a current list of issues.)

I'll work with @dchambers on the issues he filed. I'm about to go out of town, though, so it will be a couple of weeks before I can respond in detail.

@dchambers
Copy link
Contributor

Thanks @hegemonic, your assistance is very much appreciated.

@leggetter
Copy link
Contributor

👍

@dchambers
Copy link
Contributor

IMO, the various issues raised here in this meta issue have either been fixed by #926, or mitigated against.

Things that have been fixed:

  • All classes (both NamespaceJs and CommonJs) are now defined within modules, so stuff won't break as we migrate.
  • Interfaces are now correctly supported.
  • Classes, interfaces, events & modules are now displayed in their own sections of the index.
  • The redundant extra link to the source code is now fixed, as it's now rendered in the correct section.
  • I didn't see the hanging issues described by @thecapdan while working with the latest version of jsdoc3.
  • The time to build very large code-bases like CT should hopefully now be improved.

This leaves the following:

  • The constructor name is shown as a brackets-enclosed require statement -- this doesn't feel like a problem anymore with the new styling, where there is a 'Constructor' heading, and where the typeface size is smaller.
  • Fail more gracefully when incorrect syntax is used -- I think this has improved, but any issues we do find should be raised against the upstream project.
  • Improved ability to search the main jsdoc page (now that it's no longer a tree) -- this is a non-trivial feature that I've raised as a separate bug, and which isn't high enough priority given it's cost to deal with now as for the time being developers can just use the browser's in-built search functionality.

@thanhc
Copy link
Contributor

thanhc commented Aug 29, 2014

verified all the points Dom's mentioned above, all classes are now displayed as module:my/Module.
Interfaces are displayed in there own sections as other types.

No performance improvements noticed while running jsdoc against live-examples compared to the previous version.

@jeremyherr
Copy link
Contributor

Using v0.11.324-ge900841

classes appear twice, both in the classes and modules lists. All classes are modules, so it doesn't make sense to list classes under modules.

constructor name is not valid JavaScript, e.g.

new module:br/component/testing/ComponentFixture(sXml, oModelFixture, oViewFixture)

h1 at top of page for classes looks weird, e.g.

Class: module:br/component/testing/ComponentFixture

@thecapdan
Copy link
Contributor

Here's a illustration of the issue seen by @jeremyherr

image

(moving a couple of issues back to test to discuss during today's standup)

@andy-berry-dev
Copy link
Member

This is an issue that is likely to be fixed in coming releases of jsdoc. We spoke about this at the standup today and the general consensus was that we wait for it to be fixed upstream rather than hacking it in to BRJS.

Moving this back in to the backlog until its 100% fixed.

@andy-berry-dev andy-berry-dev removed this from the 0.12 milestone Sep 3, 2014
@andy-berry-dev andy-berry-dev modified the milestone: 0.13 Sep 3, 2014
@dchambers
Copy link
Contributor

@jeremyherr: Sorry, only just seen your comment, but to address your points:

classes appear twice, both in the classes and modules lists. All classes are modules, so it doesn't make sense to list classes under modules.

While it's true that both BladeRunnerJS and CaplinTrader adhere to the one class per module rule, it's also possible to have modules that export multiple classes. Also, the maintainer of jsdoc feels this is how it should work since modules that contain classes are both modules and classes, and so this is deliberate.

constructor name is not valid JavaScript, e.g. new module:br/component/testing/ComponentFixture(sXml, oModelFixture, oViewFixture)

I agree, but suggest it would be better to raise this as single issue item against the upstream project.

h1 at top of page for classes looks weird, e.g. Class: module:br/component/testing/ComponentFixture

I actually think this is broadly a good thing. The logical name of the entity being documented is module:br/component/testing/ComponentFixture, and this is what you would need to use in any jsdoc that wants to refer to this class. Additionally, it is a class.

In the old documentation we used to have different icons for classes, interfaces, singletons, etc, but since jsdoc does't have icons, having some text to tell us what we're looking at is the next best thing IMO. Again, if you disagree I'd recommend creating an issue with the upstream project.

@dchambers
Copy link
Contributor

@andyberry88, I'd suggest we close this issue as we've now integrated with jsdoc, ironed out any upgrade issues, and contributed a number of improvements as pull-requests. IMO, any further improvements to jsdoc3 should be issued against that project as a number of single-use issues so they can be more easily managed.

@andy-berry-dev
Copy link
Member

@dchambers Agreed. I'll move it to 'ReadyForTest' so @thecapdan has a chance to comment first.

@thecapdan
Copy link
Contributor

Since we've found a workaround, we can move to done - but keep an eye on jsdoc upgrades that might improve performance

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