-
Notifications
You must be signed in to change notification settings - Fork 90
Improve documentation #1588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matthewbastien
merged 9 commits into
swiftlang:main
from
matthewbastien:live-preview-docs
Jun 3, 2025
Merged
Improve documentation #1588
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
412ffa1
add documentation for the live preview editor
matthewbastien 3d7a208
add folders to better structure the userdocs DocC catalog
matthewbastien 62f62ef
make documentation more consistent between articles
matthewbastien 86e1bde
address review comments
matthewbastien 62fd0c0
Apply suggestions from code review
matthewbastien 6c305e6
fix typo in settings.md
matthewbastien 4310265
Apply suggestions from code review
matthewbastien d087d90
add alt text for images
matthewbastien b2a1f74
re-word link to documentation in the README
matthewbastien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
userdocs/userdocs.docc/Articles/Advanced/install-pre-release.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Installing Pre-Release Builds | ||
|
|
||
| Try out the latest updates by switching to the pre-release version. | ||
|
|
||
| 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. | ||
|
|
||
| The "Switch to Pre-Release Version" button in the VS Code extensions view is used to install the latest pre-release builds: | ||
|
|
||
|  | ||
|
|
||
| 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. |
2 changes: 1 addition & 1 deletion
2
userdocs/userdocs.docc/remote-dev.md → ...docs.docc/Articles/Advanced/remote-dev.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
userdocs/userdocs.docc/Articles/Features/automatic-task-creation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Automatic Task Creation | ||
|
|
||
| Add tasks for common operations with your Package. | ||
|
|
||
| For workspaces that contain a `Package.swift` file, the Swift extension adds the following tasks: | ||
|
|
||
| - **Build All**: Build all targets in the Package. | ||
| - **Build Debug <Executable>**: Each executable in a Package.swift get a task for building a debug build. | ||
| - **Build Release <Executable>**: Each executable in a Package.swift get a task for building a release build. | ||
|
|
||
| > 💡 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). | ||
|
|
||
| These tasks are available via the commands **Terminal ▸ Run Task...** and **Terminal ▸ Run Build Task...** in the command palette. |
10 changes: 5 additions & 5 deletions
10
userdocs/userdocs.docc/debugging.md → ...rdocs.docc/Articles/Features/debugging.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| # Debugging | ||
|
|
||
| vscode-swift allows you to debug your Swift packages. | ||
|
|
||
| > Tip: Debugging works best when using a version of the Swift toolchain 6.0 or higher | ||
| Debug your Swift executables using LLDB. | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
| > 💡 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. | ||
| > | ||
| > Debugging works best when using a version of the Swift toolchain 6.0 or higher. | ||
|
|
||
| Debugging uses workflows common to all VSCode extensions. For more information see https://code.visualstudio.com/docs/editor/debugging | ||
| 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. | ||
19 changes: 19 additions & 0 deletions
19
userdocs/userdocs.docc/Articles/Features/docc-live-preview.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Documentation Live Preview | ||
matthewbastien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Metadata { | ||
| @Available("Swift", introduced: "6.2") | ||
| } | ||
|
|
||
| Show a live preview of your Swift documentation while editing. | ||
|
|
||
|
|
||
| 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/). | ||
|
|
||
| View a side-by-side live preview of your documentation as you edit it with the Swift extension for VS Code. | ||
| 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. | ||
| This opens up a new editor pane with your rendered documentation: | ||
|
|
||
|  | ||
matthewbastien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| > Note: This feature is only available when using a Swift toolchain 6.2 or higher running on macOS or Linux. | ||
|
|
||
13 changes: 13 additions & 0 deletions
13
userdocs/userdocs.docc/Articles/Features/language-features.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Language Features | ||
|
|
||
| Navigate and write your Swift code more easily with Language features. | ||
|
|
||
| The Swift extension provides language features such as code completion and jump to definition via [SourceKit-LSP](https://github.com/apple/sourcekit-lsp). | ||
|
|
||
| > ⚠️ 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. | ||
matthewbastien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| SourceKit-LSP can be configured via extension settings. See <doc:settings> for more information. | ||
6 changes: 3 additions & 3 deletions
6
userdocs/userdocs.docc/project-view.md → ...cs.docc/Articles/Features/project-view.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| # Project View | ||
| # Swift Project View | ||
|
|
||
| vscode-swift provides project view | ||
| Use this view to navigate your Swift project. | ||
|
|
||
| If your workspace contains a package, this extension will add a **Swift Project** view to the Explorer: | ||
|
|
||
|  | ||
|  | ||
|
|
||
| Additionally, the extension will monitor `Package.swift` and `Package.resolved` for changes, resolve any changes to the dependencies, and update the view as needed. |
20 changes: 15 additions & 5 deletions
20
userdocs/userdocs.docc/test-coverage.md → ...s.docc/Articles/Features/test-explorer.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,27 @@ | ||
| # Test Coverage | ||
| # Running and Debugging Tests | ||
|
|
||
| vscode-swift provides mechanisms to see coverage of your tests. | ||
| View test results in the test explorer. | ||
|
|
||
|
|
||
| All VS Code extensions provide a [testing capabilities and views(https://code.visualstudio.com/docs/debugtest/testing). | ||
| View, run, and debug tests that your package containers in the Test Explorer. | ||
|
|
||
|  | ||
|
|
||
| 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. | ||
|
|
||
| ## Run Tests with Coverage | ||
|
|
||
| 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. | ||
|
|
||
| The Swift extension integrates with VS Code's Code Coverage APIs to record what code has been hit or missed by your tests. | ||
|
|
||
|  | ||
|  | ||
|
|
||
| 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`. | ||
|
|
||
|  | ||
|  | ||
|
|
||
| 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. | ||
|
|
||
|  | ||
|  |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Commands | ||
|
|
||
| Useful VS Code commands added by the Swift extension. | ||
|
|
||
|
|
||
| The Swift extension adds the following commands, each prefixed with `"Swift: "` in the command palette. | ||
|
|
||
| #### Configuration | ||
|
|
||
| - **`Create New Project...`** - Create a new Swift project using a template. This opens a dialog to guide you through creating a new project structure. | ||
| - **`Create New Swift File...`** - Create a new `.swift` file in the current workspace. | ||
| - **`Select Toolchain...`** - Select the locally installed Swift toolchain (including Xcode toolchains on macOS) that you want to use Swift tools from. | ||
|
|
||
| The following command is only available on macOS: | ||
|
|
||
| - **`Select Target Platform...`** - An experimental command available in Swift 6.1 that offers code completion for iOS, tvOS, watchOS, and visionOS projects. | ||
|
|
||
| #### Building and Debugging | ||
|
|
||
| - **`Run Build`** - Run `swift build` for the package associated with the open file. | ||
| - **`Debug Build`** - Run `swift build` with debugging enabled for the package associated with the open file, launching the binary and attaching the debugger. | ||
| - **`Attach to Process...`** - Attach the debugger to an already running process for debugging. | ||
| - **`Clean Build Folder`** - Clean the `.build` folder for the package associated with the open file, removing all previously built products. | ||
|
|
||
| #### Dependency Management | ||
|
|
||
| - **`Resolve Package Dependencies`** - Run `swift package resolve` on packages associated with the open file. | ||
| - **`Update Package Dependencies`** - Run `swift package update` on packages associated with the open file. | ||
| - **`Reset Package Dependencies`** - Run `swift package reset` on packages associated with the open file. | ||
| - **`Add to Workspace`** - Add the current package to the active workspace in VS Code. | ||
| - **`Clean Build`** - Run `swift package clean` on packages associated with the open file. | ||
| - **`Open Package.swift`** - Open `Package.swift` for the package associated with the open file. | ||
| - **`Use Local Version`** - Switch the package dependency to use a local version of the package instead of the remote repository version. | ||
| - **`Edit Locally`** - Make the package dependency editable locally, allowing changes to the dependency to be reflected immediately. | ||
| - **`Revert To Original Version`** - Revert the package dependency to its original, unedited state after local changes have been made. | ||
| - **`View Repository`** - Open the external repository of the selected Swift package in a browser. | ||
|
|
||
| #### Testing | ||
|
|
||
| - **`Test: Run All Tests`** - Run all the tests across all test targets in the open project. | ||
| - **`Test: Rerun Last Run`** - Repeat the last test run. | ||
| - **`Test: Open Coverage`** - Open the last generated coverage report, if one exists. | ||
| - **`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). | ||
|
|
||
| #### Snippets and Scripts | ||
|
|
||
| - **`Insert Function Comment`** - Insert a standard comment block for documenting a Swift function in the current file. | ||
| - **`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. | ||
| - **`Run Swift Snippet`** - If the currently open file is a Swift snippet then run it. | ||
| - **`Debug Swift Snippet`** - If the currently open file is a Swift snippet then debug it. | ||
|
|
||
| #### Diagnostics | ||
|
|
||
| - **`Capture Diagnostic Bundle`** - Capture a diagnostic bundle from VS Code, containing logs and information to aid in troubleshooting Swift-related issues. | ||
| - **`Clear Diagnostics Collection`** - Clear all collected diagnostics in the current workspace to start fresh. | ||
| - **`Restart LSP Server`** - Restart the Swift Language Server Protocol (LSP) server for the current workspace. | ||
| - **`Re-Index Project`** - Force a re-index of the project to refresh code completion and symbol navigation support. | ||
|
|
||
| > 💡 Tip: Commands can be accessed from the VS Code command palette which is common to all VS Code extensions. See the [VS Code documentation about the command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) for a more in-depth overview. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
userdocs/userdocs.docc/installation.md → ...docs.docc/Articles/Topics/installation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's subtle, but you might want to include an Availability marker on this page to indicate this works with Swift 6.0+:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this makes sense to set for debugging. You are able to debug with older toolchains: we just switched to
lldb-dapinstead ofCodeLLDBin 6.0 and later.