-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
'@' in @example code block tries to render a custom tag #1521
Comments
Pinging this. Is there a workaround for this if this is not a valid use-case? |
I've rectified this in a crude way; feel free to expand on it if you'd like.
Inside docletSrc
+ // replace the following @ symbol groups with escaped @ symbols to
+ // avoid breaking markdown triple-tick code blocks; as JSdoc will
+ // think it's a doclet tag and try to create a tag object.
+ .replace(/(@:)/g, '@:') // @:
+ .replace(/(@import)/g, '@import') // @import
+ .replace(/(@keyup)/g, '@keyup') // @keyup
+ .replace(/(@click)/g, '@click') // @click
+
.replace(/^(\s*)@(\S)/gm, '$1\\@$2') This requires me to add additional |
any update on this yet? it's relatively difficult to document TypeScript decorators without a way to escape '@' character in example code block. |
TypeScript also has this issue. I believe that we should find a solution that is compatible with both. TypeScript and JSDoc already have some differences, but I believe we should minimize these as much as possible and coordinate on the best solutions to be as compatible as possible. |
More specifically, I don't think we need to handle F.e. using |
I was able to escape the @ sign by preceding it with a zero width joiner character. It's a bit of a hack. I'm not sure if it will cause issues down the road either. char: code: /**
* @description handles the setup and teardown of connection for google cloud pubsub
* @example
*
* ```
* @Connect() // TODO: remove zero width joiner char once jsdocs accommodates
* connect(): ClientConfig {
* const projectId = this.configService.get('SOME_PROJECT_ID')
* const credentials = this.configService.get('SOME_CREDENTIALS')
* return { projectId, credentials }
* }
* ```
* @returns void
*/ result: |
+1 This will solve other issues like gajus/eslint-plugin-jsdoc#710 as well. The zero-width unicode character workarounds in this thread and others are not viable for examples that are meant as boilerplate, as the copied text will include the character and result in runtime errors like: |
Hey found this now and my usecase is lit html examples with eventlisteners like
what i see the \ escaping is not used, is there any other workaround for now? |
When documenting code with an '@' symbol in the
@example
block, jsdoc thinks the '@' is a tag and breaks the rendering of the example codeInput code
JSDoc configuration
No configuration, also tried with the markdown plugin enabled, same thing happens.
JSDoc debug output
Expected behavior
Either provide a way to escape an '@' sign with a backslash, or have jsdoc ignore any content in triple ticks so that the '@' character does not trigger a tag.
Current behavior
jsdoc reads any '@' symbol as a tag even if it is within a code example.
Your environment
The text was updated successfully, but these errors were encountered: