Skip to content

Commit 8a4c5a3

Browse files
matthewbastienplemarquandheckj
authored
Improve documentation (#1588)
Co-authored-by: Paul LeMarquand <[email protected]> Co-authored-by: Joseph Heck <[email protected]>
1 parent 8a05ead commit 8a4c5a3

28 files changed

+165
-115
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ If you'd like to return to using the released version of the extension you can u
6464

6565
Occasionally, pre-release builds will be published to the VS Code Marketplace. You can switch to the pre-release version by clicking on the `Switch to Pre-Release Version` button in the Extensions View:
6666

67-
![](userdocs/userdocs.docc/install-pre-release.png)
67+
![A snapshot of VS Code that has Extensions highlighted, showing the Swift extension. In the detail panel of the extension view, a red box highlights the button "Switch to Pre-Release Version".](userdocs/userdocs.docc/Resources/install-pre-release.png)
6868

6969
Switching back to the release version can be done by clicking on the `Switch to Release Version` button.
7070

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This extension adds language support for Swift to Visual Studio Code, providing
1212

1313
# Documentation
1414

15-
The official documentation for this extension is available at [vscode-swift](https://docs.swift.org/vscode/documentation/userdocs)
15+
The official documentation for this extension is [available on swift.org](https://docs.swift.org/vscode/documentation/userdocs).
1616

1717
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 the [LLDB DAP](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap) extension to enable debugging.
1818

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Installing Pre-Release Builds
2+
3+
Try out the latest updates by switching to the pre-release version.
4+
5+
The Swift extension provides pre-release builds that you can use to test out unreleased features or get bug fixes before the project publishes an official release. Pre-release build numbers are one minor version ahead of the most recent release.
6+
7+
The "Switch to Pre-Release Version" button in the VS Code extensions view is used to install the latest pre-release builds:
8+
9+
![A snapshot of VS Code that has Extensions highlighted, showing the Swift extension. In the detail panel of the extension view, a red box highlights the button "Switch to Pre-Release Version".](install-pre-release.png)
10+
11+
When you select to use a pre-release version, the button changes to "Switch to Release Version", which lets you go back to the official release.

userdocs/userdocs.docc/remote-dev.md renamed to userdocs/userdocs.docc/Articles/Advanced/remote-dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Visual Studio Code Dev Containers
22

3-
Dev containers can be used as an easy way to develop when building for other platforms.
3+
Create reusable development environments using containers.
44

55
[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.
66

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatic Task Creation
2+
3+
Add tasks for common operations with your Package.
4+
5+
For workspaces that contain a `Package.swift` file, the Swift extension adds 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+
> 💡 Tip: Tasks use workflows common to all VS Code extensions. For more information see [the VS Code documentation for tasks](https://code.visualstudio.com/docs/editor/tasks).
12+
13+
These tasks are available via the commands **Terminal ▸ Run Task...** and **Terminal ▸ Run Build Task...** in the command palette.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Debugging
22

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
3+
Debug your Swift executables using LLDB.
64

75
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.
86

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+
> 💡 Tip: Debugging workflows are common to all VS Code extensions. See the [VS Code documentation about testing](https://code.visualstudio.com/docs/debugtest/testing) for a more in-depth overview.
8+
>
9+
> Debugging works best when using a version of the Swift toolchain 6.0 or higher.
1010
11-
Debugging uses workflows common to all VSCode extensions. For more information see https://code.visualstudio.com/docs/editor/debugging
11+
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.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Documentation Live Preview
2+
3+
@Metadata {
4+
@Available("Swift", introduced: "6.2")
5+
}
6+
7+
Show a live preview of your Swift documentation while editing.
8+
9+
10+
The Swift toolchain provides DocC, which compiles documentation for your Swift package. You can distribute compiled documentation to developers, or host the content. It's what this project used to make its documentation! You can learn more about DocC by reading [the documentation on the Swift organization's website](https://www.swift.org/documentation/docc/).
11+
12+
View a side-by-side live preview of your documentation as you edit it with the Swift extension for VS Code.
13+
Access this feature using the Preview Swift Documentation button at the top right of an editor, or be invoking `Swift: Preview Documentation` in the command palette.
14+
This opens up a new editor pane with your rendered documentation:
15+
16+
![An animation showing how to launch documentation live preview.](docc-live-preview.gif)
17+
18+
> Note: This feature is only available when using a Swift toolchain 6.2 or higher running on macOS or Linux.
19+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Language Features
2+
3+
Navigate and write your Swift code more easily with Language features.
4+
5+
The Swift extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp).
6+
7+
> ⚠️ Important: With Swift toolchains prior to 6.1 you will need to build your project at least once for SourceKit-LSP to function correcly. Whenever you add a new dependency to your project, make sure to rebuild it so that SourceKit-LSP can update its information.
8+
9+
SourceKit-LSP provides background indexing in Swift toolchain 6.1 which will automatically index your project on startup. All indexing results are cached in the `.build/index-build` folder within your workspace.
10+
11+
Language features are common to all VS Code extensions. See the [VS Code documentation about navigating code](https://code.visualstudio.com/docs/editing/editingevolved) for a more in-depth overview.
12+
13+
SourceKit-LSP can be configured via extension settings. See <doc:settings> for more information.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Project View
1+
# Swift Project View
22

3-
vscode-swift provides project view
3+
Use this view to navigate your Swift project.
44

55
If your workspace contains a package, this extension will add a **Swift Project** view to the Explorer:
66

7-
![](package-dependencies.png)
7+
![A snapshot of the Package Dependencies view showing dependencies for the async-http-client Swift project.](package-dependencies.png)
88

99
Additionally, the extension will monitor `Package.swift` and `Package.resolved` for changes, resolve any changes to the dependencies, and update the view as needed.
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
# Test Coverage
1+
# Running and Debugging Tests
22

3-
vscode-swift provides mechanisms to see coverage of your tests.
3+
View test results in the test explorer.
4+
5+
6+
All VS Code extensions provide a [testing capabilities and views(https://code.visualstudio.com/docs/debugtest/testing).
7+
View, run, and debug tests that your package containers in the Test Explorer.
8+
9+
![A screenshot of the test explorer pane in Visual Studio Code that shows a selection of 5 tests run and passed.](test-explorer.png)
10+
11+
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 you have already opened a file, you can quickly jump to the source code for a test.
12+
13+
## Run Tests with Coverage
414

515
Test coverage is a measurement of how much of your code is tested by your tests. It defines how many lines of code were actually run when you ran your tests and how many were not. When a line of code is not run by your tests it will not have been tested and perhaps you need to extend your tests.
616

717
The Swift extension integrates with VS Code's Code Coverage APIs to record what code has been hit or missed by your tests.
818

9-
![](coverage-run.png)
19+
![A snapshot of the Test Explorer with the mouse hovering over the "Run Tests With Coverage" button.](coverage-run.png)
1020

1121
Once you've performed a code coverage run a coverage report will be displayed in a section of the primary side bar. This report lists all the source files in your project and what percentage of lines were hit by tests. You can click on each file to open that file in the code editor. If you close the report you can always get it back by running the command `Test: Open Coverage`.
1222

13-
![](coverage-report.png)
23+
![A snapshot of the Test Coverage view showing percentage of code covered for each source file.](coverage-report.png)
1424

1525
After generating code coverage lines numbers in covered files will be coloured red or green depending on if they ran during the test run. Hovering over the line numbers shows how many times each line was run. Hitting the "Toggle Inline Coverage" link that appears when hovering over the line numbers will keep this information visible.
1626

17-
![](coverage-render.png)
27+
![A snapshot of a text editor with Swift code highlighted in green to show that it has been executed in the test.](coverage-render.png)

0 commit comments

Comments
 (0)