Are there updates on using Swift-DocC with multiple targets?

I noticed that this has been talked about in both of the following threads:

However, the latest reply (out of both threads) is September 2023. Are there any updates on these use cases? Are they able to be used currently, or not?

3 Likes

Yes. There has been a significant progress on building out support for both linking between documentation for multiple targets and hosting documentation for multiple targets together.

The two main reason for not posting an update in the forums yet is that the experience was rather limited until most of the pieces was in place and that it required running multiple commands in a script to build a combined documentation archive with links between targets.

Render combined navigation for merged documentation archives by mportiz08 · Pull Request #877 · swiftlang/swift-docc-render · GitHub will address one of the last limitations to a early, initial experience and Add initial experimental support for combined documentation for multiple targets by d-ronnqvist · Pull Request #84 · swiftlang/swift-docc-plugin · GitHub will make it convenient to build a combined documentation archive with links between targets.

I'll post a real update in the forums when both those pieces have landed, which will make it the first early version that's usable end-to-end and that solves some of the most common use cases.

8 Likes

Oh this is great to know, thank you.

I see that the first one is merged already.

Should I be able to use your branch of the plugin now, or does it require some special toolchain? I didn’t try yet, but I might soon.

You can use that branch of the plugin with the Xcode 16 betas. The plugin will warn and exit if the toolchain doesn’t support the necessary features.

1 Like

@ronnqvist

It looks like both of the branches you mentioned have been merged. Do you have an estimate on when they will they be landing in Swift?

Thanks!

EDIT: It looks like it's based on the plugin. Is there documentation on how to use the flag specifically?

EDIT (again): OK, I've played around with it and it seems the single target case for previews stops me from being able to link between my targets.

The initial Swift-DocC and Swift-DocC Render changes are already available in recent Swift 6.0 toolchains.

Additionally, as we were working on this and using it we realized that we also wanted to land Synthesize a minimal landing page for combined archives by d-ronnqvist · Pull Request #1011 · swiftlang/swift-docc · GitHub for as an important enhancement and Support `--output-path` when building documentation for multiple targets. by d-ronnqvist · Pull Request #89 · swiftlang/swift-docc-plugin · GitHub as a quality-of-life improvement.

The former is available in recent Swift development toolchains and all Swift-DocC Plugin changes are available in the 1.4.x release.

With those changes, we feel like there's enough pieces in place for people to try out an early preview of what's currently available. I made a separate post about this just now.

Because there may still be breaking changes we've not updated the main package documentation to cover this yet. However, the plugin 1.4 release notes and the other forums thread from just now both show minimal examples of using the new flag.

In short, it should just be "build some number of targets/products" and pass the --enable-experimental-combined-documentation flag. You don't need to pass any extra feature flags to DocC. The plugin takes care of that.

3 Likes

Yay. I am here to report some success.

Now that everything is merged, I can just use the swift-docc-plugin 1.4.0 or greater in my package, and use the --enable-experimental-combined-documentation to generate some basic combined documentation for my packages as expected. Cross-module links appear to work fine. :tada:

5 Likes