IT이야기

JSDoc을 사용하여 'const z = (y)' = > (a, b = 3) > []'를 문서화하는 방법

cyworld 2022. 6. 5. 19:14
반응형

JSDoc을 사용하여 'const z = (y)' = > (a, b = 3) > []'를 문서화하는 방법

JSDoc에서 아래의 기능을 문서화할 방법을 찾아야 합니다.

/**
 * Return the collection from cache based on the hash, page and pagination count
 * @param state
 * @returns {function({hash: *, page: *, pagination?: *}): ([]|*)}
 */

export const collection = (state) => ({ hash, page, pagination = 60 }) => {
  if (!state.models[hash]) return []
  // deep copy the object because of the collection property array
  const model = JSON.parse(JSON.stringify(state.models[hash]))
  const end = page * pagination
  const start = end - pagination
  return model.collection.splice(start, end)
}

편집

위의 코멘트를 로 변경하여 발생한 오류를 수정했습니다.

/**
 * Return the collection from cache based on the hash, page and pagination count
 * @type {object}
 * @param state
 * @returns {function({hash: *, page: *, pagination: *}): Array}
 */

다음의 에러가 표시됩니다.

ERROR: Unable to parse a tag's type expression for source file 
/app/src/store/cache/getters.js in line 9 with tag title "returns" 
and text "{function({hash: *, page: *, pagination?: *}): ([]|*)}":
Invalid type expression "function({hash: *, page: *, pagination?: *}):
([]|*)": Expected "#", "$", "(", ",", "-", ".", "/", "0", ":", "<",
"=", "@", "[]", "\\", "_", "}", "~", "‌", "‍", Unicode combining mark,
Unicode decimal number, Unicode letter number, Unicode lowercase letter,
Unicode modifier letter, Unicode other letter, Unicode punctuation
connector, Unicode titlecase letter, Unicode uppercase letter, or
[1-9] but "?" found.

패키지.json

  "devDependencies": {
    ...
    "jsdoc": "^3.6.5",
    "jsdoc-vuejs": "^3.0.9",
    "jsdoc-vuex-plugin": "^1.0.0",
    ...
  },

https://github.com/Kocal/jsdoc-vuejs
https://github.com/martiensk/vuex-jsdoc

언급URL : https://stackoverflow.com/questions/70685018/how-to-use-jsdoc-to-document-const-z-y-a-b-3

반응형