for those who aren’t aware, @theMomax did a lot of great work over the summer to land extension block symbols in lib/SymbolGraphGen, and although you probably need to enable some feature flags to use it in DocC, we can now theoretically provide documentation attached to individual extension blocks, as opposed to the extended type itself.
/// This is an extension block comment!
extension Wardrobe
{
}
/// This is another extension block comment!
extension Wardrobe
{
}
/// This is an extension block comment with a constraint.
extension Wardrobe where Season:ColdSeason
{
}
/// This is another extension block comment, where `Season == Spring`.
extension Wardrobe<Spring>
{
}
/// This is another extension block comment, where `Season == Summer`.
extension Wardrobe<Summer>
{
}
this is really exciting, but it presents a new connundrum: what to do when there is more than one doccomment per extended type?
unlike external markdown files, which can use merge directives to specify collation, there is not really an obvious collation strategy for multiple extension block comments. for example, we can:
- discard all doccomments, except for the longest one across all extension blocks that extend the same type, and then use filenames + source positions to break ties (this is the current behavior of DocC).
This is another extension block comment, where `Season == Spring`.
- concatenate doccomments across all extension blocks that extend the same type, using filenames + source positions to define ordering.
This is an extension block comment!
This is another extension block comment!
This is an extension block comment with a constraint.
This is another extension block comment, where `Season == Spring`.
This is another extension block comment, where `Season == Summer`.
- discard all doccomments, except for the longest one across all extension blocks that extend the same type with the same constraints, and then use filenames + source positions to break ties.
This is another extension block comment!
This is an extension block comment with a constraint.
This is another extension block comment, where `Season == Spring`.
This is another extension block comment, where `Season == Summer`.
- concatenate doccomments across all extension blocks that extend the same type with the same constraints, using filenames + source positions to define ordering.
This is an extension block comment!
This is another extension block comment!
This is an extension block comment with a constraint.
This is another extension block comment, where `Season == Spring`.
This is another extension block comment, where `Season == Summer`.
- something else.
i personally am leaning towards #3, because i think it’s valuable to provide documentation broken down by generic signature, and i’m not really a fan of tying documentation collation to source file names. but i am interested in hearing how others are documenting extensions, and if there are any approaches i may have missed.