Skip to content
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

Using the protocol for other languages (in particular python) #61

Open
Nova38 opened this issue Dec 24, 2024 · 2 comments
Open

Using the protocol for other languages (in particular python) #61

Nova38 opened this issue Dec 24, 2024 · 2 comments

Comments

@Nova38
Copy link

Nova38 commented Dec 24, 2024

I find twoslash enabled doc to be really helpful when reading typescript projects that use them in their docs. I have been working on a few personal projects that use shiki for syntax highlighting some python files. I saw that there was a twoslash protocol that was created (#17 (comment)) to allow for things other than the typescript language server to generate the info that twoslash needs to render it. I was wondering what the steps would be to get the data generated into twoslash for rendering in to shiki?

Also if i wanted to include the docstrings for the nodes would I need to convert them into the jsdoc equivalents or what format do the strings of the types bellow need to be?

export interface NodeHover extends NodeBase {
type: 'hover'
/** The string content of the node this represents (mainly for debugging) */
target: string
/** The base LSP response (the type) */
text: string
/** Attached JSDoc info */
docs?: string
/** JSDoc tags */
tags?: [name: string, text: string | undefined][]
}

@antfu
Copy link
Member

antfu commented Dec 24, 2024

How much is the difference between Python's doc strings and jsodc? You do not have to convert them into jsdocs, it's just a data field and it's up to the renderer to parse the string to DOM. So it's possible that you provide your own patched renderer or so to render directly with docstring.

@Nova38
Copy link
Author

Nova38 commented Dec 24, 2024

Python has several different docstring standards so it is a little less unified. However their plugins for sphinx that complice them into structured data that is more standardized that I could pass to a patched renderer like you suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants