2
我有幾個共享某個底層數據結構的函數,同時也做了非常不同的事情,例如抽象並不是一個好主意。我可以在JSDOC中使用變量
文檔可能是這樣的(雖然這只是一個小樣本的許多方法只能分享一些這方面的文檔):
/**
* Creates an array of objects, with each object containing the average distance that minute. The
* objects have the keys **Timestamp** (ms since epoch), **Year** (year in device local time) **Month** (
* month in device local time), **Day** (day in device local time), **Hour** (hour in device local time)
* **Season** (season in device local time, Northern Hemisphere), **Weekday** (Week day name in device
* local time), **WeekNum** (week number (1-53) in device local time), **Depth** (the average depth that
* minute), and **Vibration** (the magnitude of the maximum acceleration for the minute, in Gs).
* <snip>
*/
/**
* Creates an array of objects, with each object containing the data for one minute of temperature data
* from temperature probes. The objects have the keys **Timestamp** (ms since epoch), **Year** (year in
* device local time) **Month** (month in device local time), **Day** (day in device local time), **Hour**
* (hour in device local time) **Season** (season in device local time, Northern Hemisphere), **Weekday**
* (Week day name in device local time), **WeekNum** (week number (1-53) in device local time),
* **Temperature** (Temperature measured by the temperature probe), **Vib**(the standard deviation of the
* acceleration of the accelerometer, in Gs).
* <snip>
*/
你可以從樣品,我震動的文檔和它看手段不一致。每次我改變它的含義時(甚至更糟糕的是,硬件工程師改變它的含義),我不想在6處去修復這些文檔。有沒有辦法讓我有一個全球性的術語詞典並根據需要插入它?就像:
terms.json
> {vibDef: "the magnitude of the maximum acceleration for the minute, in Gs"}
code.js
> /**
* Creates an array of objects, with each object containing the average distance that minute. The
* objects have the keys **Timestamp** (ms since epoch), **Year** (year in device local time) **Month** (
* month in device local time), **Day** (day in device local time), **Hour** (hour in device local time)
* **Season** (season in device local time, Northern Hemisphere), **Weekday** (Week day name in device
* local time), **WeekNum** (week number (1-53) in device local time), **Depth** (the average depth that
* minute), and **Vibration** (<<vibDef>>).
* <snip>
*/
這將插入我的定義vibDef無處不在文檔字符串中找到它?
我最後一次使用jsdoc,你可以關聯自己的解析器(我們把它用於降價),因此增加一個爲你的詞彙表標籤應該是可能的? – ssube