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.

@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.

@amanthatdoescares
Copy link
Author

@matthewbastien I’ve added an integration test that runs the command end-to-end, verifies SwiftPM targets appear in the QuickPick, and asserts the DocC catalog is created on disk.

This is my first time writing an integration test in this codebase, so I’d really appreciate a review on the test structure and coverage.

import { tag } from "../../tags";
import { activateExtensionForSuite, folderInRootWorkspace } from "../utilities/testutilities";

tag("large").suite("Create Documentation Catalog Command", function () {
Copy link
Member

Choose a reason for hiding this comment

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

issue: This suite should be marked as either "medium" or "small". It definitely doesn't need 10 minutes just to create a directory. I'm leaning towards "small" in this instance since it really shouldn't take long at all.

Copy link
Author

Choose a reason for hiding this comment

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

i changed it to small

const basePath = selection.basePath;

// ---- module name input ----
const moduleName = await vscode.window.showInputBox({
Copy link
Member

Choose a reason for hiding this comment

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

issue: By convention the module name for a target should match the target name if the user selected one in the previous step. The extension should only ask for a folder if the user selected a standalone documentation catalog.

Copy link
Author

Choose a reason for hiding this comment

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

done

expect(await fs.stat(markdownFile)).to.exist;

const contents = await fs.readFile(markdownFile, "utf8");
expect(contents).to.contain("# MyModule");
Copy link
Member

Choose a reason for hiding this comment

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

issue: The module name when selecting a target should match the module name of that target.

Copy link
Author

Choose a reason for hiding this comment

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

yes, done


test("creates a DocC catalog for a SwiftPM target", async () => {
test("creates a DocC catalog for a SwiftPM target", async () => {
const quickPickStub = sinon.stub(vscode.window, "showQuickPick");
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: We have methods in MockUtils.ts that will do this for you using mocha's setup() and teardown() blocks. You don't need to use sinon.stub() or the try {} finally {} here. For example:

import { mockGlobalObject } from "../../MockUtils.ts";

suite("some-suite", () => {
    const windowMock = mockGlobalObject(vscode, "window");

    test("some-test", () => {
        windowMock.showQuickPick.resolves("blah");
    });
});

const inputBoxStub = sinon.stub(vscode.window, "showInputBox");

try {
inputBoxStub.resolves("MyModule");
Copy link
Member

Choose a reason for hiding this comment

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

issue: The module name quick pick should not be shown if selecting a target.

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