Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc alters line breaks on Windows #2067

Open
matyasf opened this issue Aug 8, 2023 · 0 comments
Open

JSDoc alters line breaks on Windows #2067

matyasf opened this issue Aug 8, 2023 · 0 comments

Comments

@matyasf
Copy link

matyasf commented Aug 8, 2023

When parsing a function doc comment JSDoc alters the line breaks in the "description" section on Windows 10 (likely on other Windows versions too)

Input code

/**
 * ---
 * category: utilities
 * ---
 * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed
 * since the last tim
 */
function debounce()

JSDoc configuration

{
  "source": {
    "exludePattern": ""
  },
  "plugins": ["plugins/commentsOnly"]
}

Expected behavior

The "comment" and "description" fields have the same line breaks. It works OK on OSX, buggy on Windows10.

Current behavior

The code above results in the following output in Windows (irrelevant parts removed):

        "comment": "/**\r\n * ---\r\n * category: utilities\r\n * ---\r\n * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed\r\n * since the last tim",
        "description": "---\rcategory: utilities\r---\rCreates a debounced function that delays invoking func until after wait milliseconds have elapsed\rsince the last tim",
        "kind": "module",

Note that the line breaks were altered to \r in the "description" section from \r\n. On OSX the same part looks like this:

        "comment": "/**\n * ---\n * category: utilities\n * ---\n * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed\r\n * since the last tim",
        "description": "---\ncategory: utilities\n---\nCreates a debounced function that delays invoking func until after wait milliseconds have elapsed\nsince the last tim",
        "kind": "module",

\r in the Windows "description" part is not a valid line break in most systems and will cause most parsers to fail. Please alter it to \r\n.

Your environment

Software Version
JSDoc 4.0.0
Node.js 18.17.0
npm 9.6.7
Operating system Windows 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant