Skip to content

How to contribute to Fabric

Kienz edited this page Apr 2, 2013 · 17 revisions

Filing bugs

If you think you found a bug in Fabric, please create a jsfiddle with a minimal test case, demonstrating the bug. You can then create an issue with the link to jsfiddle. If you're unsure about something, it's best to create a post on Fabric's google group where someone might clarify some of the things.

Patching a bug or adding feature

If you're definitely certain about a bug or feature, please open a pull request (see "Using pull requests") with a fix/addition.

Architecture and gotchas

Before filing a bug or adding a patch, you might want to get familiar with Fabric's architecture:

gotchas:

or just general notes:

Code style, notes

  • 2 spaces, no tabs
  • semicolons required
  • explicit blocks
  • camelCase
  • fabric.document/fabric.window (not just document/window)

Documentation

Fabric uses JSDoc toolkit for documentation. An example of documenting a method:

/**
 * Capitalizes a string
 * @memberOf fabric.util.string
 * @method capitalize
 * @param {String} string String to capitalize
 * @return {String} Capitalized version of a string
 */
function capitalize(string) {
  return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}

Building fabric

  1. Install Node.js
  2. Build distribution file
node build.js modules=ALL exclude=gestures

Testing fabric

When fixing bugs or adding new features, it's highly advisable to add a corresponding unit test (under /test/unit, and under corresponding module). Fabric uses QUnit for unit tests. You can run entire test suite like so (from within Fabric's root directory):

> npm test

Adding documentation

Fabric uses JSDoc-style documentation, right in the code. After adding or updating certain documentation, please open a pull request. You can also add or update a page on Fabric's github wiki.