-
Notifications
You must be signed in to change notification settings - Fork 134
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
VS Code extension for TSDoc #198
Comments
Something like this: /**
* Describes a JavaScript object that specifies the configuration of a square.
* @remarks
* Use this interface with the {@link Renderer.drawShape} method.
* @public
*/
interface SquareConfig {
/**
* An HTML color code such as `#00000` for black, etc.
*/
color?: string;
/**
* The width of the square, measured in pixels.
* If the width is omitted, then by default the square will be sized to fill its container.
*/
width?: number;
} @maasha Is that what you were looking for? |
That is pretty standard, but I was wondering if alternatively one could use an
This would show up nicely on hover vscode (and Atom and others) for a quick overview of the interface: |
As far as TSDoc goes, I think we would prefer to fix VS Code so that it properly displays the documentation for the interface members. Whereas if we were to add an alternative syntax that is functionally equivalent to the main syntax, this would make the standard harder to learn and harder for implementors to parse. Btw in your screenshot I don't think VS Code is actually understanding the |
Right, I did notice that vscode renders any tag the same - and that is actually what made me wonder in the first place. I can agree to stick to the "main syntax" and then we wait for vscode team to improve the interface information displayed on hover? Will they do this? |
We might start by making a TSDoc extension for VS Code (similar to the recently released plugin for ESLint). This approach would also allow us to render the docs more nicely similar to what the playground does. Before I would work on that myself, I have some higher priorities I've been wanting to wrap up, such as finishing the declaration reference parser and posting a spec that documents the TSDoc grammar in detail. |
Awesome, let me know if you need testers |
I played around with this a bit today. Making a VS Code extension is very easy to do! In about 30 mins I was able to create a simple prototype that finds the nearest TSDoc comment and generates some markdown which gets rendered as a vscode.Hover object: This was just an experiment, not a real solution. But if someone's feeling bored, making a TSDoc extension might be a pretty rewarding project. I probably don't have time to undertake it myself, but I'm happy to help out with the design and any parsing/rendering aspects. (For example, for the TSDoc->Markdown part, maybe we can extract the MarkdownEmitter.ts from API Documenter and make it into a reusable library.) CC @jsamr |
If someone wants to help push this along but doesn't want to implement it, writing up a dev plan would also be useful:
A little research to answer these questions might save a lot of time for the implementation. |
@octogonz Thanks for the elaborated presentation of these issues. Not sure I have the time to tackle this, but who knows. I would add one remark: this extension would be useful for consumers of libraries which documentation has been bundled with API extractor. But how would this extension figure out which standard is this library declaration file(s) following? it would be nice if API extractor added an unambiguous comment header to convey which documentation standard this file is complying to. |
The tsdoc.json file solves this problem. It's a source file used by build tools such as ESLint, but it could also be included with your NPM package when it is published, allowing consumers to determine whether your doc comments implement TSDoc syntax or not (and what tags are supported). API Extractor writes its own file tsdoc-metadata.json in your output folder, which looks like this: <your project>/dist/tsdoc-metadata.json // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.13.1"
}
]
} The |
I currently also do not have the time to implement this feature myself, but I think a TSDOC extension would very helpful. Just a note for when this gets implemented. I think it would be amazing if this extension would also show return type comments in the vscode.hover object. This is currently missing when using the native jsdocs support. To see what I mean, check out the GIF below, or test it yourself using this example repository. For JSDOC this can be solved using this solution, but I think it would be nice if the TSDoc extension could automatically do this based on the return type interface. |
e.g.
The text was updated successfully, but these errors were encountered: