Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

ios - How to go about adding a link/reference to another method in documentation Xcode?

I am adding some description to my method in class. This is how I achieved this:

enter image description here

And it looks like this upon clicking...

enter image description here

How can I make the underlined method clickable? I want it to be referenced so that when a user clicks on it, they are directed to a particular web page for documentation.

Is it even possible? Thanks in advance, any help will be appreciated

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

New in Xcode 13

Using the new DocC tool in Xcode, you can now reference other methods by using a double backtick.

If the type, property, or method you are referencing is not a "sibling" of the one you are documenting, you can refer to it by qualifying the reference.

struct House {
    /// The rooms in the house.
    var rooms: [Room]

    /// The maximum size of the household.
    ///
    /// This is calculated by summing the ``Room/occupancyLimit`` of this 
    /// house's ``rooms``.
    var maximumHouseholdSize: ...
}

struct Room {
    /// The maximum number of occupants allowed in the room.
    var occupancyLimit: ...
}

Here, the documentation comment for House.maximumHouseholdSize references House.rooms with:

``rooms``

because rooms is a sibling of maximumHouseholdSize.

It also references Room.occupancyLimit with:

``Room/occupancyLimit``

because occupancyLimit is not nested in the same type, but rather under the Room type.


Prior to Xcode 13

You can link to another method by tagging it with /// - Tag: and referring to it by Tag using the x-source-tag://[Tag] scheme like so:

/// - Tag: someMethod
func someMethod() {
   ...
}

/// Make sure to call [someMethod](x-source-tag://someMethod) at some point when overriding.
func otherMethod() {
   ...
}

Clicking on the someMethod link in the Quick Help pop-over will take you to the method and flash-highlight it in yellow.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...