これは JavaScript です。元のメソッドに簡単にパッチを適用してドキュメントを生成することもできます。
以下は、coffeescript のサンプル コードです。
express = require 'express'
methods = require 'express/node_modules/methods' # array of all HTTP methods
app = express()
methods.forEach (method) ->
orig = app[method]
app[method] = (path, handler) ->
console.log "patched method ", method, " ", path
# generate docs here
orig.apply(this, arguments)
を使用してハンドラ関数のコードを取得することもできますhandler.toString()
。いくつかの Regex-Fu を追加すると、次のように記述された関数からより多くのメモを抽出できます。
app.get "/foo", (req, res) ->
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit"
more code here