question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Provide way to link to other files from JSDoc comments

See original GitHub issue

Suggestion

šŸ” Search Terms

  • quickInfo
  • markdown
  • link
  • relative path
  • jsdoc

ā­ Suggestion

On VS Code, we have a long standing feature request to support relative file paths inside JSDoc comments: https://github.com/microsoft/vscode/issues/86564

For example, if if I have a file folder/foo.ts:

/**
 * [link](./other.js)
 */
export declare function foo(x: string, y: {}): void

Then anywhere the documentation for foo is shown, we should render link as a clickable link to folder/other.ts.

On the VS Code side today, we can support rendering link but do not know what relative paths inside the documentation should be relative to

Proposal

To fix this, I propose that requests that return documentation also include a path that tells us which file the documentation comes from

Hereā€™s an example using quickInfo:

[Trace  - 17:11:37.514] <semantic> Response received: quickinfo (292). Request took 2 ms. Success: true 
Result: {
    "kind": "function",
    "kindModifiers": "export,declare",
    "start": { "line": 4, "offset": 25    },
    "end": { "line": 4, "offset": 28 },
    "displayString": "function foo(x: string, y: {}): void",
    "documentation": [
        {
            "text": "[link](./files.js)",
            "kind": "text",

             // new field
             "file": "/absolute/path/to/folder/foo.ts"
        }
    ],
    "tags": []
}

This would likely be a new field on SymbolDisplayPart

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:28
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
mjbvzcommented, Feb 3, 2022

Not a huge fan of my original proposal actually

Instead of markdown, I think we should investigate adding proper file link support to JSDoc. As far as I can tell this isnā€™t supported in the jsdoc spec

Hereā€™s what this could look like using our existing @link support:

/**
 * {@link import('./main.ts') link}
 */
declare function foo(x: string, y: {}): void

Or we could come up with some new way to express file links:

/**
 * {@linkfile ./main.ts link}
 */
export declare function foo(x: string, y: {}): void

Having proper semantic file link support would be nice as we could include these references when you run find all reference to file and update them when you move a file

8reactions
Domiiicommented, Aug 27, 2022

From what I understand, you guys are saying that this is blocking https://github.com/microsoft/vscode/issues/86564.

Are there any updates on this? Would love to be able to link files, be it JS, or any file really.

  • I would also like to ask if its possible to add line/column numbers, as though you just throw it to the code CLI?
    • E.g. {@linkfile ../../x/y/z.js:42}
  • And another one: could we have support to have file links relative to a module name, iff the url does not start with (i) ., (ii) root or (iii) protocol?
    • E.g. {@linkfile my-module/x/y/z.js:42} instead of {@linkfile ../../../node_modules/my-module/x/y/z.js:42}?
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSDoc: {@link}
Link to another item in the documentation. ... The following example shows all of the ways to provide link text for the {@link}...
Read more >
VS Code tips ā€” Linking to a symbol in JSDoc ... - YouTube
link tags in JSDoc comments let you link to other symbols in your JavaScript or TypeScript project.These links show in hovers, suggestions,Ā ...
Read more >
javascript - Is it possible to tell jsdoc to look in a file separate ...
The key is to create a type definition with a unique name, and then use @see to link to that definition. @module and...
Read more >
JSDoc Reference - TypeScript: Documentation
Documentation tags work in both TypeScript and JavaScript. @deprecated; @see; @link. Other. @enumĀ ...
Read more >
JSDoc comments | WebStorm Documentation - JetBrains
WebStorm recognizes JSDoc comments and helps you create them by automatically inserting @param , @returns , @private , and other tags whenĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found