Hello everyone. I would like kick off a discussion about linking between documentation for multiple targets and hosting documentation for multiple targets together.
As a first step I would like to focus the discussion on goals and use cases. Two example use cases that we aim to solve are:
- A team with two apps and a shared framework should be able to write documentation links from each app to the framework but not between the apps or from the framework to either of the apps (more on this later).
- A developer of a Swift package should be able to host documentation for all the targets in that package in one place.
Goals
A few key goals for combined documentation of multiple targets include:
A targetâs documentation should be able to link to that target's dependencies' documentation
Just like how targets can use dependenciesâ public symbols, the target's documentation should be able to link to public symbols, articles, and tutorials in its dependencies' documentation. The syntax to link to a dependency's documentation and local documentation should be the same. Developers should be able to link to a dependencies' documentation even if the dependency is defined outside of the current package or project.
Developers should be able to host multiple related targets in a single documentation archive.
Developers should be able to create documentation archives which contain documentation for multiple targets. Developers should have control over which targets are part of the multi-target documentation archive and which aren't. Developers should be able to create combined documentation archives for multiple targets even if the targets are not part of the same build workflow.
Documentation for targets sub-hierarchies should continue to be buildable as separate units
If a target can be imported individually it canât require that its documentation be build together with other related targets (unless they are dependencies of that target). The other targets may not even be buildable in the current build workflow due to differences in platform or SDK requirements.
Documentation archives should not contain known broken links
Links to documentation in other targets are only valid if both are hosted next to each other or if both are hosted together. Developers should have the ability to remove links to targets that wonât be hosted together.
Maintain as much flexibility as possible for direct callers
Developers who write their own tools and scripts that interact with DocC directly should have as much flexibility as possible to define dependencies between targets and define what targets are part of multi-target documentation archives.
Use cases
Below is a list of some of the use cases that we have considered. If there are important use cases that we have missed we would like to hear about it.
Swift package authors documenting their packages
A developer of a Swift package with multiple targets would continue to write documentation for each target, now with the additional ability for each target to link to documentation for its dependencies. They should be able to combine all their targets' documentation into a single documentation archive so that it can all be hosted in one place.
Developers of projects in separate repos that are conceptually related
Projects with conceptually related components across multiple different repos won't necessarilly be part of any single build workflow. They should still be able combine the documentation for these conceptually related targets into one combined documentation archive so that the documentation for all targets can be hosted together.
App, tool, or framework developers wanting to link to shared code and other dependencies
Similar to Swift package developers; teams working on apps, tools, or frameworks would write documentation for each target like with the new ability for each target to link to documentation for its dependencies. Regardless if the dependency is from the same project or an external dependency, developers should be able to link to its documentation. Declarations in the developer's target that use dependencies' public types should form automatic links to those symbols' documentation. The app developer team can optionally host their combined app and framework documentation but they can also read the locally built documentation if that's a better fit for their workflow.
Organizations wanting to host many unrelated documentation archives
Whether it's a group with many teams wanting to host each team's documentation in one place or projects like the Swift Package Index, we don't believe that documentation for unrelated targets or projects should be combined into one large documentation archive. However, some changes for multi-target documentation archives will also make it easier to host multiple separate documentation archives side-by-side.
Custom integrations
Developers who don't rely on build workflows to build their documentation have the ability to define their documentation "dependencies" and control how to combine the documentation into a single archive in their custom tooling. Documentation dependencies doesn't have to match target dependencies. A custom integration could build documentation with a dependency one way and then build it again with the dependency the other way but it wouldn't result in unrestricted back-and-forth linking between the two.
Frameworks or libraries that have example apps
DocC doesn't have specific support for documentation with example projects but it's a feature we'd like to support in the future and it's worth thinking about how an example app and a framework could link to each other. Following the target dependency order; documentation for the example app could link to symbols in the framework or library but the framework of library wouldn't be able to link to symbols in the example app. The framework likely doesn't need to link to individual symbols in the example app but it would be useful to be able to link to the example as a whole from the framework documentation that example app is showcasing. Depending on how documentation with example projects would workâwhich is far outside the scope for this proposalâthere are different ways to address this. It may even be that the page that describe the example project is part of the frameworks documentation and not the example's documentation.
Use cases for future directions
Two important uses cases for future directionsâwhich may be added over timeâare:
Developers linking to documentation for SDKs or other pre-built dependencies
App developers who use functionality from SDKs or other pre-built dependencies should be able to link to documentation for those dependencies as well. This would, for example, allow links to protocols in the Swift standard library that the developer's code conforms to.
Connecting hosted documentation with fully qualified links
When a developer hosts their documentation for a target that has external dependencies with their own hosted documentation, the target's hosted documentation should form fully qualified links to the dependencies' hosted documentation. Readers of the target's hosted documentation can click through to the dependencies' hosted documentation.
Call to action
Are there use cases or goals for combined documentation of multiple targets that we've missed? We want to know about them so that upcoming discussions about solutions can focus on the right problems.