Skip to content

Commit bf2d1fa

Browse files
devvaannshabose
authored andcommitted
fix: syntax highlighting in docs site
1 parent fb9cfcc commit bf2d1fa

14 files changed

+65
-4
lines changed

build/api-docs-generator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,13 @@ function mdxFileModifications() {
461461
// for example NodeConnector.mdx
462462
if (directoryName.endsWith('.mdx')) {
463463
importStatement =
464-
`### Import :\n\`\`\`\n` +
464+
`### Import :\n\`\`\`js\n` +
465465
`brackets.getModule("${fileNameWithoutExt}")\n` +
466466
`\`\`\`\n`;
467467
} else {
468468
importStatement =
469-
`### Import :\n\`\`\`\n` +
470-
`brackets.getModule("${directoryName}/${fileNameWithoutExt}")\n` +
469+
`### Import :\n\`\`\`js\n` +
470+
`brackets.getModule("${fileNameWithoutExt}")\n` +
471471
`\`\`\`\n`;
472472
}
473473

src/NodeConnector.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*
3636
* ### Create `NodeConnector` in Phoenix (`x.js`)
3737
*
38+
* @example
3839
* ```js
3940
* const NodeConnector = require('NodeConnector');
4041
* const XY_NODE_CONNECTOR_ID = 'ext_x_y'; // Use a unique ID
@@ -52,6 +53,7 @@
5253
*
5354
* ### Create `NodeConnector` in Node.js (`y.js`)
5455
*
56+
* @example
5557
* ```js
5658
* const XY_NODE_CONNECTOR_ID = 'ext_x_y'; // Use the same unique ID
5759
* let nodeConnector = global.createNodeConnector(XY_NODE_CONNECTOR_ID, exports);
@@ -67,13 +69,15 @@
6769
*
6870
* To call a Node.js function from Phoenix, use the `execPeer` method.
6971
*
72+
* @example
7073
* ```js
7174
* // In `x.js` (Phoenix)
7275
* const fullPath = await nodeConnector.execPeer('getPWDRelative', 'sub/path.html');
7376
* ```
7477
*
7578
* To execute a Phoenix function from Node.js and transfer binary data, pass an optional ArrayBuffer.
7679
*
80+
* @example
7781
* ```js
7882
* // In `y.js` (Node.js)
7983
* const { operationDone, buffer } = await nodeConnector.execPeer('modifyImage', {name:'theHills.png'}, imageAsArrayBuffer);
@@ -84,6 +88,7 @@
8488
* The `NodeConnector` object implements all the APIs supported by `utils/EventDispatcher`. You can trigger and listen
8589
* to events between Node.js and Phoenix using the `triggerPeer` and (`on`, `one` or `off`) methods.
8690
*
91+
* @example
8792
* ```js
8893
* // In `y.js` (Node.js)
8994
* nodeConnector.on('phoenixProjectOpened', (_event, projectPath) => {
@@ -97,12 +102,14 @@
97102
*
98103
* To raise an event from Phoenix to Node.js:
99104
*
105+
* @example
100106
* ```js
101107
* // In `x.js` (Phoenix)
102108
* nodeConnector.triggerPeer('phoenixProjectOpened', '/x/project/folder');
103109
* ```
104110
*
105111
* To Switch off events
112+
* @example
106113
* ```js
107114
* nodeConnector.off('phoenixProjectOpened'); // will switch off all event handlers of that name.
108115
* ```
@@ -117,6 +124,7 @@
117124
*
118125
* Example of calling a function in Node.js with binary data transfer:
119126
*
127+
* @example
120128
* ```js
121129
* // In `y.js` (Node.js)
122130
* const { operationDone, buffer } = await nodeConnector.execPeer('modifyImage', {name:'name.png'}, imageArrayBuffer);
@@ -128,6 +136,7 @@
128136
*
129137
* Example of sending binary data in an event from Phoenix to Node.js:
130138
*
139+
* @example
131140
* ```js
132141
* // In `x.js` (Phoenix)
133142
* const imageArrayBuffer = getSomeImageArrayBuffer(); // Get the ArrayBuffer

src/features/BeautificationManager.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* ### registerBeautificationProvider
2828
* Register a Beautification provider with this api.
2929
*
30+
* @example
3031
* ```js
3132
* // syntax
3233
* BeautificationManager.registerBeautificationProvider(provider, supportedLanguages, priority);
@@ -38,6 +39,7 @@
3839
* 1. `priority`: Used to break ties among providers for a particular language. Providers with a higher number
3940
* will be asked for beatified code before those with a lower priority value. Defaults to zero.
4041
*
42+
* @example
4143
* ```js
4244
* // to register a provider that will be invoked for all languages. where provider is any object that implements
4345
* // a `beautifyEditorProvider` and `beautifyTextProvider` function
@@ -49,6 +51,8 @@
4951
*
5052
* ### removeBeautificationProvider
5153
* Removes a registered Beautification provider. The API takes the same arguments as `registerBeautificationProvider`.
54+
*
55+
* @example
5256
* ```js
5357
* // syntax
5458
* BeautificationManager.removeBeautificationProvider(provider, supportedLanguages);
@@ -59,6 +63,8 @@
5963
* ### provider.beautifyEditorProvider
6064
* Each provider must implement the `beautifyEditorProvider` function that returns a promise. The promise either resolves with
6165
* the beautified code details or rejects if there is nothing to beautify for the provider.
66+
*
67+
* @example
6268
* ```js
6369
* // function signature
6470
* provider.beautifyEditorProvider = function(editor) {
@@ -97,6 +103,8 @@
97103
* Each provider must implement the `beautifyTextProvider` function that returns a promise.
98104
* The promise either resolves with the beautified code details(same as beautifyEditorProvider) or rejects if
99105
* there is nothing to beautify for the provider.
106+
*
107+
* @example
100108
* ```js
101109
* // function signature.
102110
* provider.beautifyTextProvider = function(textToBeautify, filePathOrFileName) {

src/features/NewFileContentManager.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*
2929
* ## Usage
3030
* Let's say whenever a user creates a new js file, we have to prefill the contents to "sample content"
31+
*
32+
* @example
3133
* ```js
3234
* const NewFileContentManager = brackets.getModule("features/NewFileContentManager");
3335
* // replace `js` with language ID(Eg. javascript) if you want to restrict the preview to js files only. use `all` for
@@ -48,6 +50,7 @@
4850
* ### registerContentProvider
4951
* Register a Content provider with this api.
5052
*
53+
* @example
5154
* ```js
5255
* // syntax
5356
* NewFileContentManager.registerContentProvider(provider, supportedLanguages, priority);
@@ -59,6 +62,7 @@
5962
* 1. `priority`: Contents provided hy providers with higher priority will win if there are more than
6063
* one provider registered for the language. Default is 0.
6164
*
65+
* @example
6266
* ```js
6367
* // to register a provider that will be invoked for all languages. where provider is any object that implements
6468
* // a getContent function
@@ -70,6 +74,8 @@
7074
*
7175
* ### removeContentProvider
7276
* Removes a registered content provider. The API takes the same arguments as `registerContentProvider`.
77+
*
78+
* @example
7379
* ```js
7480
* // syntax
7581
* NewFileContentManager.removeContentProvider(provider, supportedLanguages);
@@ -80,6 +86,8 @@
8086
* ### provider.getContent
8187
* Each provider must implement the `getContent` function that returns a promise. The promise either resolves with
8288
* the content text or rejects if there is no content made available by the provider.
89+
*
90+
* @example
8391
* ```js
8492
* exports.CONTENT_PROVIDER_NAME = "extension.someName"; // for debugging
8593
* // function signature

src/features/QuickViewManager.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
* ## Usage
4141
* Lets build a "hello world" extension that displays "hello world" on hover over a text in the editor.
4242
* In your extension file, add the following code:
43+
*
44+
* @example
4345
* ```js
4446
* const QuickViewManager = brackets.getModule("features/QuickViewManager");
4547
* // replace `all` with language ID(Eg. javascript) if you want to restrict the preview to js files only.
@@ -77,6 +79,7 @@
7779
* ### registerQuickViewProvider
7880
* Register a QuickView provider with this api.
7981
*
82+
* @example
8083
* ```js
8184
* // syntax
8285
* QuickViewManager.registerQuickViewProvider(provider, supportedLanguages);
@@ -86,6 +89,8 @@
8689
* 1. `supportedLanguages`: An array of languages that the QuickView supports. If `["all"]` is supplied, then the
8790
* QuickView will be invoked for all languages. Restrict to specific languages: Eg: `["javascript", "html", "php"]`
8891
*
92+
*
93+
* @example
8994
* ```js
9095
* // to register a provider that will be invoked for all languages. where provider is any object that implements
9196
* // a getQuickView function
@@ -97,6 +102,8 @@
97102
*
98103
* ### removeQuickViewProvider
99104
* Removes a registered QuickView provider. The API takes the same arguments as `registerQuickViewProvider`.
105+
*
106+
* @example
100107
* ```js
101108
* // syntax
102109
* QuickViewManager.removeQuickViewProvider(provider, supportedLanguages);
@@ -107,6 +114,8 @@
107114
* ### getQuickView
108115
* Each provider must implement the `getQuickView` function that returns a promise. The promise either resolves with
109116
* the quick view details object(described below) or rejects if there is no preview for the position.
117+
*
118+
* @example
110119
* ```js
111120
* // function signature
112121
* provider.getQuickView = function(editor, pos, token, line) {
@@ -156,6 +165,8 @@
156165
* Each provider can optionally implement the `filterQuickView` function to control what among the available
157166
* quick views should be rendered if multiple providers responded with a QuickView. The function will be called
158167
* once all `getQuickView` providers provided a valid preview object.
168+
*
169+
* @example
159170
* ```js
160171
* // function signature
161172
* provider.filterQuickView = function(popovers) {

src/features/SelectionViewManager.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* ## Usage
4242
* Lets build a "hello world" extension that displays "hello world" above selected text in the editor.
4343
* In your extension file, add the following code:
44+
*
45+
* @example
4446
* ```js
4547
* const SelectionViewManager = brackets.getModule("features/SelectionViewManager");
4648
* // replace `all` with language ID(Eg. javascript) if you want to restrict the preview to js files only.
@@ -69,6 +71,7 @@
6971
* ### registerSelectionViewProvider
7072
* Register a SelectionView provider with this api.
7173
*
74+
* @example
7275
* ```js
7376
* // syntax
7477
* SelectionViewManager.registerSelectionViewProvider(provider, supportedLanguages);
@@ -78,6 +81,7 @@
7881
* 1. `supportedLanguages`: An array of languages that the SelectionView supports. If `["all"]` is supplied, then the
7982
* SelectionView will be invoked for all languages. Restrict to specific languages: Eg: `["javascript", "html", "php"]`
8083
*
84+
* @example
8185
* ```js
8286
* // to register a provider that will be invoked for all languages. where provider is any object that implements
8387
* // a getSelectionView function
@@ -89,6 +93,8 @@
8993
*
9094
* ### removeSelectionViewProvider
9195
* Removes a registered SelectionView provider. The API takes the same arguments as `registerSelectionViewProvider`.
96+
*
97+
* @example
9298
* ```js
9399
* // syntax
94100
* SelectionViewManager.removeSelectionViewProvider(provider, supportedLanguages);
@@ -99,6 +105,8 @@
99105
* ### getSelectionView
100106
* Each provider must implement the `getSelectionView` function that returns a promise. The promise either resolves with
101107
* the Selection View details object(described below) or rejects if there is no preview for the position.
108+
*
109+
* @example
102110
* ```js
103111
* // function signature
104112
* provider.getSelectionView = function(editor, selections) {

src/utils/EventDispatcher.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,21 @@
5555
*
5656
* ## Usage
5757
* ### Importing from an extension
58+
* @example
5859
* ```js
5960
* const EventDispatcher = brackets.getModule("utils/EventDispatcher");
6061
* ```
6162
* ### Using the global object
6263
* The EventDispatcher Object is available within the global context, be it phoenix or phoenix core web workers or node.
64+
* @example
6365
* ```js
6466
* window.EventDispatcher.makeEventDispatcher(exports); // within phoenix require module
6567
* self.EventDispatcher.makeEventDispatcher(object); // within web worker
6668
* global.EventDispatcher.makeEventDispatcher(exports); // within node module that has an export
6769
* ```
6870
*
6971
* If you wish to import event dispatcher to your custom web worker, use the following
72+
* @example
7073
* ```js
7174
* importScripts('<relative path from your extension>/utils/EventDispatcher');
7275
* // this will add the global EventDispatcher to your web-worker. Note that the EventDispatcher in the web worker
@@ -76,6 +79,7 @@
7679
* self.EventDispatcher.trigger("someEvent"); // within web worker
7780
* ```
7881
* ### Sample Usage within extension
82+
* @example
7983
* ```js
8084
* // in your extension js file.
8185
* define (function (require, exports, module) {

src/utils/EventManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* ## Usage
3434
* For Eg. Let's say we have an extension `drawImage` installed that wants to expose custom functionality to phoenix.
3535
* The Extension will first register named EventHandler like this:
36+
* @example
3637
* ```js
3738
* // in drawImage/someExtensionModule.js module within the extension, do the following:
3839
* const EventDispatcher = brackets.getModule("utils/EventDispatcher"),
@@ -44,6 +45,7 @@
4445
* Once the event handler is registered, we can trigger events on the named handler anywhere in phoenix
4546
* (inside or outside the extension) by using:
4647
*
48+
* @example
4749
* ```js
4850
* EventManager.triggerEvent("drawImage-Handler", "someEventName", "param1", "param2", ...);
4951
* ```

src/utils/ExtensionInterface.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* For Making this possible, the `angular-cli` extension makes a named interface available with the ExtensionInterface
3535
* module and `angular` extension can get hold of the interface as and when the extension gets loaded.
3636
*
37+
* @example
3738
* ```js
3839
* // in angular-cli extension, make a file say cli-interface.js module within the extension, do the following:
3940
* const ExtensionInterface = brackets.getModule("utils/ExtensionInterface"),
@@ -43,6 +44,7 @@
4344
* Once the interface is registered, the angular extension can get hold of the interface with the following code
4445
* (inside or outside the extension) by using:
4546
*
47+
* @example
4648
* ```js
4749
* let angularCli;
4850
* ExtensionInterface.waitAndGetExtensionInterface("angularCli").then(interfaceObj=> angularCli = interfaceObj);

src/utils/FeatureGate.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* so that only people who want to test the extension will be able to use it.
3434
*
3535
* ### creating a feature gate
36+
* @example
3637
* ```js
3738
* // within extensions
3839
* const FeatureGate = brackets.getModule("utils/FeatureGate"); // replace with `require` for core modules.
@@ -44,6 +45,7 @@
4445
* Once the feature is registered, use the below code to check if the feature can be safely enabled. For Eg., if
4546
* you want to enable fancy colors based on the example above:
4647
*
48+
* @example
4749
* ```js
4850
* if(FeatureGate.isFeatureEnabled(FEATURE_NEW_COLORS)){
4951
* // do fancy colors here

0 commit comments

Comments
 (0)