我将在黑暗中尝试一下,因为我无法代表 jQuery 团队说明原因I不会使用 JSDoc。 JSDoc,至少我上次检查时,没有任何干净的方法来支持方法重载(或参数转移......无论你想在这里给它起什么名字),而 jQuery 到处都使用它。让我们举一个简单的常见例子.animate() http://api.jquery.com/animate/:
.animate({ height: 5 })
.animate({ height: 5 }, 100)
.animate({ height: 5 }, 100, "linear")
.animate({ height: 5 }, 100, "linear", func)
.animate({ height: 5 }, 100, func)
.animate({ height: 5 }, func)
.animate({ height: 5 }, { duration: 100, queue: false })
.animate({ height: 5 }, { duration: 100, easing: "linear" })
.animate({ height: 5 }, { duration: 100, easing: "linear", complete: func })
所有这些都是有效的,因为根据需要检查和转移参数类型 http://github.com/jquery/jquery/blob/master/src/effects.js#L275尽可能支持任何重载场景...这只会让 JSDoc 感到困惑,没有干净的方法将这些可选参数添加到文档中。如果情况发生了变化,请纠正我,但我上次查看(可能是团队最后一次查看)情况仍然如此。
另一个潜在的考虑因素是 jQuery 运行时如何生成一些方法,例如(许多方法之一),几乎所有事件处理程序快捷方式 http://api.jquery.com/category/events/ are 循环生成 http://github.com/jquery/jquery/blob/1.4.3/src/event.js#L1142其他方法的类似行为...您将如何记录这些? JSDoc 生成在这里确实不能很好地工作。