object-field-jsdoc.ejs 891 B

12345678910111213141516171819202122232425262728
  1. <%
  2. const { field, utils } = it;
  3. const { formatDescription, require, _ } = utils;
  4. const comments = _.uniq(
  5. _.compact([
  6. field.title,
  7. field.description,
  8. field.deprecated && ` * @deprecated`,
  9. !_.isUndefined(field.format) && `@format ${field.format}`,
  10. !_.isUndefined(field.minimum) && `@min ${field.minimum}`,
  11. !_.isUndefined(field.maximum) && `@max ${field.maximum}`,
  12. !_.isUndefined(field.pattern) && `@pattern ${field.pattern}`,
  13. !_.isUndefined(field.example) &&
  14. `@example ${_.isObject(field.example) ? JSON.stringify(field.example) : field.example}`,
  15. ]).reduce((acc, comment) => [...acc, ...comment.split(/\n/g)], []),
  16. );
  17. %>
  18. <% if (comments.length === 1) { %>
  19. /** <%~ comments[0] %> */
  20. <% } else if (comments.length) { %>
  21. /**
  22. <% comments.forEach(comment => { %>
  23. * <%~ comment %>
  24. <% }) %>
  25. */
  26. <% } %>