Skip to content

Conversation

@amanthatdoescares
Copy link

@amanthatdoescares amanthatdoescares commented Dec 17, 2025

Description

This change adds a new Swift command that helps users get started with DocC documentation.

The command prompts for a module name and creates a basic DocC catalog in the workspace, including:

  • A <Module>.docc directory
  • An initial markdown file with the module title

This removes the need to manually set up the DocC folder structure and makes it easier to start documenting Swift packages directly from VS Code.

Issue: #1647

Tasks

  • Required tests have been written
  • Documentation has been updated (not applicable)
  • Added an entry to CHANGELOG.md if applicable

Copy link
Member

@matthewbastien matthewbastien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! There are a few issues that need to be resolved before this can be merged.


if (hasPackageSwift) {
try {
const { stdout } = await execFileAsync("swift", ["package", "dump-package"], {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information is already computed and stored on the folderContext.swiftPackage for each Swift Package folder open in the workspace. See https://github.com/swiftlang/vscode-swift/blob/main/src/commands.ts#L80 for a reference of how to get the folderContext for the currently active folder and pass it in to the command.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out — I wasn’t aware this information was already available via FolderContext. I’ll refactor the command to use folderContext.swiftPackage instead of invoking swift package dump-package.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

for (const name of targets) {
const srcPath = path.join(rootPath, "Sources", name);
try {
await fs.access(srcPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use fileExists in utilities/filesystem instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once i read filesystem i think folderExists is much more accurate in this case

Copy link
Member

@matthewbastien matthewbastien Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileExists() and folderExists() check for the path in question to be a file or folder respectively. You're going to want to use pathExists() because you can't create the folder if anything exists at that path regardless of whether or not it is a file, folder, symlink, etc.


const doccDir = path.join(basePath, `${value}.docc`);
try {
await fs.access(doccDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileExists here as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think folderExists is much accurate here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to use pathExists().

@matthewbastien
Copy link
Member

I'd also like to have an integration test for this since the logic will be interacting with the FolderContext. Something that runs the command and makes sure that all of the targets show up correctly in the quick pick. It should also make sure that the catalog gets created properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants