2016-04-20 42 views
11

Zakładając, że mamy następujący kod wewnątrz klasy ES6 (dokumentacja):Jak rozszerzyć parametr typedef w JSDOC?

/** 
* @typedef Test~options 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 

Teraz chciałbym udokumentować inną funkcję, nazwijmy go test2. Ta funkcja pobiera dokładnie ten sam obiekt options, ale potrzebuje innej właściwości parent.

Jak udokumentować to bez dokumentacji opcji nadmiarowych? Zbędne środki:

/** 
* @typedef Test~options 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 


/** 
* @typedef Test~options2 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
* @property {object} parent - The parent element 
*/ 

/** 
* @param {Test~options2} opt - Option object 
*/ 
test2(opt){ 

} 
+0

referencyjną na GitHub: https://github.com/jsdoc3/jsdoc/issues/1199 – dude

Odpowiedz

2

Wypróbuj już

/** 
* @typedef {object.<string>} Test~options 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 

/** 
* @typedef {Test~options} Test~options2 
* @property {object} parent - The parent element 
*/ 

/** 
* @param {Test~options2} opt - Option object 
*/ 
test2(opt){ 

} 
+0

To najlepsze rozwiązanie do tej pory, ponieważ określa ** typ ** z 'Test ~ options2' jako' Test ~ options', łączący z drugim. Ale to nie jest idealne, ponieważ nie powtarza wszystkich parametrów swojego "rozszerzonego" typu; wyświetla tylko nowe parametry. JSDoc powinien pracować nad lepszym znacznikiem dla tego. – chharvey