I know a bit of CMake, but I'd really like some guidance or thoughts on a potential solution I'm trying to work out:
This is all about the Swift build, and generating the documentation for the standard library (which ultimately shows up at docs.swift.org). Today it's following a simple-ish pattern: when it builds the standard library normally, it tacks on a flag that emits the symbolgraphs for all the modules that it builds, and then in a sweep later, docc is provided a top level directory where all those symbol graphs were emitted, and is uses them all together.
That's working, but it's throwing in a whole bunch of symbols that shouldn't be exposed in DocC, highlighted with Standard Library documentation includes unavailable enumerations · Issue #175 · swiftlang/docs · GitHub.
In digging through the build scripts and trying to grok them, the symbol graphs for modules are getting triggered when a module is "tagged" with IS_STDLIB, sometimes that happens indirectly through the "tag" IS_SDK_OVERLAY (such as Observation).
I think the solution I'd like to aim for would make an exclusion list - either building a list of files or tags or something, potentially in CMake - that we'd want to exclude. There's already two hard-coded as exclusions in the CMake setup today - swiftDarwin, and swiftDifferentiationUnittest. This would extract those two hard coded exceptions and start building a bigger list (so we could exclude StdlibUnittest, SwiftPrivate*, RuntimeUnittest, SwiftReflectionTest, and _RegexBuilder, among the set) and only generate symbolgraphs when those values aren't hit.
What I'm not super clear on is it doing this in CMake is the right place, or if this should be driven from elsewhere - a different layer (such as the python that we have convenience methods set up to call through it). It kind of looks like we've really leaned into CMake for most of this, so I think that make sense, but I'd like some validation.
I also want to set it up so that only the things we want to explicit exclude are dropped, so that if/when we add other modules to the standard library in the future, the process automatically includes generating those symbol graphs - which ultimately get included and built with the DocC catalog content for the standard library.
I'm thinking:
- declaring the list - perhaps in
stdlib/cmake/modules/StdlibOptions.cmakethat is the exclusions that we'll use - update
stdlib/cmake/modules/AddSwiftStdlib.cmakearound 1044 to use that list instead of the hardcoded exceptions - add to the list to exclude _RegexBuilder, SwiftPrivate*, StdlibUnittest, RuntimeUnittest, SwiftReflectionTest, and so forth - the various modules that we just don't need the symbols for in the standard library.
Is this a reasonable approach? Am I attempting to solve this problem at too low a level?