Ross 🧼

Ross 是一个 Swift 命令行工具,用于移除 Swift 代码中的所有注释。

-/**
-Registers a handler in an `Application` for a given path.
-
-- Parameters:
-  - app: The `Application` to register the handler in.
-  - path: The path to register the handler for.
-*/
public func register(in app: Application, for path: String) {
  app.on(method, path.pathComponents) { [handle] req async throws in
    try await handle(req)
  }
}

警告 目前,Ross 几乎肯定无法移除所有你想要移除的注释。 如果你发现有注释遗留,请提交 issue,以便我们可以添加适当的 visit(_:) 函数的专用版本以及测试用例。

基本用法

swift run ross <directory> [--remove-plain <remove-plain>]
ARGUMENTS:
  <directory>             The folder whose contents you want to remove comments from.

OPTIONS:
  --remove-plain <remove-plain>
                          Whether or not Ross should remove plain comments. (default: true)
  -h, --help              Show help information.

建议将其与 swift-format 结合使用,特别是 "maximumBlankLines" 规则,以处理删除注释后可能残留的任何多余的换行符。

为什么叫 Ross?

Charles Ross,哈里·杜鲁门总统的白宫新闻秘书,首次记录使用了“无可奉告” 作为对问题的标准答案。