1

I am checking new Apple documentation on Xcode 13 beta. I am able to build documentation with DocC.

But I am not able to see any documentation created for extensions like String extension, Date extension.

As per example for below case it will not add any documentation.

extension String {

    /// Description for DocC
    func myMethod() {
       
    }
}

Consider, If I have created an extension for any struct or class, then it is adding documentation like below code

public struct MyStruct {

}


extension MyStruct {

  /// Description
  func myMethod() {
 
  }
}

Is this default behaviour by apple or I am missing anything?

PJR
  • 13,052
  • 13
  • 64
  • 104

1 Answers1

6

This is not currently supported. DocC cannot generate documentation for anything but a single module's types. Extensions to types outside your module aren't handled. (It also won't allow you to link to types outside your module using ``...`` references.)

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Thanks Rob Napier. Is this a XCode beta limitation? Do you have any specific doc link where above scenario mentioned ? – PJR Aug 31 '21 at 18:26
  • 1
    It's a limitation of the beta, but there's no indication that it'll be improved for release (Apple rarely announces what they plan to improve until it's released, so it might). There is no official list of DocC limitations that I'm aware of (it'll be open sourced later this year, but is not yet). But this does not work, and neither do the related use cases described. Symbols are resolved relative to the current module only. When the 360iDev talks are published Ellen Shapiro did an excellent talk on this. https://speakerdeck.com/designatednerd/navigating-docc-360idev-denver-august-2021 – Rob Napier Aug 31 '21 at 19:17
  • 1
    Note that this even applies to Swift PM packages that have include multiple modules. You can't link outside of the current module at all, even inside the same SPM package. That's the nature of v1.0. – Rob Napier Aug 31 '21 at 19:18
  • There's an (as of 2022-04-14) [open issue](https://bugs.swift.org/browse/SR-15410) on this limitation. I seems it being addressed, at least there's a [discussion](https://forums.swift.org/t/document-extensions-to-external-types-using-docc/56060). – Kenneth Laskoski Apr 14 '22 at 22:14