On Dec 28, 2012, at 5:05 AM, Matthew Flaschen mflaschen@wikimedia.org wrote:
We have all these JavaScript documentation comments, but we're not actually generating docs. This has been talked about before, e.g. http://www.gossamer-threads.com/lists/wiki/wikitech/208357?do=post_view_thre..., https://bugzilla.wikimedia.org/show_bug.cgi?id=40143, https://www.mediawiki.org/wiki/Requests_for_comment/Documentation_overhaul#I... .
I don't think Doxygen is the best choice, though. JavaScript is really put forth as a sort-of afterthought.
I suggest JSDoc (http://usejsdoc.org/), simply because it's a standard library and has has been put forward in the past, with good rationale.
I know there are other good ones too.
What do you think?
Matt Flaschen
Doxygen is indeed not meant for JavaScript. With some hacks it can be tricked into reading comment blocks from javascript files, but that won't scale for our code base, nor will it be enough to make a useful structure given the dynamic way JavaScript works.
JSDoc is pretty solid, though there are some concerns: * The syntax is somewhat foreign compared to what we're doing right now * Development is unclear (v2 on google-code has been discontinued, v3 on github is a rewrite still being worked on) * Written in javascript, but doesn't run on node. Requires Java. * Features appear to cover the general cross-language cases, but too limited when trying to document more complex javascript solutions (e.g. VisualEditor's code base).
I've recently looked into a documentation generator for VisualEditor and though I haven't stopped looking yet, I'm currently pausing rather long at JSDuck. It is very well engineered and especially optimised for modern JavaScript (inheritance, mixins, event emitters, override/overload methods from another module, modules, etc.).
It is also easy to extend when needing to implement custom @tags.
I've set up a vanilla install for VisualEditor's code base here:
http://integration.wmflabs.org/mwext-VisualEditor-docs/
Right now, like MediaWiki core, VisualEditor is just documenting code loosely, not following any particular doc-syntax, so we're bound to require a few tweaks[1] no matter which framework we choose. Our current syntax is just something we came up with loosely based on what we're used to with Doxygen.
Right the demo on labs only uses the "Doc" app of JSDuck, but it also supports Guides, Demo's, interactive live-editable Examples and more.
A few random things I like in particular about JSDuck are: * Support documenting parameters of callback functions * Support documenting events emitted by a class/module * Option to show/hide inherited methods and other characteristics * Support to completely document objects for @param and @return (like @param {Object} foo, @param {number} foo.bar) * Live search and permalinks * Markdown all the way + duck extension for doc specific syntax (e.g. @link and #method)
If it works out, I think we can get this going for MediaWiki core as well.
Regardless of the framework we choose, we should set it up to be generated for branches and update on merge from jenkins's post-merge hooks. Come to think of it, we should probably do that for the PHP/Doxygen as well (is that still running from the cronjob on svn.wikimedia.org?).
-- Krinkle
[1] Perfectionist alert, this commit does more than just the necessary "tweaks": https://gerrit.wikimedia.org/r/42221/