我目前正在研究 gem 并为其编写文档。我目前有一个类,其中定义了几种方法defined_method,如下所示:
class Client
['one', 'two'].each do |method_name|
# Sets the value
# @param argument the argument to set.
define_method("set_#{method_name}") do |argument|
# Method content
end
end
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 YARD 记录这些方法,但是在生成项目的文档时,这些方法不会出现在类文档中。
有谁知道我如何记录这些?我错过了什么吗?
我目前有一个UITableViewController,它在init函数中设置一个自定义数据源:
class BookmarkTableViewController: UITableViewController {
var date: Date
// MARK: - Init
init(date: Date, fetchAtLoad: Bool) {
self.date = date
super.init(style: .plain)
self.tableView.dataSource = BookmarkDataSource(date: date)
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
自定义数据源如下:
class BookmarkDataSource: NSObject {
let date: Date
init(date: Date) {
self.date = date
super.init()
}
}
// MARK: - UITableViewDataSource
extension BookmarkDataSource: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell …Run Code Online (Sandbox Code Playgroud)