小编Ali*_*iou的帖子

使用 YARD 记录元编程创建的方法

我目前正在研究 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 记录这些方法,但是在生成项目的文档时,这些方法不会出现在类文档中。

有谁知道我如何记录这些?我错过了什么吗?

ruby documentation metaprogramming yard

5
推荐指数
1
解决办法
274
查看次数

UITableViewController,自定义数据源不显示单元格

我目前有一个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)

uitableview ios swift swift3 xcode8

0
推荐指数
1
解决办法
989
查看次数

标签 统计

documentation ×1

ios ×1

metaprogramming ×1

ruby ×1

swift ×1

swift3 ×1

uitableview ×1

xcode8 ×1

yard ×1