-
Notifications
You must be signed in to change notification settings - Fork 669
VexFlow Coding Style
0xFE edited this page Mar 31, 2014
·
11 revisions
- Code must be readable.
- Code must be testable.
- In general, try to stick with the conventions in the existing code.
- No hard-tabs. Use 2 spaces.
- Comments get preprocessed through Docco. This allows Markdown in comments.
- Take a look at
src/accidentals.js
for commenting boilerplate.- In particular, note the header at the top of the file.
- If you contributed significantly to the file, feel free to add an "Author:" comment below the copyright.
- All methods and parameters must be documented.
- Run
rake docs
to regenerate the documentation indocs/
. - Take a look at docs/accidental.html for an example of a generated document.
- Respect API boundaries. If you don't want your code to break, don't reach into its internals. E.g., prefer
note.getStave()
tonote.stave
. - Run
rake lint
before sending in a pull request.
If you're writing code that requires a new file, e.g., a new element, class, modifier, etc.
- Create the
.js
file insrc/
- Add the file to
base_sources
inRakefile
. - Add a test file to
tests/
.- If your file was called
slurs.js
the test file should beslurs_test.js
. - Use
tests/textnote_test.js
as a template.
- If your file was called
- Include the test
.js
totests/flow.html
and addVex.Flow.Test.YourTest.Start()
to the document load function (also inflow.html
.) - Run
rake
andrake docs
and ensure that the output is correct.
[ VexFlow.com ] [ API ] [ GitHub Repo ] [ Contributors ]