swiftlang / swift-docc-plugin

Swift Package Manager command plugin for Swift-DocC
https://swiftpackageindex.com/apple/swift-docc-plugin/1.3.0/documentation/swiftdoccplugin
Apache License 2.0
316 stars 54 forks source link

swift-docc-plugin generate-documentation results in empty docc catalog - no symbols - when using a local binary target/XCFramework #50

Open heckj opened 1 year ago

heckj commented 1 year ago

Swift-docc-plugin is failing to generate documentation for a swift package that is using a binaryTarget with a local reference to an XCFramework, which is provided to include a local static binary library (compiled from another language: Rust in this case)

possibly related, depending on the underlying logic used to get the symbol graphs - I found an issue with swift package dump-symbol-graph with the same package + local binary target setup, opened as https://github.com/apple/swift-package-manager/issues/6162. If swift-docc-plugin relies on that functionality, that might be the underlying issue. I wasn't sure however, so I wanted to open this as well.

The command in question:

$(xcrun --find swift) package \
      --allow-writing-to-directory ./docs \
      generate-documentation \
      --fallback-bundle-identifier com.github.y-crdt.Yniffi \
      --fallback-bundle-version 0.16.1 \
      --target Yniffi \
      --output-path ./docs \
      --emit-digest \
      --disable-indexing \
      --transform-for-static-hosting \
      --hosting-base-path 'Yniffi'

Note that manually generating the symbol graphs and then invoking docc directly does work:

rm -rf .build .symbol-graphs
mkdir -p .symbol-graphs

$(xcrun --find swift) build --target Yniffi \
    -Xswiftc -emit-symbol-graph \
    -Xswiftc -emit-symbol-graph-dir -Xswiftc .symbol-graphs

$(xcrun --find docc) convert swift/scaffold/Documentation.docc \
    --fallback-display-name Yniffi \
    --fallback-bundle-identifier com.github.y-crdt.Yniffi \
    --fallback-bundle-version 0.16.1 \
    --additional-symbol-graph-dir .symbol-graphs \
    --emit-digest \
    --transform-for-static-hosting \
    --output-path ./docs \
    --hosting-base-path 'Yniffi'

Checklist

Expected behavior

Actual behavior

./docs/linkable-entities.json contains only [] ./docs/indexing-records.json contains only []

Steps to Reproduce

Note: full reproduction requires building the XCFramework locally - which currently requires Rust to be installed locally.

  1. git clone https://github.com/heckj/y-uniffi.git
  2. cd y-uniffi
  3. git checkout yrs_16_2
  4. cd lib
  5. ./build-xcframework.sh
  6. swift build # works correctly, no issues
  7. run command to generate empty docs:
$(xcrun --find swift) package \
      --allow-writing-to-directory ./docs \
      generate-documentation \
      --fallback-bundle-identifier com.github.y-crdt.Yniffi \
      --fallback-bundle-version 0.16.1 \
      --target Yniffi \
      --output-path ./docs \
      --emit-digest \
      --disable-indexing \
      --transform-for-static-hosting \
      --hosting-base-path 'Yniffi'

Swift-DocC Plugin Version Information

Swift-DocC plugin version: 1.1.0 Swift Compiler version:

swift-driver version: 1.75.1 Apple Swift version 5.8 (swiftlang-5.8.0.117.11 clang-1403.0.22.8.60)
Target: arm64-apple-macosx13.0

(Issue was also happening identically with swift 5.7 release)