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

Support `--output-path` when building documentation for multiple targets. #89

Closed d-ronnqvist closed 3 weeks ago

d-ronnqvist commented 3 weeks ago

Bug/issue #, if applicable:

Summary

Support passing a custom --output-path value when building documentation for multiple targets.

This is technically unrelated to support for combined documentation archives, but it's more likely that developers will pass a custom output path when building combined documentation for multiple targets.

I implemented this PR in steps:

Additionally, this PR makes the following changes

Dependencies

This builds on top of #87 and #88. The new changes in this PR start with https://github.com/swiftlang/swift-docc-plugin/commit/e66ee31902270dc48b3cfeb505ee16ebd24bfbe8 and onwards. You can see that subset of the diff here.

Additionally, this PR conditionally uses some new functionality in https://github.com/swiftlang/swift-docc/pull/1011.

Testing

There are 3 behaviors to test in this PR

Note that in all cases you need to disable package sandboxing to use a custom output path.

You can use the package plugin repo itself to test this.

Single target

Build documentation for one target with a custom output path

swift package \
  --disable-sandbox \
  generate-documentation \
  --target Snippets \
  --output-path MyOutputDir

After the build succeeds, the "MyOutputDir" directory should contain the content of the Snippets target's documentation.

Multiple targets

Build documentation for two (or more) targets with a custom output path

swift package \
  --disable-sandbox \
  generate-documentation \
  --target Snippets \
  --target SwiftDocCPlugin \
  --output-path MyOutputDir

After the build succeeds, the "MyOutputDir" directory should contain the two subdirectories named "Snippets.doccarchive" and "SwiftDocCPlugin.doccarchive" that each contain that target's documentation.

Combined targets

Build combined documentation for two (or more) targets with a custom output path

swift package \
  --disable-sandbox \
  generate-documentation \
  --target Snippets \
  --target SwiftDocCPlugin \
  --enable-experimental-combined-documentation \
  --output-path MyOutputDir

After the build succeeds, the "MyOutputDir" directory should contain the content of the combined documentation archive.

The plugin only prints the combined archives's output path. It doesn't print the individual target's output paths, even though they were built to produce the combined archive.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

d-ronnqvist commented 3 weeks ago

@swift-ci please test

d-ronnqvist commented 3 weeks ago

@swift-ci please test

d-ronnqvist commented 3 weeks ago

@swift-ci please test

d-ronnqvist commented 3 weeks ago

@swift-ci please test