Skip to content

Commit aaf5862

Browse files
authored
Fix enum docs, fixes #7511 (#7650)
1 parent 0f33d87 commit aaf5862

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

api/references/contribution-points.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ See the [Commands Extension Guide](https://code.visualstudio.com/api/extension-g
141141

142142
## contributes.configuration
143143

144-
Contribute configuration keys that will be exposed to the user. The user will be able to set these configuration options as User Settings or as Workspace Settings, either by using the Settings editor or by editing the JSON settings file directly.
144+
Contribute configuration keys that will be exposed to the user. The user will be able to set these configuration options in the Settings editor or by editing a settings.json file directly.
145145

146146
This section can either be a single object, representing a single category of settings, or an array of objects, representing multiple categories of settings. If there are multiple categories of settings, the Settings editor will show a submenu in the table of contents for that extension, and the title keys will be used for the submenu entry names.
147147

@@ -179,7 +179,7 @@ Your configuration entry is used both to provide intellisense when editing your
179179

180180
![settings UI screenshot with numbers](images/contribution-points/settings-ui.png)
181181

182-
**title**
182+
#### title
183183

184184
The `title` 1️⃣️ of a category is the heading used for that category.
185185

@@ -200,7 +200,7 @@ For both the `title` and `displayName` fields, words like "Extension", "Configur
200200
-`"title": "GitMagic Configuration"`
201201
-`"title": "GitMagic Extension Configuration Settings"`
202202

203-
**properties**
203+
#### properties
204204

205205
The `properties` 2️⃣ in your configuration will be a dictionary of configuration properties.
206206

@@ -210,7 +210,7 @@ In the settings UI, your configuration key will be used to namespace and constru
210210
211211
Entries will be grouped according to the hierarchy established in your keys. So for example, these entries
212212

213-
```
213+
```text
214214
gitMagic.blame.dateFormat
215215
gitMagic.blame.format
216216
gitMagic.blame.heatMap.enabled
@@ -234,7 +234,7 @@ Otherwise, properties without an explicit order field appear in alphabetical ord
234234
Configuration keys are defined using a superset of [JSON
235235
Schema](https://json-schema.org/overview/what-is-jsonschema).
236236

237-
**description** / **markdownDescription**
237+
#### description / markdownDescription
238238

239239
Your `description` 3️⃣ appears after the title and before the input field, except for booleans, where the description is used as the label for the checkbox. 6️⃣
240240

@@ -258,7 +258,7 @@ If you use `markdownDescription` instead of `description`, your setting descript
258258

259259
For `markdownDescription`, in order to add newlines or multiple paragraphs, use the string `\n\n` to separate the paragraphs instead of just `\n`.
260260

261-
**type**
261+
#### type
262262

263263
Entries of type `number` 4️⃣ , `string` 5️⃣ , `boolean` 6️⃣ can be edited directly in the settings UI.
264264

@@ -289,7 +289,7 @@ Some `object` and `array` type settings will be rendered in the settings UI. Sim
289289

290290
If an `object` or `array` type setting can also contain other types like nested objects, arrays, or null, then the value won't be rendered in the settings UI and can only be modified by editing the JSON directly. Users will see a link to **Edit in settings.json** as shown in the screenshot above. 8️⃣
291291

292-
**order**
292+
#### order
293293

294294
Both categories and the settings within those categories can take an integer `order` type property, which gives a reference to how they should be sorted relative to other categories and/or settings.
295295

@@ -299,34 +299,33 @@ If two settings within the same category have `order` properties, the setting wi
299299

300300
If two categories have the same `order` property value, or if two settings within the same category have the same `order` property value, then they will be sorted in increasing alphabetical order within the settings UI.
301301

302-
**enum** / **enumDescriptions** / **enumItemLabels**
302+
#### enum / enumDescriptions / markdownEnumDescriptions / enumItemLabels
303303

304-
If you provide an array of items under the `enum` 7️⃣ property, the settings UI will render a dropdown menu.
304+
If you provide an array of items under the `enum` 7️⃣ property, the settings UI will render a dropdown menu of those items.
305305

306-
![settings UI screenshot of dropdown](images/contribution-points/settings-ui-enum.png)
306+
You can also provide an `enumDescriptions` property, an array of strings of the same length as the `enum` property. The `enumDescriptions` property provides a description in the settings UI at the bottom of the dropdown menu corresponding to each `enum` item. \
307+
You can also use `markdownEnumDescriptions` instead of `enumDescriptions`, and your descriptions will be parsed as Markdown. \
308+
To customize the dropdown option names in the settings UI, you can use `enumItemLabels`.
307309

308-
You can also provide an `enumDescriptions` property, which provides descriptive text rendered at the bottom of the dropdown:
310+
Example:
309311

310312
```json
311313
{
312-
"gitMagic.blame.heatMap.location": {
314+
"settingsEditorTestExtension.enumSetting": {
313315
"type": "string",
314-
"default": "right",
315-
"enum": ["left", "right"],
316-
"enumDescriptions": [
317-
"Adds a heatmap indicator on the left edge of the gutter blame annotations",
318-
"Adds a heatmap indicator on the right edge of the gutter blame annotations"
319-
]
316+
"enum": ["first", "second", "third"],
317+
"enumDescriptions": ["The first enum", "The second enum", "The third enum"],
318+
"markdownEnumDescriptions": ["The *first* enum", "The *second* enum", "The *third* enum"],
319+
"enumItemLabels": ["1st", "2nd", "3rd"],
320+
"default": "first",
321+
"description": "Example setting with an enum"
320322
}
321323
}
322324
```
323325

324-
You can also use `markdownEnumDescriptions`, and your descriptions will be rendered as Markdown.
325-
326-
To customize the dropdown options, you can use `enumItemLabels`. The `workbench.iconTheme` setting uses both `enumDescriptions` and `enumItemLabels`. In the screenshot below, the hovered option has the item label "None", with enum description "No file icons" and enum value `null`.
327-
![The workbench.iconTheme setting in the Settings UI with the dropdown expanded showing the enum item labels and one enum description](images/contribution-points/settings-ui-icon-theme.png)
326+
![settings UI screenshot of example enum setting above](images/contribution-points/settings-ui-enum.png)
328327

329-
**deprecationMessage** / **markdownDeprecationMessage**
328+
#### deprecationMessage / markdownDeprecationMessage
330329

331330
If you set `deprecationMessage`, or `markdownDeprecationMessage`, the setting will get a warning underline with your specified message. Also, the setting will be hidden from the settings UI unless it is configured by the user. If you set `markdownDeprecationMessage`, the markdown will not be rendered in the setting hover or the problems view. If you set both properties, `deprecationMessage` will be shown in the hover and the problems view, and `markdownDeprecationMessage` will be rendered as Markdown in the settings UI.
332331

@@ -343,7 +342,7 @@ Example:
343342
}
344343
```
345344

346-
**Other JSON Schema properties**
345+
#### Other JSON Schema properties
347346

348347
You can use any of the validation JSON Schema properties to describe other constraints on configuration values:
349348

@@ -357,15 +356,15 @@ You can use any of the validation JSON Schema properties to describe other const
357356
- `maxItems`, `minItems` for restricting array length
358357
- `editPresentation` for controlling whether a single-line inputbox or multi-line textarea is rendered for the string setting in the Settings editor
359358

360-
**Unsupported JSON Schema properties**
359+
#### Unsupported JSON Schema properties
361360

362361
Not supported in the configuration section are:
363362

364363
- `$ref` and `definition`: The configuration schemas needs to be self-contained and cannot make assumptions how the aggregated settings JSON schema document looks like.
365364

366365
For more details on these and other features, see the [JSON Schema Reference](https://json-schema.org/overview/what-is-jsonschema).
367366

368-
**scope**
367+
#### scope
369368

370369
A configuration setting can have one of the following possible scopes:
371370

@@ -423,7 +422,7 @@ Below are example configuration scopes from the built-in Git extension:
423422

424423
You can see that `git.alwaysSignOff` has `resource` scope and can be set per user, workspace, or folder, while the ignored repositories list with `window` scope applies more globally for the VS Code window or workspace (which might be multi-root).
425424

426-
**Linking to settings**
425+
#### Linking to settings
427426

428427
You can insert a link to another setting, which will be rendered as a clickable link in the settings UI, by using this special syntax in the markdown-type properties: ``` `#target.setting.id#` ```. This will work in `markdownDescription`, `markdownEnumDescriptions`, and `markdownDeprecationMessage`. Example:
429428

Lines changed: 2 additions & 2 deletions
Loading

api/references/images/contribution-points/settings-ui-icon-theme.png

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

0 commit comments

Comments
 (0)