swift-doc icon indicating copy to clipboard operation
swift-doc copied to clipboard

Add the ability to hide certain underscored attributes

Open karwa opened this issue 4 years ago • 0 comments

A project I'm working on makes use of @_specialize as an alternative to inlining in certain circumstances. It can be a really great tool for getting the best performance with the smallest code size. Unfortunately, it leads to quite a bit of noise in the documentation.

It would be great if there was a way to hide these. @_specialize is irrelevant to anybody who uses an API - essentially what it does is, well, generates specialisations of a generic function, and within the function call, figures out if there's an optimised copy to dispatch to. Basically it's like making the compiler write:

func myFunc<S: StringProtocol>(_ value: S) -> Int {
  if let stringValue = value as? String {
    return myFunc_specialised_for_string(stringValue)
  } else if let substringValue = value as? Substring {
    return myFunc_specialised_for_substring(substringValue)
  } else {
    return myFunc_unspecialised(value)
  }
}

image

karwa avatar Mar 28 '21 17:03 karwa