Skip to content

Commit 7782112

Browse files
committed
Convert docs to DocC
This change migrates the markdown based documentation into a DocC bundle with the goal to publish this documentation on swift.org. This change: * Adds a DocC bundle with the existing documentation * Pares down the readme to remove most of the documentation and links out to the documentation instead * Adds a command to the extension to open the documentation * Adds the open documentation command to the project view
1 parent 41e8872 commit 7782112

24 files changed

+226
-110
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ assets/documentation-webview
1313
assets/test/**/Package.resolved
1414
assets/swift-docc-render
1515
ud
16+
userdocs/userdocs.docc/.docc-build

README.md

+4-107
Original file line numberDiff line numberDiff line change
@@ -10,116 +10,13 @@ This extension adds language support for Swift to Visual Studio Code, providing
1010
* Package dependency view
1111
* Test Explorer view
1212

13-
This extension uses [SourceKit LSP](https://github.com/apple/sourcekit-lsp) for the [language server](https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/), which powers code completion. It also has a dependency on [LLDB DAP](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap) for debugging.
14-
15-
To propose new features, you can post on the [swift.org forums](https://forums.swift.org) in the [VS Code Swift Extension category](https://forums.swift.org/c/related-projects/vscode-swift-extension/). If you run into something that doesn't work the way you'd expect, you can [file an issue in the GitHub repository](https://github.com/swiftlang/vscode-swift/issues/new).
16-
17-
## Installation
18-
19-
The Swift extension is supported on macOS, Linux, and Windows. To install, firstly ensure you have [Swift installed on your system](https://www.swift.org/install/). Then [install the Swift extension](https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode). Once your machine is ready, you can get started with the **Swift: Create New Project...** command.
20-
21-
## Features
22-
23-
### Language features
24-
25-
The extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp). To ensure the extension functions correctly, it’s important to first build the project so that SourceKit-LSP has access to all the symbol data. Whenever you add a new dependency to your project, make sure to rebuild it so that SourceKit-LSP can update its information.
26-
27-
### Automatic task creation
28-
29-
For workspaces that contain a **Package.swift** file, this extension will add the following tasks:
30-
31-
- **Build All**: Build all targets in the Package
32-
- **Build Debug <Executable>**: Each executable in a Package.swift get a task for building a debug build
33-
- **Build Release <Executable>**: Each executable in a Package.swift get a task for building a release build
34-
35-
These tasks are available via **Terminal ▸ Run Task...** and **Terminal ▸ Run Build Task...**.
36-
37-
### Commands
38-
39-
The extension adds the following commands, available via the command palette.
40-
41-
#### Configuration
42-
43-
- **Create New Project...**: Create a new Swift project using a template. This opens a dialog to guide you through creating a new project structure.
44-
- **Create New Swift File...**: Create a new `.swift` file in the current workspace.
45-
- **Select Toolchain**: Select the locally installed Swift toolchain (including Xcode toolchains on macOS) that you want to use Swift tools from.
46-
47-
The following command is only available on macOS:
48-
49-
- **Select Target Platform**: This is an experimental command that offers code editing support for iOS, tvOS, watchOS and visionOS projects.
50-
51-
#### Building and Debugging
52-
53-
- **Run Build**: Run `swift build` for the package associated with the open file.
54-
- **Debug Build**: Run `swift build` with debugging enabled for the package associated with the open file, launching the binary and attaching the debugger.
55-
- **Attach to Process...**: Attach the debugger to an already running process for debugging.
56-
- **Clean Build Folder**: Clean the build folder for the package associated with the open file, removing all previously built products.
57-
58-
#### Dependency Management
13+
# Documentation
5914

60-
- **Resolve Package Dependencies**: Run `swift package resolve` on packages associated with the open file.
61-
- **Update Package Dependencies**: Run `swift package update` on packages associated with the open file.
62-
- **Reset Package Dependencies**: Run `swift package reset` on packages associated with the open file.
63-
- **Add to Workspace**: Add the current package to the active workspace in VS Code.
64-
- **Clean Build**: Run `swift package clean` on packages associated with the open file.
65-
- **Open Package.swift**: Open `Package.swift` for the package associated with the open file.
66-
- **Use Local Version**: Switch the package dependency to use a local version of the package instead of the remote repository version.
67-
- **Edit Locally**: Make the package dependency editable locally, allowing changes to the dependency to be reflected immediately.
68-
- **Revert To Original Version**: Revert the package dependency to its original, unedited state after local changes have been made.
69-
- **View Repository**: Open the external repository of the selected Swift package in a browser.
15+
The official documentation for this extension is available at [vscode-swift](https://www.swift.org/vscode/documentation/vscode)
7016

71-
#### Testing
72-
73-
- **Test: Run All Tests**: Run all the tests across all test targes in the open project.
74-
- **Test: Rerun Last Run**: Perform the last test run again.
75-
- **Test: Open Coverage**: Open the last generated coverage report, if one exists.
76-
- **Test: Run All Tests in Parallel**: Run all tests in parallel. This action only affects XCTests. Swift-testing tests are parallel by default, and their parallelism [is controlled in code](https://developer.apple.com/documentation/testing/parallelization).
77-
78-
#### Snippets and Scripts
79-
80-
- **Insert Function Comment**: Insert a standard comment block for documenting a Swift function in the current file.
81-
- **Run Swift Script**: Run the currently open file, as a Swift script. The file must not be part of a build target. If the file has not been saved it will save it to a temporary file so it can be run.
82-
- **Run Swift Snippet**: If the currently open file is a Swift snippet then run it.
83-
- **Debug Swift Snippet**: If the currently open file is a Swift snippet then debug it.
84-
85-
#### Diagnostics
86-
87-
- **Capture VS Code Swift Diagnostic Bundle**: Capture a diagnostic bundle from VS Code, containing logs and information to aid in troubleshooting Swift-related issues.
88-
- **Clear Diagnostics Collection**: Clear all collected diagnostics in the current workspace to start fresh.
89-
- **Restart LSP Server**: Restart the Swift Language Server Protocol (LSP) server for the current workspace.
90-
- **Re-Index Project**: Force a re-index of the project to refresh code completion and symbol navigation support.
91-
92-
### Package dependencies
93-
94-
If your workspace contains a package that has dependencies, this extension will add a **Package Dependencies** view to the Explorer:
95-
96-
![](images/package-dependencies.png)
97-
98-
Additionally, the extension will monitor `Package.swift` and `Package.resolved` for changes, resolve any changes to the dependencies, and update the view as needed.
99-
100-
### Debugging
101-
102-
The Swift extension uses the [LLDB DAP](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap) extension for debugging.
103-
104-
When you open a Swift package (a directory containing a `Package.swift` file), the extension automatically generates build tasks and launch configurations for each executable within the package. Additionally, if the package includes tests, the extension creates a configuration specifically designed to run those tests. These configurations all leverage the CodeLLDB extension as the debugger of choice.
105-
106-
Use the **Run > Start Debugging** menu item to run an executable and start debugging. If you have multiple launch configurations you can choose which launch configuration to use in the debugger view.
107-
108-
CodeLLDB includes a version of `lldb` that it uses by default for debugging, but this version of `lldb` doesn’t support Swift. The Swift extension will automatically identify the required version and offer to update the CodeLLDB configuration as necessary so that debugging is supported.
109-
110-
### Test Explorer
111-
112-
If your package contains tests then they can be viewed, run and debugged in the Test Explorer.
113-
114-
![](images/test-explorer.png)
115-
116-
Once your project is built, the Test Explorer will list all your tests. These tests are grouped by package, then test target, and finally, by XCTestCase class. From the Test Explorer, you can initiate a test run, debug a test run, and if a file has already been opened, you can jump to the source code for a test.
117-
118-
### Documentation
17+
This extension uses [SourceKit LSP](https://github.com/apple/sourcekit-lsp) for the [language server](https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/), which powers code completion. It also has a dependency on [LLDB DAP](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap) for debugging.
11918

120-
* [Extension Settings](docs/settings.md)
121-
* [Test Coverage](docs/test-coverage.md)
122-
* [Visual Studio Code Dev Containers](docs/remote-dev.md)
19+
To propose new features, you can post on the [swift.org forums](https://forums.swift.org) in the [VS Code Swift Extension category](https://forums.swift.org/c/related-projects/vscode-swift-extension/). If you run into something that doesn't work the way you'd expect, you can [file an issue in the GitHub repository](https://github.com/swiftlang/vscode-swift/issues/new).
12320

12421
## Contributing
12522

package.json

+11
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@
299299
"title": "Run Tests with Coverage",
300300
"category": "Test",
301301
"icon": "$(debug-coverage)"
302+
},
303+
{
304+
"command": "swift.openDocumentation",
305+
"title": "Open Documentation",
306+
"category": "Swift",
307+
"icon": "$(book)"
302308
}
303309
],
304310
"configuration": [
@@ -1068,6 +1074,11 @@
10681074
"command": "swift.nestedDependenciesList",
10691075
"when": "view == projectPanel && swift.flatDependenciesList",
10701076
"group": "navigation@5"
1077+
},
1078+
{
1079+
"command": "swift.openDocumentation",
1080+
"when": "view == projectPanel",
1081+
"group": "navigation@6"
10711082
}
10721083
],
10731084
"view/item/context": [

src/commands.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { updateDependenciesViewList } from "./commands/dependencies/updateDepVie
4444
import { runTask } from "./commands/runTask";
4545
import { TestKind } from "./TestExplorer/TestKind";
4646
import { pickProcess } from "./commands/pickProcess";
47+
import { openDocumentation } from "./commands/openDocumentation";
4748

4849
/**
4950
* References:
@@ -209,6 +210,7 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
209210
vscode.commands.registerCommand("swift.openEducationalNote", uri =>
210211
openEducationalNote(uri)
211212
),
213+
vscode.commands.registerCommand("swift.openDocumentation", () => openDocumentation()),
212214
];
213215
}
214216

src/commands/openDocumentation.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2025 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import * as vscode from "vscode";
16+
17+
/**
18+
* Handle the user requesting to show the vscode-swift documentation.
19+
*/
20+
export async function openDocumentation(): Promise<void> {
21+
vscode.env.openExternal(vscode.Uri.parse("https://www.swift.org/vscode/documentation/vscode"));
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Automatic Task Creation
2+
3+
vscode-swift automatically adds tasks for common operations with your Package.
4+
5+
For workspaces that contain a **Package.swift** file, this extension will add the following tasks:
6+
7+
- **Build All**: Build all targets in the Package
8+
- **Build Debug <Executable>**: Each executable in a Package.swift get a task for building a debug build
9+
- **Build Release <Executable>**: Each executable in a Package.swift get a task for building a release build
10+
11+
These tasks are available via **Terminal ▸ Run Task...** and **Terminal ▸ Run Build Task...**.

userdocs/userdocs.docc/commands.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Commands
2+
3+
vscode-swift adds various commands to Visual Studio Code.
4+
5+
The extension adds the following commands, available via the command palette.
6+
7+
#### Configuration
8+
9+
- **Create New Project...**: Create a new Swift project using a template. This opens a dialog to guide you through creating a new project structure.
10+
- **Create New Swift File...**: Create a new `.swift` file in the current workspace.
11+
- **Select Toolchain**: Select the locally installed Swift toolchain (including Xcode toolchains on macOS) that you want to use Swift tools from.
12+
13+
The following command is only available on macOS:
14+
15+
- **Select Target Platform**: This is an experimental command that offers code completion for iOS and tvOS projects.
16+
17+
#### Building and Debugging
18+
19+
- **Run Build**: Run `swift build` for the package associated with the open file.
20+
- **Debug Build**: Run `swift build` with debugging enabled for the package associated with the open file, launching the binary and attaching the debugger.
21+
- **Attach to Process...**: Attach the debugger to an already running process for debugging.
22+
- **Clean Build Folder**: Clean the build folder for the package associated with the open file, removing all previously built products.
23+
24+
#### Dependency Management
25+
26+
- **Resolve Package Dependencies**: Run `swift package resolve` on packages associated with the open file.
27+
- **Update Package Dependencies**: Run `swift package update` on packages associated with the open file.
28+
- **Reset Package Dependencies**: Run `swift package reset` on packages associated with the open file.
29+
- **Add to Workspace**: Add the current package to the active workspace in VS Code.
30+
- **Clean Build**: Run `swift package clean` on packages associated with the open file.
31+
- **Open Package.swift**: Open `Package.swift` for the package associated with the open file.
32+
- **Use Local Version**: Switch the package dependency to use a local version of the package instead of the remote repository version.
33+
- **Edit Locally**: Make the package dependency editable locally, allowing changes to the dependency to be reflected immediately.
34+
- **Revert To Original Version**: Revert the package dependency to its original, unedited state after local changes have been made.
35+
- **View Repository**: Open the external repository of the selected Swift package in a browser.
36+
37+
#### Testing
38+
39+
- **Test: Run All Tests**: Run all the tests across all test targes in the open project.
40+
- **Test: Rerun Last Run**: Perform the last test run again.
41+
- **Test: Open Coverage**: Open the last generated coverage report, if one exists.
42+
- **Test: Run All Tests in Parallel**: Run all tests in parallel. This action only affects XCTests. Swift-testing tests are parallel by default, and their parallelism [is controlled in code](https://developer.apple.com/documentation/testing/parallelization).
43+
44+
#### Snippets and Scripts
45+
46+
- **Insert Function Comment**: Insert a standard comment block for documenting a Swift function in the current file.
47+
- **Run Swift Script**: Run the currently open file, as a Swift script. The file must not be part of a build target. If the file has not been saved it will save it to a temporary file so it can be run.
48+
- **Run Swift Snippet**: If the currently open file is a Swift snippet then run it.
49+
- **Debug Swift Snippet**: If the currently open file is a Swift snippet then debug it.
50+
51+
#### Diagnostics
52+
53+
- **Capture VS Code Swift Diagnostic Bundle**: Capture a diagnostic bundle from VS Code, containing logs and information to aid in troubleshooting Swift-related issues.
54+
- **Clear Diagnostics Collection**: Clear all collected diagnostics in the current workspace to start fresh.
55+
- **Restart LSP Server**: Restart the Swift Language Server Protocol (LSP) server for the current workspace.
56+
- **Re-Index Project**: Force a re-index of the project to refresh code completion and symbol navigation support.
File renamed without changes.
File renamed without changes.
File renamed without changes.

userdocs/userdocs.docc/debugging.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Debugging
2+
3+
vscode-swift allows you to debug your Swift packages.
4+
5+
> Tip: Debugging works best when using a version of the Swift toolchain 6.0 or higher
6+
7+
When you open a Swift package (a directory containing a `Package.swift` file), the extension automatically generates build tasks and launch configurations for each executable within the package. Additionally, if the package includes tests, the extension creates a configuration specifically designed to run those tests. These configurations all leverage the CodeLLDB extension as the debugger of choice.
8+
9+
Use the **Run > Start Debugging** menu item to run an executable and start debugging. If you have multiple launch configurations you can choose which launch configuration to use in the debugger view.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# DocC Preview
2+
3+
vscode-swift supports rendering your DocC documentation
4+
5+
> Warning: DocC Preview is only supported with Swift toolchains versioned 6.2 or higher
6+
7+
Docs here!
File renamed without changes.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Installation
2+
3+
vscode-code Swift is installed through the extension marketplace.
4+
5+
The Swift extension is supported on macOS, Linux, and Windows.
6+
7+
To install, firstly ensure you have [Swift installed on your system](https://www.swift.org/install/). Then [install the Swift extension](https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode). Once your machine is ready, you can get started with the **Swift: Create New Project...** command.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Language Features
2+
3+
vscode-swift provides various language features to help you write Swift code.
4+
5+
The extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp). To ensure the extension functions correctly, it’s important to first build the project so that SourceKit-LSP has access to all the symbol data. Whenever you add a new dependency to your project, make sure to rebuild it so that SourceKit-LSP can update its information.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Project View
2+
3+
vscode-swift provides project view
4+
5+
If your workspace contains a package, this extension will add a **Swift Project** view to the Explorer:
6+
7+
![](images/package-dependencies.png)
8+
9+
Additionally, the extension will monitor `Package.swift` and `Package.resolved` for changes, resolve any changes to the dependencies, and update the view as needed.

docs/remote-dev.md userdocs/userdocs.docc/remote-dev.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Visual Studio Code Dev Containers
22

3+
Dev containers can be used as an easy way to develop when building for other platforms.
4+
35
[VS Code Dev Containers](https://code.visualstudio.com/docs/remote/containers) allows you to run your code and environment in a container. This is especially useful for Swift when developing on macOS and deploying to Linux. You can ensure there are no compatibility issues in Foundation when running your code. The extension also works with [GitHub Codespaces](https://github.com/features/codespaces) to allow you to write your code on the web.
46

57
## Requirements

docs/settings.md userdocs/userdocs.docc/settings.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Extension Settings
22

3+
vscode-swift provides various settings to configure its behaviour.
4+
35
The Visual Studio Code Swift extension comes with a number of settings you can use to control how it works. Detailed descriptions of each setting is provided in the extension settings page.
46

57
This document outlines useful configuration options not covered by the settings descriptions in the extension settings page.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Supported Toolchains
2+
3+
vscode-swift supports several versions of the Swift toolchain.
4+
5+
vscode-swift supports the following Swift toolchains:
6+
* 5.9
7+
* 5.10
8+
* 6.0
9+
* 6.1 (unreleased)
10+
11+
The extension also strives to work with the latest nightly toolchains built from the main branch.
12+
13+
Certain features of vscode-swift will only work with newer versions of the toolchains. We recommend using the latest version of the Swift toolchain to get the most benefit of the extension. The following features only work with certain toolchains as listed:
14+
15+
Feature | Minimum Toolchain Required
16+
------------------------ | -------------------------------------
17+
lldb-dap debugging | 6.0
18+
DocC preview | 6.0
19+

0 commit comments

Comments
 (0)