Expand PackagePlugin API to enable full documentation for package traits

In following up on enabling traits deeper into the swift ecosystem, I dug into how to enable a feature request to add the traits support for generating documentation.

What I found was that the docc-plugin code uses the getSymbolGraphs API from the PackagePlugin interface that Package Manager exposes - but there’s currently no path to request either specific or all traits for a package. I think the correct path is to expand this API surface to support some indicator of traits with the getSymbolGraphs API - most likely the options.

I opened an issue/feature-request on SwiftPM for this feature, but before I start hacking on prototypes or solutions, I wanted to inquire here to see if I’m on the right path - or if there’s another API or alternate path that I was missing for getting symbol graphs back to the docc-plugin from SwiftPM that allowed me to specify package traits.

I also haven’t (yet) dug through all the package plugin code paths to really understand how or where the code currently does the work - so for anyone that’s been down that path before, are there any gotchas to look out for, or constraints that a solution would need to reside within? My initial thought was to expand the “options” struct that the API accepts to allow for specifying traits, and then passing that through and using it within the package manager to either retrieve the relevant symbols or invoke a build to create them in order to pass them back.

This sounds like something the plugin API should support, but I think it exposes a bigger problem with the symbol graph plugin API today, that it’s separate from the build API and lacks the same expressivity while performing more or less the same work. I think it’s worth considering if BuildParameters should gain:

  • API to enable traits
  • API to request a symbol graph emitted during the build be emitted in the BuildResult

That would ensure that in addition to supporting your use case, future (and existing) build config options like configuration, extra C flags, etc. can be taken into account when generating a symbol graph in a plugin.

4 Likes