swiftlang / swift-docc-plugin

Swift Package Manager command plugin for Swift-DocC
https://swiftpackageindex.com/swiftlang/swift-docc-plugin/documentation/swiftdoccplugin
Apache License 2.0
322 stars 53 forks source link

package preview-documentation doesn't display pathing to docs target, and top-level page is throwing an error when resolving. #75

Open heckj opened 2 years ago

heckj commented 2 years ago

Description

Using the tools versioned with 5.7.0 release:

/Applications/Xcode-14.1beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package --disable-sandbox tools-version
5.7.0

(This is also with the swift-docc-plugin branch of main to get snippets to work.)

When I invoke swift package preview-documentation:

export DOCC_JSON_PRETTYPRINT=YES
om.github.heckj.DoccSnippetExample \
 $(xcrun --find swift) package \
     --disable-sandbox \
     preview-documentation \
     --target DoccSnippetExample

The preview no longer shows the extension of the target. The output I'm seeing is:

========================================
Starting Local Preview Server
     Address: http://localhost:8000/
========================================

Where it used to display the full path to the target: http://localhost:8000/documentation/doccsnippetexample/

That root page also displays an error when you try to access it:

Screen Shot 2022-10-01 at 3 18 56 PM
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8000/data/documentation/doccsnippetexample.json

And when I looked into the directory structure, the json file is located inside the target - so I'm suspecting there's been a slight adjustment somewhere and parts aren't quite aligned for where swift-docc-render looks for JSON files.

In the on-disk directory, the JSON file for this page resides at: docs/data/documentation/doccsnippetexample/doccsnippetexample.json and I'm thinking that the preview server and docs-render is expecting to find it at docs/data/documentation/doccsnippetexample.json.

I'm uncertain, but suspect these might be related (target directory and broken link with preview), so I'm including them into a single report, but I'm happy to break them up as well.

Checklist

Expected Behavior

No response

Actual behavior

No response

Steps To Reproduce

For a reproduction case:

clone the repo:

(which invokes:

export DOCC_JSON_PRETTYPRINT=YES

 $(xcrun --find swift) package \
     --disable-sandbox \
     preview-documentation \
     --target DoccSnippetExample

Swift-DocC Version Information

'5.7.0'

Swift Compiler Version Information

swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.134.3 clang-1400.0.29.51)
Target: arm64-apple-macosx12.0