Skip to content

Commit eecb384

Browse files
devvaannshabose
authored andcommitted
docs: refine API docs for files in Preferences dir
1 parent aaa67ad commit eecb384

File tree

6 files changed

+252
-222
lines changed

6 files changed

+252
-222
lines changed

docs/API-Reference/preferences/PreferencesBase.md

Lines changed: 149 additions & 198 deletions
Large diffs are not rendered by default.

docs/API-Reference/preferences/PreferencesDialogs.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@ const PreferencesDialogs = brackets.getModule("preferences/PreferencesDialogs")
99
PreferencesDialogs
1010

1111
**Kind**: global variable
12-
<a name="_validateBaseUrl"></a>
13-
14-
## \_validateBaseUrl(url) ⇒ <code>string</code>
15-
Validate that text string is a valid base url which should map to a server folder
16-
17-
**Kind**: global function
18-
**Returns**: <code>string</code> - Empty string if valid, otherwise error string
19-
20-
| Param | Type |
21-
| --- | --- |
22-
| url | <code>string</code> |
23-
2412
<a name="showProjectPreferencesDialog"></a>
2513

2614
## showProjectPreferencesDialog(baseUrl, errorMessage) ⇒ <code>Dialog</code>
2715
Show a dialog that shows the project preferences
2816

2917
**Kind**: global function
30-
**Returns**: <code>Dialog</code> - A Dialog object with an internal promise that will be resolved with the ID of the clicked button when the dialog is dismissed. Never rejected.
18+
**Returns**: <code>Dialog</code> - A Dialog object with an internal promise that will be resolved with the ID
19+
of the clicked button when the dialog is dismissed. Never rejected.
3120

3221
| Param | Type | Description |
3322
| --- | --- | --- |

docs/API-Reference/preferences/StateManager.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ const StateManager = brackets.getModule("preferences/StateManager")
88
## \_
99
StateManager
1010

11+
**Kind**: global constant
12+
<a name="PROJECT_CONTEXT"></a>
13+
14+
## PROJECT\_CONTEXT : <code>string</code>
15+
Project specific context
16+
17+
**Kind**: global constant
18+
<a name="GLOBAL_CONTEXT"></a>
19+
20+
## GLOBAL\_CONTEXT : <code>string</code>
21+
Global context
22+
23+
**Kind**: global constant
24+
<a name="PROJECT_THEN_GLOBAL_CONTEXT"></a>
25+
26+
## PROJECT\_THEN\_GLOBAL\_CONTEXT : <code>string</code>
27+
Project or global context
28+
1129
**Kind**: global constant
1230
<a name="getVal"></a>
1331

@@ -43,7 +61,10 @@ Convenience function that sets a view state and then saves the file
4361
<a name="definePreferenceInternal"></a>
4462

4563
## definePreferenceInternal(id, type, initial, options) ⇒ <code>Object</code>
46-
returns a preference instance that can be listened `.on("change", cbfn(changeType))` . The callback fucntion will be calledwhenever there is a change in the supplied id with a changeType argument. The change type can be one of the two:CHANGE_TYPE_INTERNAL - if change is made within the current app window/browser tapCHANGE_TYPE_EXTERNAL - if change is made in a different app window/browser tab
64+
returns a preference instance that can be listened `.on("change", cbfn(changeType))` . The callback fucntion will be called
65+
whenever there is a change in the supplied id with a changeType argument. The change type can be one of the two:
66+
CHANGE_TYPE_INTERNAL - if change is made within the current app window/browser tap
67+
CHANGE_TYPE_EXTERNAL - if change is made in a different app window/browser tab
4768

4869
**Kind**: global function
4970

@@ -54,3 +75,32 @@ returns a preference instance that can be listened `.on("change", cbfn(changeTyp
5475
| initial |
5576
| options |
5677

78+
<a name="getPreferenceInternal"></a>
79+
80+
## getPreferenceInternal(id) ⇒ <code>Object</code>
81+
Get the preference instance for the given ID.
82+
83+
**Kind**: global function
84+
85+
| Param | Type |
86+
| --- | --- |
87+
| id | <code>string</code> |
88+
89+
<a name="createExtensionStateManager"></a>
90+
91+
## createExtensionStateManager(extensionID) ⇒ <code>object</code>
92+
create a state manager for an extension.
93+
ensure that the IDs are unique.
94+
95+
**Kind**: global function
96+
**Returns**: <code>object</code> - Object with methods to manage the extension's state and preferences.
97+
- `get(id, context)`: Get the value from the extension's state.
98+
- `set(id, value, context)`: Set the value in the extension's state.
99+
- `definePreference(id, type, initial, options)`: define a preference for the extension.
100+
- `getPreference(id)`: retrieve a defined preference.
101+
- `PROJECT_CONTEXT`, `GLOBAL_CONTEXT`, `PROJECT_THEN_GLOBAL_CONTEXT`: constant for context management.
102+
103+
| Param | Type |
104+
| --- | --- |
105+
| extensionID | <code>string</code> |
106+

src/preferences/PreferencesBase.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ define(function (require, exports, module) {
131131
* Error type for problems parsing preference files.
132132
*
133133
* @constructor
134+
* @private
134135
* @param {string} message Error message
135136
*/
136137
function ParsingError(message) {
@@ -1022,7 +1023,7 @@ define(function (require, exports, module) {
10221023

10231024
/**
10241025
* Represents a single, known Preference.
1025-
*
1026+
* @private
10261027
* @constructor
10271028
* @param {Object} properties Information about the Preference that is stored on this object
10281029
*/
@@ -1037,6 +1038,7 @@ define(function (require, exports, module) {
10371038
* Utility for PreferencesSystem & PrefixedPreferencesSystem -- attach EventDispatcher's on()/off()
10381039
* implementation as private _on_internal()/_off_internal() methods, so the custom on()/off() APIs
10391040
* these classes use can leverage EventDispatcher code internally. Also attach the regular public trigger().
1041+
* @private
10401042
*/
10411043
function _addEventDispatcherImpl(proto) {
10421044
var temp = {};
@@ -1049,7 +1051,7 @@ define(function (require, exports, module) {
10491051
/**
10501052
* Provides a subset of the PreferencesSystem functionality with preference
10511053
* access always occurring with the given prefix.
1052-
*
1054+
* @private
10531055
* @constructor
10541056
* @param {PreferencesSystem} base The real PreferencesSystem that is backing this one
10551057
* @param {string} prefix Prefix that is used for preferences lookup. Any separator characters should already be added.
@@ -1063,7 +1065,7 @@ define(function (require, exports, module) {
10631065
PrefixedPreferencesSystem.prototype = {
10641066
/**
10651067
* Defines a new (prefixed) preference.
1066-
*
1068+
* @private
10671069
* @param {string} id unprefixed identifier of the preference. Generally a dotted name.
10681070
* @param {string} type Data type for the preference (generally, string, boolean, number)
10691071
* @param {Object} initial Default value for the preference
@@ -1084,7 +1086,7 @@ define(function (require, exports, module) {
10841086

10851087
/**
10861088
* Get the prefixed preference object
1087-
*
1089+
* @private
10881090
* @param {string} id ID of the pref to retrieve.
10891091
*/
10901092
getPreference: function (id) {
@@ -1093,7 +1095,7 @@ define(function (require, exports, module) {
10931095

10941096
/**
10951097
* Gets the prefixed preference
1096-
*
1098+
* @private
10971099
* @param {string} id Name of the preference for which the value should be retrieved
10981100
* @param {Object=} context Optional context object to change the preference lookup
10991101
*/
@@ -1104,7 +1106,7 @@ define(function (require, exports, module) {
11041106

11051107
/**
11061108
* Gets the location in which the value of a prefixed preference has been set.
1107-
*
1109+
* @private
11081110
* @param {string} id Name of the preference for which the value should be retrieved
11091111
* @param {Object=} context Optional context object to change the preference lookup
11101112
* @return {{scope: string, layer: ?string, layerID: ?object}} Object describing where the preferences came from
@@ -1115,7 +1117,7 @@ define(function (require, exports, module) {
11151117

11161118
/**
11171119
* Sets the prefixed preference.
1118-
*
1120+
* @private
11191121
* @param {string} id - The identifier of the preference to set.
11201122
* @param {Object} value - The new value for the preference.
11211123
* @param {{location: ?Object, context: ?Object}=} options - Specific location to set the value or context for the operation.
@@ -1168,7 +1170,7 @@ define(function (require, exports, module) {
11681170
/**
11691171
* Sets up a listener for events for this PrefixedPreferencesSystem. Only prefixed events
11701172
* will notify. Optionally, you can set up a listener for a specific preference.
1171-
*
1173+
* @private
11721174
* @param {string} event Name of the event to listen for
11731175
* @param {string|Function} preferenceID Name of a specific preference or the handler function
11741176
* @param {?Function} handler Handler for the event
@@ -1191,7 +1193,7 @@ define(function (require, exports, module) {
11911193
/**
11921194
* Turns off the event handlers for a given event, optionally for a specific preference
11931195
* or a specific handler function.
1194-
*
1196+
* @private
11951197
* @param {string} event Name of the event for which to turn off listening
11961198
* @param {string|Function} preferenceID Name of a specific preference or the handler function
11971199
* @param {?Function} handler Specific handler which should stop being notified
@@ -1213,7 +1215,7 @@ define(function (require, exports, module) {
12131215
/**
12141216
* Saves the preferences. If a save is already in progress, a Promise is returned for
12151217
* that save operation.
1216-
*
1218+
* @private
12171219
* @return {Promise} Resolved when the preferences are done saving.
12181220
*/
12191221
save: function () {

src/preferences/PreferencesDialogs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ define(function (require, exports, module) {
4040

4141
/**
4242
* Validate that text string is a valid base url which should map to a server folder
43+
* @private
4344
* @param {string} url
4445
* @return {string} Empty string if valid, otherwise error string
4546
*/

src/preferences/StateManager.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,27 @@ define(function (require, exports, module) {
3333
EventDispatcher = require("utils/EventDispatcher"),
3434
ProjectManager = require("project/ProjectManager");
3535

36+
/**
37+
* Project specific context
38+
* @const
39+
* @type {string}
40+
*/
3641
const PROJECT_CONTEXT = "project";
42+
43+
/**
44+
* Global context
45+
* @const
46+
* @type {string}
47+
*/
3748
const GLOBAL_CONTEXT = "global";
49+
50+
/**
51+
* Project or global context
52+
* @const
53+
* @type {string}
54+
*/
3855
const PROJECT_THEN_GLOBAL_CONTEXT = "any";
56+
3957
const PHSTORE_STATEMANAGER_PREFIX = "STATE_";
4058
const transformDotsInID = {};
4159

@@ -185,6 +203,12 @@ define(function (require, exports, module) {
185203
return preference;
186204
}
187205

206+
/**
207+
* Get the preference instance for the given ID.
208+
*
209+
* @param {string} id
210+
* @returns {{}}
211+
*/
188212
function getPreferenceInternal(id) {
189213
if(!definedPreferences[id]){
190214
throw new Error("getPreference " + id + " no such preference defined.");
@@ -193,6 +217,19 @@ define(function (require, exports, module) {
193217
}
194218

195219
const knownExtensions = {};
220+
221+
/**
222+
* create a state manager for an extension.
223+
* ensure that the IDs are unique.
224+
*
225+
* @param {string} extensionID
226+
* @returns {object} Object with methods to manage the extension's state and preferences.
227+
* - `get(id, context)`: Get the value from the extension's state.
228+
* - `set(id, value, context)`: Set the value in the extension's state.
229+
* - `definePreference(id, type, initial, options)`: define a preference for the extension.
230+
* - `getPreference(id)`: retrieve a defined preference.
231+
* - `PROJECT_CONTEXT`, `GLOBAL_CONTEXT`, `PROJECT_THEN_GLOBAL_CONTEXT`: constant for context management.
232+
*/
196233
function createExtensionStateManager(extensionID) {
197234
let i=0;
198235
if(extensionID.includes(".")){

0 commit comments

Comments
 (0)