소스 검색

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

Mario Schuettel 9 년 전
부모
커밋
0810617239
2개의 변경된 파일25개의 추가작업 그리고 25개의 파일을 삭제
  1. 11 11
      editor/docs/Implementing additional commands for undo-redo.md
  2. 14 14
      editor/docs/Writing unit tests for undo-redo commands.md

+ 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.**
 **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:
 Then there are separate commands for:
 - setting a color property (THREE.Color)
 - setting a color property (THREE.Color)
 - setting maps (THREE.Texture)
 - setting maps (THREE.Texture)
@@ -26,12 +26,12 @@ Every command needs a constructor. In the constructor
 
 
 ```javascript
 ```javascript
 	
 	
-CmdXXX = function () {
+DoSomethingCommand = function () {
 
 
 	Command.call( this ); // Required: Call default constructor
 	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 
 	// TODO: store all the relevant information needed to 
 	// restore the old and the new state
 	// 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
 - **fromJSON:** which deserializes the command
 
 
 ```javascript
 ```javascript
-CmdXXX.prototype = {
+DoSomethingCommand.prototype = {
 
 
 	execute: function () {
 	execute: function () {
 
 
@@ -66,7 +66,7 @@ CmdXXX.prototype = {
 
 
 		// TODO: serialize all the necessary information as part of 'output' (JSON-format)
 		// TODO: serialize all the necessary information as part of 'output' (JSON-format)
 		// so that it can be restored in 'fromJSON'
 		// so that it can be restored in 'fromJSON'
-	
+
 		return output;
 		return output;
 
 
 	},
 	},
@@ -74,9 +74,9 @@ CmdXXX.prototype = {
 	fromJSON: function ( json ) {
 	fromJSON: function ( json ) {
 
 
 		Command.prototype.fromJSON.call( this, json ); // Required: Call 'fromJSON'-method of prototype 'Command'
 		Command.prototype.fromJSON.call( this, json ); // Required: Call 'fromJSON'-method of prototype 'Command'
-		
+
 		// TODO: restore command from json
 		// 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.
 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
 ```javascript
-	
-editor.execute( new CmdXXX() );
-		
+
+editor.execute( new DoSomethingCommand() );
+
 ```
 ```
 
 
 ### Updatable commands ###
 ### 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 ###
 ### 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 ###
 ### 2. Include the new command in the editor test suite ###
 
 
 Navigate to the editor test suite `test/unit/unittests_editor.html` and open it.
 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:
 Within the file, go to the `<!-- command object classes -->` and include the new command:
 
 
-```javascript
+```html
 // <!-- command object classes -->
 // <!-- 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:
 Next, in the same file, go to `<!-- Undo-Redo tests -->` and include the test file for the new command:
 
 
-```javascript
+```html
 // <!-- Undo-Redo tests -->
 // <!-- 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 ####
 #### 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
 ```javascript
-module( "CmdXXX" );
+module( "DoSomethingCommand" );
 
 
-test("Test CmdXXX (Undo and Redo)", function() {
+test("Test DoSomethingCommand (Undo and Redo)", function() {
 
 
     var editor = new Editor();
     var editor = new Editor();
 
 
@@ -74,13 +74,13 @@ test("Test CmdXXX (Undo and Redo)", function() {
     // your test begins here...
     // your test begins here...
 
 
 
 
-});
+} );
 ```
 ```
 
 
 The predefined code is just meant to ease the development, you do not have to stick with it.
 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.
 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 ####
 #### Assertions ####
 After performing `editor.execute()` twice, you can do your first assertion to check whether the executes are done correctly.
 After performing `editor.execute()` twice, you can do your first assertion to check whether the executes are done correctly.