Every source file starts with ArrayFire.js' license, which template can be found there.
Other rules:
- UTF8
- Max 100 chars per source lines
- Use 4 spaces instead of tabs
- Only English text is allowed
- Don't overuse comments, write clean, good structured code instead
- KISS
- YAGNI
- DRY if it not contradicts with KISS
ArrayFire.js uses CMake.js of its build system. To build native sources, please install CMake.js from the npm:
npm install -g cmake-js
Go to ArrayFire.js' source folder, and enter:
cmake-js build
to build its native addon. You can use --debug
argument to use debug configuration.
Enter:
cmake-js --help
for more information, or refer to its readme on Github.
Notice: It's advised to use an IDE to develop the native module, there is a tutorial available for instructions of using Qt Creator, but other CMake compatible IDEs will do.
- Language of development is C++11
- Use
auto
everywhere - File names are written in lower case
- Files are put to
src
directory - Headers have
.h
extension and use guarding macros - Source files have
.cpp
extension, and includesext.h
at first ext.h
should contain all external includes- Addon code are put into the global namespace
- Prefer
struct
instead ofclass
- Braces are start on new line
- V8 rules apply for casing and structuring of public code
- Classes, public members are Pascal cased
- Functions are Pascal cased
- Public fields could only accessed by methods
- Internal fields and arguments are lower camel cased, any kind of notation could only used for variables, if required
Language of development is ECMAScript 2015 (aka ES6). However ES5 is supported by manually compiled code using Gulp. Library's runtime will autodetect if ES6 is available or not and uses appropriate code path for execution. So with io.js and Node.js 0.12 with harmony, ES6 source will run, so it's advised to use those platforms for development to have ability to debug the original code.
To compile ES5 from ES6 first install Gulp from the npm:
npm install -g gulp
then go to ArrayFire.js' source folder and enter:
gulp
- Library's source files are put to
lib/es6
directory - Unit tests' source files are put to
tests/es6
directory - Examples' source files are put to
examples/es6
directory - File names are written in lower camel case
- Standard JS coding rules apply (that every IDE uses as default)
- All source files must pass ESLint and JSHint validation with the included .eslintrc and .jshintrc rules
- New functionality should be covered by unit tests that must pass on atleast two supported HW platforms at your side
Documentation is generated by MkDocs, and its source files put to documentation
folder. It's not the contributors duty to compile documentation from its sources. However they could see the changes that they are making by installing mkdocs, and enter the following command at ArrayFire.js' documentation
folder:
mkdocs serve
- All functionality covered by documentation
- Functionality changes have to involve appropriate changes in the documentation also
- All documented functionality refer to appropriate chapter of the ArrayFire documentation if available