T
T
TedMarsh2021-09-11 14:46:23
JavaScript
TedMarsh, 2021-09-11 14:46:23

Why doesn't JSDoc see local comments?

In the code below , the jsdoc documentation generator does not see local comments on functions and variables.

document.addEventListener("DOMContentLoaded", function () {
  /**
   * Конвертирует Rem в Пиксели
   * @param   {Number} rem Сколько rem сконвертировать в пиксели
   * @returns {Number} Кол-во сконвертированных пикселей
   */
  function convertRemToPixels(rem) {
    return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
  }
});


That is, when compiling, there is a clear window:
613c95db13a3a757460792.png

When there is no wrapping function, JSDoc sees and you can read these comments:
/**
   * Конвертирует Rem в Пиксели
   * @param   {Number} rem Сколько rem сконвертировать в пиксели
   * @returns {Number} Кол-во сконвертированных пикселей
   */
  function convertRemToPixels(rem) {
    return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
  }

  console.log(convertRemToPixels(2))

613c96d68822b505219536.png

jsdoc.json:
{
  "source": {
    "include": "./src/js/main.js",
    "excludePattern": "(node_modules/|docs|dist)"
  },
  "plugins": ["plugins/markdown"],
  "templates": {
    "cleverLinks": true,
    "monospaceLinks": true
  },
  "opts": {
    "recurse": true,
    "destination": "./docs/",
    "readme": "./readme/readme.md"
  }
}


How to fix this JSDoc behavior?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question