分别记录破坏分配中的元素

发布于 2025-02-10 12:15:07 字数 1230 浏览 0 评论 0原文

在Swift中,您可以为这样的单个声明编写文档注释:

/// The title of the view.
private var title: String

当您将光标放置在使用> title的情况下时,XCode会自动显示此文档。您可以使用MARKDOWN以及一些Swift特定的语义格式,如 nofollow noreferrer”>此nshipster文章

是否可以单独记录由于这样的破坏分配而产生的变量?

private var (titlePromise, titleSeal) = Promise<String>.pending()

我尝试了我认为是显而易见的事情,

private var (
    /// Promise that will resolve when we receive the view's title.
    titlePromise,
    /// Resolver function for the view's title.
    titleSeal
) = Promise<String>.pending()

但是Xcode并未对这些评论进行接触。我发现可以将DOC评论放在两个之前,

/// Promise and resolver for the view's title.
private var (titlePromise, titleSeal) = Promise<String>.pending()

在这种情况下XCode将该文档应用于Promise> Promiseseal。这不是理想的,因为这些变量(相关)是单独用途的单独类型。

是否可以以Xcode可以拿起的方式在元组分配中分别记录(或全部)元素?

In Swift, you can write a documentation comment for a single declaration like this:

/// The title of the view.
private var title: String

This documentation is automatically displayed by Xcode when you put your cursor on a use of title. You can use Markdown along with some Swift-specific semantic formatting, as described in this NSHipster article.

Is it possible to separately document the variables resulting from a destructuring assignment like this?

private var (titlePromise, titleSeal) = Promise<String>.pending()

I tried what I thought was the obvious thing,

private var (
    /// Promise that will resolve when we receive the view's title.
    titlePromise,
    /// Resolver function for the view's title.
    titleSeal
) = Promise<String>.pending()

but Xcode did not pick up on these comments. I found that it was possible to put a doc comment before both,

/// Promise and resolver for the view's title.
private var (titlePromise, titleSeal) = Promise<String>.pending()

in which case Xcode applies that documentation to both promise and seal. This is not ideal, since those variables—while related—are separate types with separate uses.

Is it possible to separately document both (or all) of the elements in a tuple assignment in a way that Xcode will pick up on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瓜 2025-02-17 12:15:07

即使我早些时候也有同样的要求,但我没有找到任何这样的解决方案。尽管Apple在编写不同类型的代码评论的帮助下提供了丰富的文档,但到目前为止,还没有办法为元组属性编写文档评论。但是,或者我遇到这样的写作。

/// A tupple property whcih holds the values of title
/// - Parameters:
///     - titlePromise: So on so.....
///     - titleSeal: So on so.....
/// ```
/// mTitle = Promise<String>.pending()
/// print(mTitle.titlePromise)
/// ```
var mTitle: (titlePromise: String, titleSeal: String)?

Even I had same requirement earlier but I didn't found any such solution. Though apple providing the rich documentation with the help of writing different types of code commenting, till now there is no way of writing documentation comment for a tuple property. But, alternatively I come across writing like this.

/// A tupple property whcih holds the values of title
/// - Parameters:
///     - titlePromise: So on so.....
///     - titleSeal: So on so.....
/// ```
/// mTitle = Promise<String>.pending()
/// print(mTitle.titlePromise)
/// ```
var mTitle: (titlePromise: String, titleSeal: String)?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文