Critical gaps in Drupal core JS

Everything is not fine in ninjavascript land

Here are the main problems with Drupal javascript:

  1. no testing,
  2. no visible documentation.

Testing

This one is a maintainer nightmare. We refactor away and break eveything in the process. Thankfully we can’t break the overlay anymore, but we have Views UI to break now! As well as various surprising components all over the place. Long story short, we need front-end testing.

There was a core conversation at the last DrupalCon prague about javascript testing where jessebeach, seutje and me talked about what was wrong and how we could get that going. The take away is that we need to find a framework to work with to set up our tests. If anyone has experience with a framework that might work with Drupal and the contrib space to write tests with, please let me know.

It really is the main pain point right now, let us know your thoughts in the javascript testing issue.

Documentation

Next big issue is documentation. It is currently non-existant for javascript. There are comments in the code, but it’s just not fun to read and we can’t see the whole picture. There have been many discussions and arguments about what and how to do. A few weeks ago I spend a whole sunday writing Drupal javascript with jsdoc and comming up with a JSDoc theme suitable for Drupal.

All that work ended up online at the Drupal JS API site. And it is looking pretty damn good. For example, you can see everything contained in the Drupal JS object. Ever wondered what was the list of all the Drupal.behaviors in core? Or what exactly are objects created from the Drupal.ProgressBar constructor? Of course there are lots of adjustments to make but it’s a start.

Right now it’s pretty much patch worthy. There is still a couple of issues that would be nice to get in for easier documentation: Split up contextual.toolbar.js and Split up ckeditor.admin.js. Once those are in I’ll make the patch so we can use JSDoc to generate documentation while we wait for a Drupal API integration with JSDoc and finally get some javascript documentation on api.drupal.org.

There is still a long way to go for Drupal to become a javascript heaven. We can use all the help we can get to make that sooner rather than later.


2014-01-26: The patch for Use JSDoc has been posted to the issue queue and needs people to improve and review it.

Comments

Reply