-
Notifications
You must be signed in to change notification settings - Fork 89
Add command to create a Swift DocC documentation catalog #2006
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
base: main
Are you sure you want to change the base?
Add command to create a Swift DocC documentation catalog #2006
Conversation
matthewbastien
left a comment
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.
Thank you for this PR! There are a few issues that need to be resolved before this can be merged.
Co-authored-by: Matthew Bastien <[email protected]>
Co-authored-by: Matthew Bastien <[email protected]>
|
|
||
| if (hasPackageSwift) { | ||
| try { | ||
| const { stdout } = await execFileAsync("swift", ["package", "dump-package"], { |
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.
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.
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.
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.
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.
done
| for (const name of targets) { | ||
| const srcPath = path.join(rootPath, "Sources", name); | ||
| try { | ||
| await fs.access(srcPath); |
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.
you can use fileExists in utilities/filesystem instead
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.
once i read filesystem i think folderExists is much more accurate in this case
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.
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); |
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.
fileExists here as well
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 think folderExists is much accurate here
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.
You'll have to use pathExists().
|
I'd also like to have an integration test for this since the logic will be interacting with the |
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:
<Module>.doccdirectoryThis 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