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
Adding examples (@example) to the documentation #135
Comments
Hi Édes, nice to hear from you. TypeDoc currently has no explicit support for the The "official" JSDoc implementation supports the |
Thanks for the quick response, Sebastian! I think, it would be a very nice extension of the existing functionality, if |
Just found this issue as I tried the same combination, expecting @example and code snippets to work together. Instead I just get a tag on top of my snippet, pushing my code. |
+1 need too:) |
I have tried triple markdown but the whitespace seems to get stripped? Some help on inserting code blocks would be greatly appreciated |
I tried markdown syntax and it appears to work just fine. In my mind this issue isn't that critical. However, it might be nice to see the example tag show up above the examples that are included in the docs. |
Fenced code blocks do seems to have whitespace stripped. ( per comment above). This does make it difficult to include multiline examples in the docs. |
Update: I was able to preserve whitespaces/indentation. One needs to start the example with stars (*). /**
* . . .
* @example
* ```typescript
*
*const resourceGroupName = 'res9101';
*const accountName = 'sto4445';
*const parameters: StorageManagementModels.StorageAccountCreateParameters = {
* sku: {
* name: <StorageManagementModels.SkuName>'Standard_GRS'
* },
* kind: <StorageManagementModels.Kind>'Storage',
* location: 'eastus2euap',
* tags: {
* "key1": "value1",
* "key2": "value2"
* }
* };
*const storageAccount = await client.storageAccounts.create(resourceGroupName, accountName, parameters);
* ```
* @param {string} resourceGroupName The name of the resource group within the
* user's subscription. The name is case insensitive.
* . . .
*/ As you can see the indentation is preserved in the example. |
With TypeDoc 0.23 (currently sitting on the beta branch, no release yet since I broke lots of things...), TypeDoc is much smarter about parsing comments, it will correctly handle indentation in code blocks, even without leading Note: TypeDoc and JSDoc disagree about what an |
Thanks for the really great documentation tool!
I was wondering, if there is any way to add examples directly into the doccoment? I noticed, that adding custom tags like
@whatever
shows up in the generated documentation, and if I use the triple quote markdown syntax, I get syntax highlighting. It also looks like, that@example
is not treated as a special annotiation. But is the@example
& markdown combo the standard way of adding API examples to your source? Is there a standard way at all?The text was updated successfully, but these errors were encountered: