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.

Handling multiple comments per symbol

See original GitHub issue

TypeScript allows multiple comments to be attached to a symbol. Consider:

/** Comment one **/
enum A { a }
/** Comment two **/
enum A { b = 1 }

This presents a problem for documentation generators parsing the comments as they must either pick one of the comments, or take both comments and combine them. I believe tsdoc should either provide a function to merge comments, or should provide guidance on how to choose the comment to keep.

For reference, TypeDoc supports an @preferred tag which tells the generator which comment to use. If no @preferred tag is present, it will take the longest comment. VSCode (ts language service?) appears to simply concatenate any comment summaries and lists any @remarks blocks separately.

Related to the above, it might be worth standardizing what should happen if multiple comments are attached to a node, for example:

/** Comment one **/
/** Comment two **/
enum A { a }

In TypeDoc, only comment two would be used to document A. However, in VSCode, I again see that the summaries have been joined.

I understand this isn’t directly related to the parsing of an actual comment, which is tsdoc’s focus. However, it is a closely related issue which would benefit from a standard.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
octogonzcommented, Sep 11, 2018

Declaration merging is a more interesting case. However my opinion is that the documentation tool should somehow enforce that there is only one doc comment. Trying to merge doc comments seems complex and counterintuitive.

For example, API Extractor requires that either the property setter or the property getter should have a doc comment, but not both. The same policy would make sense for an enum with multiple declarations.

We initially took the same approach for overloaded functions, but for that special case there seems to be a general consensus that each overload should get its own doc comment. (Otherwise the @param entries can get messy.)

1reaction
octogonzcommented, Sep 11, 2018

I just realized, this is at least very closely related to #6, more probably a duplicate, but I’ll leave that choice to the maintainers.

@Gerrit0 These contributions are very helpful. I’m almost done integrating the TSDoc library into API Extractor, at which point it will be considered “feature complete”. Then I will collect all the ideas from the GitHub issues and write up a first draft of the spec document.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Comment Out Multiple Lines in Python - freeCodeCamp
The real workaround for making multi-line comments in Python is by using docstrings. If you use a docstring to comment out multiple line...
Read more >
Comments in Code - Visual Basic | Microsoft Learn
If your comment requires more than one line, use the comment symbol on each line, as the following example illustrates.
Read more >
C Language: Comments - TechOnTheNet
The compiler will assume that everything after the /* symbol is a comment until it reaches the */ symbol, even if it spans...
Read more >
Comments - CSS: Cascading Style Sheets - MDN Web Docs
Comments can be placed wherever white space is allowed within a style sheet. They can be used on a single line, or traverse...
Read more >
1.2 — Comments - Learn C++
The /* and */ pair of symbols denotes a C-style multi-line comment. Everything in between the symbols is ignored. /* This is a...
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