Forráskód Böngészése

adjustments to the documentation according to naming convention. Old: "Cmd[..].js" new: "[..]Command.js"

Mario Schuettel 9 éve
szülő
commit
0810617239

+ 11 - 11
editor/docs/Implementing additional commands for undo-redo.md

@@ -12,7 +12,7 @@ It would also be possible to only store the difference between the old and the n
 
 **Before implementing your own command you should look if you can't reuse one of the already existing ones.**
 
-For numbers, strings or booleans the CmdSet...Value-commands can be used.
+For numbers, strings or booleans the Set...ValueCommand-commands can be used.
 Then there are separate commands for:
 - setting a color property (THREE.Color)
 - setting maps (THREE.Texture)
@@ -26,12 +26,12 @@ Every command needs a constructor. In the constructor
 
 ```javascript
 	
-CmdXXX = function () {
+DoSomethingCommand = function () {
 
 	Command.call( this ); // Required: Call default constructor
 
-	this.type = 'CmdXXX';            // Required: has to match the object-name!
-	this.name = 'Set/Do/Update XXX'; // Required: description of the command, used in Sidebar.History
+	this.type = 'DoSomethingCommand';            // Required: has to match the object-name!
+	this.name = 'Set/Do/Update DoSomething'; // Required: description of the command, used in Sidebar.History
 
 	// TODO: store all the relevant information needed to 
 	// restore the old and the new state
@@ -46,7 +46,7 @@ And as part of the prototype you need to implement four functions
 - **fromJSON:** which deserializes the command
 
 ```javascript
-CmdXXX.prototype = {
+DoSomethingCommand.prototype = {
 
 	execute: function () {
 
@@ -66,7 +66,7 @@ CmdXXX.prototype = {
 
 		// TODO: serialize all the necessary information as part of 'output' (JSON-format)
 		// so that it can be restored in 'fromJSON'
-	
+
 		return output;
 
 	},
@@ -74,9 +74,9 @@ CmdXXX.prototype = {
 	fromJSON: function ( json ) {
 
 		Command.prototype.fromJSON.call( this, json ); // Required: Call 'fromJSON'-method of prototype 'Command'
-		
+
 		// TODO: restore command from json
-		
+
 	}
 
 };
@@ -89,9 +89,9 @@ To execute a command we need an instance of the main editor-object. The editor-o
 On **editor** we then call **.execute(...)*** with the new command-object which in turn calls **history.execute(...)** and adds the command to the undo-stack.
 
 ```javascript
-	
-editor.execute( new CmdXXX() );
-		
+
+editor.execute( new DoSomethingCommand() );
+
 ```
 
 ### Updatable commands ###

+ 14 - 14
editor/docs/Writing unit tests for undo-redo commands.md

@@ -16,19 +16,19 @@ Each of the listed steps will now be described in detail.
 
 ### 1. Create a new unit test file ###
 
-Create a new file in path `test/unit/editor/TestCmdXXX.js`.
+Create a new file in path `test/unit/editor/TestDoSomethingCommand.js`.
 
 ### 2. Include the new command in the editor test suite ###
 
 Navigate to the editor test suite `test/unit/unittests_editor.html` and open it.
 Within the file, go to the `<!-- command object classes -->` and include the new command:
 
-```javascript
+```html
 // <!-- command object classes -->
 //...
-<script src="../../editor/js/SetUuidCommand.js"></script>
-<script src="../../editor/js/SetValueCommand.js"></script>
-<script src="../../editor/js/CmdXXX.js"></script>         // add this line
+<script src="../../editor/js/AddScriptCommand.js"></script>
+<script src="../../editor/js/DoSomethingCommand.js"></script>         // add this line
+<script src="../../editor/js/MoveObjectCommand.js"></script>
 //...
 ```
 
@@ -36,12 +36,12 @@ It is recommended to keep the script inclusions in alphabetical order, if possib
 
 Next, in the same file, go to `<!-- Undo-Redo tests -->` and include the test file for the new command:
 
-```javascript
+```html
 // <!-- Undo-Redo tests -->
 //...
-<script src="editor/TestSetValueCommand.js"></script>
-<script src="editor/TestCmdXXX.js"></script>              // add this line
-<script src="editor/TestNestedDoUndoRedo.js"></script>
+<script src="editor/TestAddScriptCommand.js"></script>
+<script src="editor/TestDoSomethingCommand.js"></script>              // add this line
+<script src="editor/TestMoveObjectCommand.js"></script>
 //...
 ```
 
@@ -51,12 +51,12 @@ Again, keeping the alphabetical order is recommended.
 
 #### Template ####
 
-Open the unit test file `test/unit/editor/TestCmdXXX.js` and paste following code:
+Open the unit test file `test/unit/editor/TestDoSomethingCommand.js` and paste following code:
 
 ```javascript
-module( "CmdXXX" );
+module( "DoSomethingCommand" );
 
-test("Test CmdXXX (Undo and Redo)", function() {
+test("Test DoSomethingCommand (Undo and Redo)", function() {
 
     var editor = new Editor();
 
@@ -74,13 +74,13 @@ test("Test CmdXXX (Undo and Redo)", function() {
     // your test begins here...
 
 
-});
+} );
 ```
 
 The predefined code is just meant to ease the development, you do not have to stick with it.
 However, the test should cover at least one `editor.execute()`, one `editor.undo()` and one `editor.redo()` call.
 
-Best practice is to call `editor.execute( new CmdXXX( {custom parameters} ) )` **twice**. Since you'll have to do one undo (go one step back), it is recommended to have a custom state for comparison. Try to avoid assertions `ok()` against default values.
+Best practice is to call `editor.execute( new DoSomethingCommand( {custom parameters} ) )` **twice**. Since you'll have to do one undo (go one step back), it is recommended to have a custom state for comparison. Try to avoid assertions `ok()` against default values.
 
 #### Assertions ####
 After performing `editor.execute()` twice, you can do your first assertion to check whether the executes are done correctly.