我試圖記錄與JSDoc JavaScript文件(3)像這樣:JSDoc - 標記一些代碼不被解析但保留文檔?
/** 1 if gnome-bluetooth is available, 0 otherwise
* @type {boolean}
* @const
*/
const HAVE_BLUETOOTH = @[email protected];
現在的文件(稱爲config.js.in
)是不是對自己有效的JavaScript;該文件將通過一個Makefile替換適當的值爲@[email protected]
。
當我嘗試在此上運行JSdoc時,它(可以理解)由於文件中的語法錯誤而變得遲鈍。
是否有某種方式來告訴JSDoc忽視在這個文件中的所有代碼,但單純考慮註釋? (我可能需要爲每個doclet添加@name
標記,以將代碼中的文檔完全分開;這很好)。
喜歡的東西:
/** 1 if gnome-bluetooth is available, 0 otherwise
* @name HAVE_BLUETOOTH
* @type {boolean}
* @const
*/
/** @ignore */ // somehow ignore from here onwards
const HAVE_BLUETOOTH = @[email protected];
/** [email protected] */ // somehow don't ignore from here onwards (although I'd be happy
// to ignore the entire file)
我寧願不修改文件的代碼的一部分,如果可能的話(我的文檔添加到現有的項目)。例如,我也許可以繞過它與
const HAVE_BLUETOOTH = parseInt('@[email protected]', 10);
這將使該文件又具有有效的JS語法,這樣分析器不抱怨,但是這也意味着我修改原始文件的代碼這是我想避免的(我更喜歡只是添加文檔)。
歡呼
您是否找到解決方法? –
難道你不能改變管道,以便jsdoc在你縮小之前在一箇中間的編譯版本上運行嗎?如果沒有,那麼一個不太侵入性的代碼破解是const HAVE_BLUETOOTH = +'@ HAVE_BLUETHOOTH @'; – lemonzi