Skip to content

Commit 01fea9a

Browse files
devvaannshabose
authored andcommitted
docs: refine API docs for files in Command dir
1 parent 8feb8bd commit 01fea9a

File tree

6 files changed

+142
-130
lines changed

6 files changed

+142
-130
lines changed

docs/API-Reference/command/CommandManager.md

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,39 @@
33
const CommandManager = brackets.getModule("command/CommandManager")
44
```
55

6-
<a name="_commands"></a>
6+
<a name="EventDispatcher"></a>
77

8-
## \_commands : <code>Object</code>
9-
Map of all registered global commands
8+
## EventDispatcher
9+
Manages global application commands that can be called from menu items, key bindings, or subparts
10+
of the application.
1011

11-
**Kind**: global variable
12-
**Properties**
12+
This module dispatches these event(s):
13+
- commandRegistered -- when a new command is registered
14+
- beforeExecuteCommand -- before dispatching a command
1315

14-
| Name | Type | Description |
15-
| --- | --- | --- |
16-
| commands | <code>Object.&lt;string, Command&gt;</code> | A map of command IDs to Command objects. |
16+
**Kind**: global constant
17+
<a name="EVENT_BEFORE_EXECUTE_COMMAND"></a>
1718

18-
<a name="_commandsOriginal"></a>
19+
## EVENT\_BEFORE\_EXECUTE\_COMMAND : <code>string</code>
20+
Event triggered before command executes.
1921

20-
## \_commandsOriginal : <code>Object</code>
21-
Temporary copy of commands map for restoring after testingTODO (issue #1039): implement separate require contexts for unit tests
22+
**Kind**: global constant
23+
<a name="SOURCE_KEYBOARD_SHORTCUT"></a>
2224

23-
**Kind**: global variable
24-
**Properties**
25+
## SOURCE\_KEYBOARD\_SHORTCUT : <code>string</code>
26+
Keyboard shortcut trigger.
2527

26-
| Name | Type | Description |
27-
| --- | --- | --- |
28-
| commands | <code>Object.&lt;string, Command&gt;</code> | A map of command IDs to Command objects. |
28+
**Kind**: global constant
29+
<a name="SOURCE_UI_MENU_CLICK"></a>
2930

30-
<a name="EventDispatcher"></a>
31+
## SOURCE\_UI\_MENU\_CLICK : <code>string</code>
32+
UI menu click trigger.
3133

32-
## EventDispatcher
33-
Manages global application commands that can be called from menu items, key bindings, or subpartsof the application.This module dispatches these event(s): - commandRegistered -- when a new command is registered - beforeExecuteCommand -- before dispatching a command
34+
**Kind**: global constant
35+
<a name="SOURCE_OTHER"></a>
36+
37+
## SOURCE\_OTHER : <code>string</code>
38+
Other trigger types.
3439

3540
**Kind**: global constant
3641
<a name="register"></a>
@@ -60,18 +65,6 @@ Registers a global internal only command.
6065
| id | <code>string</code> | unique identifier for command. Core commands in Brackets use a simple command title as an id, for example "app.abort_quit". Extensions should use the following format: "author.myextension.mycommandname". For example, "lschmitt.csswizard.format.css". |
6166
| commandFn | <code>function</code> | the function to call when the command is executed. Any arguments passed to execute() (after the id) are passed as arguments to the function. If the function is asynchronous, it must return a jQuery promise that is resolved when the command completes. Otherwise, the CommandManager will assume it is synchronous, and return a promise that is already resolved. |
6267

63-
<a name="_testReset"></a>
64-
65-
## \_testReset()
66-
Clear all commands for unit testing, but first make copy of commands so thatthey can be restored afterward
67-
68-
**Kind**: global function
69-
<a name="_testRestore"></a>
70-
71-
## \_testRestore()
72-
Restore original commands after test and release copy
73-
74-
**Kind**: global function
7568
<a name="get"></a>
7669

7770
## get(id) ⇒ [<code>Command</code>](#new_Command_new)

docs/API-Reference/command/DefaultMenus.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/API-Reference/command/Menus.md

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -434,29 +434,29 @@ Menu sections are denoted by dividers or the beginning/end of a menu
434434

435435
| Name | Type | Default |
436436
| --- | --- | --- |
437-
| FILE_OPEN_CLOSE_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
438-
| FILE_SAVE_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
439-
| FILE_LIVE | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
440-
| FILE_SETTINGS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
441-
| FILE_EXTENSION_MANAGER | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
442-
| EDIT_UNDO_REDO_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
443-
| EDIT_TEXT_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
444-
| EDIT_SELECTION_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
445-
| EDIT_MODIFY_SELECTION | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
446-
| EDIT_COMMENT_SELECTION | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
447-
| EDIT_CODE_HINTS_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
448-
| EDIT_TOGGLE_OPTIONS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
449-
| FIND_FIND_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
450-
| FIND_FIND_IN_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
451-
| FIND_REPLACE_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
452-
| VIEW_HIDESHOW_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
453-
| VIEW_FONTSIZE_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
454-
| VIEW_TOGGLE_OPTIONS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
455-
| NAVIGATE_GOTO_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
456-
| NAVIGATE_DOCUMENTS_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
457-
| NAVIGATE_OS_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
458-
| NAVIGATE_QUICK_EDIT_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
459-
| NAVIGATE_QUICK_DOCS_COMMANDS | <code>string</code> | <code>&quot;{\&quot;sectionMarker\&quot;:\&quot;\&quot;}&quot;</code> |
437+
| FILE_OPEN_CLOSE_COMMANDS | <code>string</code> | <code>&quot;FILE_OPEN_CLOSE_COMMANDS&quot;</code> |
438+
| FILE_SAVE_COMMANDS | <code>string</code> | <code>&quot;FILE_SAVE_COMMANDS&quot;</code> |
439+
| FILE_LIVE | <code>string</code> | <code>&quot;FILE_LIVE&quot;</code> |
440+
| FILE_SETTINGS | <code>string</code> | <code>&quot;FILE_SETTINGS&quot;</code> |
441+
| FILE_EXTENSION_MANAGER | <code>string</code> | <code>&quot;FILE_EXTENSION_MANAGER&quot;</code> |
442+
| EDIT_UNDO_REDO_COMMANDS | <code>string</code> | <code>&quot;EDIT_UNDO_REDO_COMMANDS&quot;</code> |
443+
| EDIT_TEXT_COMMANDS | <code>string</code> | <code>&quot;EDIT_TEXT_COMMANDS&quot;</code> |
444+
| EDIT_SELECTION_COMMANDS | <code>string</code> | <code>&quot;EDIT_SELECTION_COMMANDS&quot;</code> |
445+
| EDIT_MODIFY_SELECTION | <code>string</code> | <code>&quot;EDIT_MODIFY_SELECTION&quot;</code> |
446+
| EDIT_COMMENT_SELECTION | <code>string</code> | <code>&quot;EDIT_COMMENT_SELECTION&quot;</code> |
447+
| EDIT_CODE_HINTS_COMMANDS | <code>string</code> | <code>&quot;EDIT_CODE_HINTS_COMMANDS&quot;</code> |
448+
| EDIT_TOGGLE_OPTIONS | <code>string</code> | <code>&quot;EDIT_TOGGLE_OPTIONS&quot;</code> |
449+
| FIND_FIND_COMMANDS | <code>string</code> | <code>&quot;FIND_FIND_COMMANDS&quot;</code> |
450+
| FIND_FIND_IN_COMMANDS | <code>string</code> | <code>&quot;FIND_FIND_IN_COMMANDS&quot;</code> |
451+
| FIND_REPLACE_COMMANDS | <code>string</code> | <code>&quot;FIND_REPLACE_COMMANDS&quot;</code> |
452+
| VIEW_HIDESHOW_COMMANDS | <code>string</code> | <code>&quot;VIEW_HIDESHOW_COMMANDS&quot;</code> |
453+
| VIEW_FONTSIZE_COMMANDS | <code>string</code> | <code>&quot;VIEW_FONTSIZE_COMMANDS&quot;</code> |
454+
| VIEW_TOGGLE_OPTIONS | <code>string</code> | <code>&quot;VIEW_TOGGLE_OPTIONS&quot;</code> |
455+
| NAVIGATE_GOTO_COMMANDS | <code>string</code> | <code>&quot;NAVIGATE_GOTO_COMMANDS&quot;</code> |
456+
| NAVIGATE_DOCUMENTS_COMMANDS | <code>string</code> | <code>&quot;NAVIGATE_DOCUMENTS_COMMANDS&quot;</code> |
457+
| NAVIGATE_OS_COMMANDS | <code>string</code> | <code>&quot;NAVIGATE_OS_COMMANDS&quot;</code> |
458+
| NAVIGATE_QUICK_EDIT_COMMANDS | <code>string</code> | <code>&quot;NAVIGATE_QUICK_EDIT_COMMANDS&quot;</code> |
459+
| NAVIGATE_QUICK_DOCS_COMMANDS | <code>string</code> | <code>&quot;NAVIGATE_QUICK_DOCS_COMMANDS&quot;</code> |
460460

461461
<a name="BEFORE"></a>
462462

@@ -500,17 +500,6 @@ Retrieves the ContextMenu object for the corresponding id.
500500
| --- | --- |
501501
| id | <code>string</code> |
502502

503-
<a name="removeMenuItemEventListeners"></a>
504-
505-
## removeMenuItemEventListeners(menuItem)
506-
Removes the attached event listeners from the corresponding object.
507-
508-
**Kind**: global function
509-
510-
| Param | Type |
511-
| --- | --- |
512-
| menuItem | [<code>MenuItem</code>](#MenuItem) |
513-
514503
<a name="getMenuItem"></a>
515504

516505
## getMenuItem(id) ⇒ [<code>MenuItem</code>](#MenuItem)

src/command/CommandManager.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,36 @@ define(function (require, exports, module) {
3434

3535
const EventDispatcher = require("utils/EventDispatcher");
3636

37+
/**
38+
* Event triggered before command executes.
39+
* @constant {string}
40+
*/
3741
const EVENT_BEFORE_EXECUTE_COMMAND = "beforeExecuteCommand";
38-
const SOURCE_KEYBOARD_SHORTCUT = "keyboardShortcut",
39-
SOURCE_UI_MENU_CLICK = "uiMenuClick",
40-
SOURCE_OTHER = "otherExecAction";
42+
43+
/**
44+
* Keyboard shortcut trigger.
45+
* @constant {string}
46+
*/
47+
const SOURCE_KEYBOARD_SHORTCUT = "keyboardShortcut";
48+
49+
/**
50+
* UI menu click trigger.
51+
* @constant {string}
52+
*/
53+
const SOURCE_UI_MENU_CLICK = "uiMenuClick";
54+
55+
/**
56+
* Other trigger types.
57+
* @constant {string}
58+
*/
59+
const SOURCE_OTHER = "otherExecAction";
4160

4261

4362
/**
4463
* Map of all registered global commands
4564
* @type {Object} CommandMap
4665
* @property {Object.<string, Command>} commands - A map of command IDs to Command objects.
66+
* @private
4767
*/
4868
let _commands = {};
4969

@@ -52,6 +72,7 @@ define(function (require, exports, module) {
5272
* TODO (issue #1039): implement separate require contexts for unit tests
5373
* @type {Object} CommandMap
5474
* @property {Object.<string, Command>} commands - A map of command IDs to Command objects.
75+
* @private
5576
*/
5677
let _commandsOriginal = {};
5778

@@ -83,6 +104,7 @@ define(function (require, exports, module) {
83104

84105
/**
85106
* Get command id
107+
* @private
86108
* @return {string}
87109
*/
88110
Command.prototype.getID = function () {
@@ -91,7 +113,7 @@ define(function (require, exports, module) {
91113

92114
/**
93115
* Executes the command. Additional arguments are passed to the executing function
94-
*
116+
* @private
95117
* @return {$.Promise} a jQuery promise that will be resolved when the command completes.
96118
*/
97119
Command.prototype.execute = function () {
@@ -120,6 +142,7 @@ define(function (require, exports, module) {
120142

121143
/**
122144
* Is command enabled?
145+
* @private
123146
* @return {boolean}
124147
*/
125148
Command.prototype.getEnabled = function () {
@@ -129,6 +152,7 @@ define(function (require, exports, module) {
129152
/**
130153
* Sets enabled state of Command and dispatches "enabledStateChange"
131154
* when the enabled state changes.
155+
* @private
132156
* @param {boolean} enabled
133157
*/
134158
Command.prototype.setEnabled = function (enabled) {
@@ -143,6 +167,7 @@ define(function (require, exports, module) {
143167
/**
144168
* Sets enabled state of Command and dispatches "checkedStateChange"
145169
* when the enabled state changes.
170+
* @private
146171
* @param {boolean} checked
147172
*/
148173
Command.prototype.setChecked = function (checked) {
@@ -156,6 +181,7 @@ define(function (require, exports, module) {
156181

157182
/**
158183
* Is command checked?
184+
* @private
159185
* @return {boolean}
160186
*/
161187
Command.prototype.getChecked = function () {
@@ -169,7 +195,7 @@ define(function (require, exports, module) {
169195
* Note, a Command name can appear in either HTML or native UI
170196
* so HTML tags should not be used. To add a Unicode character,
171197
* use \uXXXX instead of an HTML entity.
172-
*
198+
* @private
173199
* @param {string} name
174200
*/
175201
Command.prototype.setName = function (name) {
@@ -183,6 +209,7 @@ define(function (require, exports, module) {
183209

184210
/**
185211
* Get command name
212+
* @private
186213
* @return {string}
187214
*/
188215
Command.prototype.getName = function () {
@@ -259,6 +286,7 @@ define(function (require, exports, module) {
259286
/**
260287
* Clear all commands for unit testing, but first make copy of commands so that
261288
* they can be restored afterward
289+
* @private
262290
*/
263291
function _testReset() {
264292
_commandsOriginal = _commands;
@@ -267,6 +295,7 @@ define(function (require, exports, module) {
267295

268296
/**
269297
* Restore original commands after test and release copy
298+
* @private
270299
*/
271300
function _testRestore() {
272301
_commands = _commandsOriginal;

src/command/DefaultMenus.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
/*global Phoenix*/
2323

24-
// @INCLUDE_IN_API_DOCS
25-
2624
/**
2725
* Initializes the default brackets menu items.
2826
*/

0 commit comments

Comments
 (0)