Skip to content

The docc-plugin preview-documentation sometimes fails to preview content with snippets #99

@heckj

Description

@heckj

The docc-plugin preview-documentation command appears to be failing to generate a module index page when snippets are added to the project.

This is with Swift 6.0.2 and swift-docc-plugin 1.4.3 (Xcode 16.1 release).

When I run the command to preview my documentation:

swift package --disable-sandbox preview-documentation --target Voxels

I see the (mostly) normal output:

Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build of product 'snippet-extract' complete! (0.18s)
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build of target: 'Voxels' complete! (0.15s)
Input: /Users/heckj/src/Voxels/Sources/Voxels/Documentation.docc
Template: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/docc/render
========================================
Starting Local Preview Server
	 Address: http://localhost:8080/
========================================
Monitoring /Users/heckj/src/Voxels/Sources/Voxels/Documentation.docc for changes...

A difference from what I expected is that there's no documentation/voxels on the URL presented, which happens on other projects.
When I opened a browser, going to http://localhost:8080/documentation/voxels, the JS browser error reports a missing file voxels.json.
Looking at the .build directory, I see .build/plugins/Swift-DocC Preview/outputs/Voxels.doccarchive/data/documentation, the directory of which voxels within it and a collection of all the symbols in JSON format. However, there isn't a voxels.json file in that directory.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected behavior

Describe what you expected to happen.

Actual behavior

Describe or copy/paste the behavior you observe.

Steps to Reproduce

git clone https://github.com/heckj/voxels
cd voxels
git checkout 7c70985
swift package --disable-sandbox preview-documentation --target Voxels

(URL for the above shows http://localhost:8080/documentation/voxels and resolves correctly)

git checkout 6089364
swift package --disable-sandbox preview-documentation --target Voxels

(URL for the next commit shows http://localhost:8080/ and fails to resolve)

The only difference between these two commits is adding the file Snippets/example-snippet.swift to the project.

Swift-DocC Plugin Version Information

Swift-DocC plugin version: 1.4.2 for example, or a commit hash.
Swift Compiler version: Output from swiftc --version:

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions