mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-18 07:44:51 +00:00
1a95ec9ac4
Thanks to @cjrk and @cheigele for contributing their developer docs (which can be found at https://github.com/cjrk/saa-tw). By the way, I plan to remove the “creator” and “modifier” fields but will keep a prominent acknowledgement for your contributions.
41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
title: TiddlyWiki Coding Style Guidelines
|
|
tags: dev
|
|
|
|
! Motivation
|
|
|
|
TiddlyWiki is a large project with many interested parties. It benefits everyone if the code is as easy to read as possible. A key part of that it must be written and laid out consistently -- the code should read as though it were written by a single author.
|
|
|
|
! Guidelines
|
|
|
|
!! Tabs and whitespace
|
|
|
|
TiddlyWiki uses 4-character tabs for indenting.
|
|
|
|
One blank line is used to separate blocks of code. Occasional blank lines are permitted within blocks for clarity, but should be avoided unless they solve a specific readability problem.
|
|
|
|
!! Layout of basic constructs
|
|
|
|
See the following example for layout of basic JavaScript constructs:
|
|
|
|
```
|
|
/*
|
|
Multiline comments are used to introduce a block of code such as a function definition
|
|
*/
|
|
function demoFunction(param,more) {
|
|
// Proper sentence capitalisation for comments
|
|
if(condition == "something") {
|
|
// No space between "if" and the brackets; always spaces around binary operators
|
|
something = somethingElse;
|
|
myOtherFunction(one,two); // No whitespace within function parameters
|
|
do {
|
|
myCondition.explore(); // Always use semicolons
|
|
} while(myCondition < worsens);
|
|
}
|
|
}
|
|
|
|
```
|
|
|
|
!! Strings
|
|
|
|
Double quotes are preferred over single quotes for string literals.
|