gpt4 book ai didi

swift - 如何在 Xcode 中格式化代码,包括标记

转载 作者:行者123 更新时间:2023-11-30 12:37:00 25 4
gpt4 key购买 nike

我知道使用 Xcode 可以使用编辑器 -> 结构 -> 重新缩进来格式化代码,我遇到的问题是当我想重新缩进所有代码(包括标记)时这个:

/**
Append new motive to motives array
- parameters:
- name: A brief description of motive.
- returns: false if is empty otherwise true
*/

注意:如果我选择所有代码并重新识别它,标记代码将如下所示:

/**
Append new motive to motives array
- parameters:
- name: A brief description of motive.
- returns: false if is empty otherwise true
*/

这将影响显示的快速帮助,我在缩进之前和之后添加了两张图片。

缩进之前快速帮助:

Before Indent Quick Help

缩进后快速帮助:

enter image description here

看看在缩进我的代码后,快速帮助没有按应有的方式显示,特别是参数行它消失了,因为它需要从-参数缩进: 一个选项卡。

问题是如何缩进我的代码,包括对标记的适当缩进,或者如何选择我的所有代码缩进它但不影响标记。

最佳答案

看起来还有一些错误尚未修复。我推荐下面的方式来描述参数。

基本(与 Apple Development 相同)

/**
Append new motive to motives array

- parameters name: A brief description of motive
- parameters opt: A options

- returns: false if is empty otherwise true
*/
public func exampleFunc(_ name: String, options opt: Options) {
...
}

但我更喜欢使用 XCode 的自动缩进。

自动缩进(推荐方式)

/**
Append new motive to motives array

- parameters name: A brief description of motive
- parameters opt: A options

- returns: false if is empty otherwise true
*/
public func exampleFunc(_ name: String, options opt: Options) {
...
}

即使使用自动缩进,它也会使格式始终相同。

关于swift - 如何在 Xcode 中格式化代码,包括标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42742343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com