-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[IDEA] Add JSDoc to AST #8532
Comments
I think the right article to link to - is: https://www.puruvj.dev/blog/get-to-know-typescript--using-typescript-without-typescript It has been mentioned in: https://devclass.com/2023/05/11/typescript-is-not-worth-it-for-developing-libraries-says-svelte-author-as-team-switches-to-javascript-and-jsdoc/ I personally would love to get "autocomplete" and "type popups" if I hover a TW function in VSCode. IMO JSDOC is not too much different, to what we do have already. We will probably increase the source code size a bit, but I think the wins would be worth it. What we have atm is suboptimal. eg: Just yesterday I had to lookup the GitHub-saver code for a thread at Talk
That's nice, but how can we tell VSCode, where to find that info in If we could improve the inline documentation in a way, that VSCode Intellisense automatically recognises it, in the whole project, I would support the effort. VSCode does understand JSDoc -- and JSDoc understands commonjs - Because TW implements its own require function So IMO $tw.modules.execute(moduleName,moduleRoot) We would need to let JSDoc know, how to use this info. There is a second relation -- eg: JSDoc also has no idea about that relation, but it would need to know it to give proper info if you hover Just some thoughts. @Jermolene -- Did you ever have a closer look at JSDoc in relation with TW source code? |
Maybe sourcemap can handle this, no JSDoc/TS required. Or use https://github.com/tiddly-gittly/TW5-Typed/blob/master/src/modules/utils/index.d.ts https://github.com/tiddly-gittly/TW5-Typed/blob/master/src/core.d.ts#L164
And this will only require JSDoc, no sourcemap/TS reuqired. Currently I only care about AST node, they change frequent than other methods. Other methods in https://github.com/tiddly-gittly/TW5-Typed haven't break since they are added. I can add PR to add some type, but #8255 may cause conflict and rework. An example here #8533 |
My views are:
|
I'm with you. For those unaware of the negatives (sorry, there are many), and are unwilling to spend the hours necessary to do the full-on, deepdive analyses, grab a coffee (or six) and head here: https://medium.com/javascript-scene/the-typescript-tax-132ff4cb175b https://medium.com/javascript-scene/the-shocking-secret-about-static-types-514d39bf30a3 https://medium.com/javascript-scene/you-might-not-need-typescript-or-static-types-aa7cb670a77b |
Hi! I’m considering to add JSDoc comments to the TiddlyWiki codebase. Would this change be acceptable to the community? |
I think it would be great, if VSCode would be able to use IntellySense to show all TW function parameters as tooltips. There are some points we do have to consider: The main problem is, that the core code-size will be increased significantly, which is a problem. As you may know, the TW core code is intentionally not uglyfied. The main target audience for TW are "standard users" not developers. That's why debugging the TW core code without the need for source maps is essential. Even modifying parts of the core JS code, by interested non-developers, should be straight forward. That's not possible with uglified core code. So we would need to implement JSDocs in a way, that does not increase core code size all too much or not at all. The core size is the main driver for the tiddlywiki.html single file size. There is a proof of concept PR at: #8533 As you see in the discussion there. TW implements its own IMO @linonetwo found out how to "teach" IntellySense to connect the JSDOC pieces using We do not want to add 3rd party dependencies if it can be avoided. TW already implements a "build-step" that parses our TW js-header and converts js-code into proper tiddlers.
You can see the start of that discussion at: #8533 (review) and following posts. There is a second discussion going on, which discusses lossless "core compression", which may reduce the core size by the factor of 8 to 10. As @Jermolene mentioned in the linked PR. If we can combine those 2 steps it should be doable. The core would be compressed by the TW build-step and uncompressed at wiki startup. |
Here is the discussion about core compression |
I’ve read through the discussion and think I understand the main points, but I’d like to clarify a few things:
Thank you for your time and insights! |
You are right JSDoc is not needed for the TW development at the moment.
I would consider a user that is comfortable with using or figuring out what:
Yes and no, with a tendency to: We try to avoid dependencies if possible. Most 3rp party tools include nested dependencies that need constant maintenance. IMO The advantage that a new dependency brings will need to outweigh the disadvantages by at least a 100 to 1. Simply speaking "we can not afford it" For me personally especially nested dependencies include a horrendously huge attack surface for "supply chain attacks", which will be the No.1 thread in the future.
For the default usage of the tiddlywiki.html single page app. If you download empty.html you will see, that it is about 2.6MByte in file size. While that is half the size than most images taken with a modern mobile phone, it still is a significant size. Especially if wikis have to be loaded, if bandwidth is expensive or limited. In contrast TWclassic empty.html is about 400kByte. If we could be close to that, it would be a huge win. (BTW TWc is built using the TW5 build chain)
Mainly for the single page HTML. A smaller default bandwidth footprint using node-js client-server configuration would be a welcome side effect.
I think this issue already is about JSDoc. I think you can post your arguments here. Converting this issue into a discussion is still possible in the future. |
Yes JSDoc is not needed, but it improve dev-experience, isn't it? Improve code readability, code understandability?
So, can we add a lot of JSDoc comments to the source code without any issues if we implement compression for a single-page HTML file? |
From my point of view -- yes, iff JSDoc is human created or human redacted and optimized. As linonetwo mentioned at the POC PR, the JSDoc is created with an LLM. The quality is so bad, that "no jsdocs" would be better. See my comment: #8533 (comment) and #8533 (comment) The concept that @linonetwo introduced with the POC PR, seems to be high quality. |
If done right. -- "dev-experience" with VSCode -- definitely yes. Code readability -- not really. The syntax needed by the JSDoc parser is distracting and adds mental complexity. Code understandability -- Once devs know how to "decode" the JSDoc syntax in their head -- yes, if it is placed outside the code itself. Mixing code and JSDocs is distracting. ATM The main advantage of JSDoc comments is the possibility to use "automatic" processing of type definitions and make them usable. Automatically create more advanced dev-docs in the future may be a second step. Exporting JSDoc developer documentation and importing it into https://tiddlywiki.com/dev would be great. |
@rougsig For now you can try PR to my branch, like updating jsdoc to make them high quality. Current TODO is move typescript to build time, so there will be .d.ts file in npm tiddlywiki package, for plugin developers to use, and core developers can optionally not installing typescript. But I'm writing my games, and we have https://github.com/tiddly-gittly/TW5-Typed as "temporary" workaround, so I don't feel this is urgent for myself. |
@linonetwo Okay got it. I will focus on better UX for editor and theme. Actually i can't understand why we can't do something like obsidian real time inline markup render. Working here https://github.com/rougsig/TiddlyWikiX |
@rougsig You can search on CPL, you may find https://github.com/tiddly-gittly/slate-write . But it relys on #8258 which also needs attention. |
Is your feature request related to a problem? Please describe.
To build WYSIWYG editor, I need to maintain https://github.com/tiddly-gittly/wikiast , but it's dev experience is so bad that I don't want to touch it for a while.
Describe the solution you'd like
At least move AST part of typing from https://github.com/tiddly-gittly/TW5-Typed to the tw core, using JSDoc like how svelte does ( https://news.ycombinator.com/item?id=35932617 )
Example:
https://github.com/sveltejs/svelte/blob/1681b218cf3b42757f7d0f0a7c0dc45a79fea6f0/packages/svelte/src/store/shared/index.js#L7-L10
Describe alternatives you've considered
Directly use .d.ts may be better, but inline typing will make sure people update it.
Currently AST type in TW5-Typed is broken, the wikiast's code is in a mess. My time on opensource is liminted, so I need auto type checker to help GPT4 to help me. (GPT works better with type check output)
Additional context
I've heard that tw core maintainers don't like TS even JSDoc, but the fact is plugin developer need it, I need it, so please consider providing a better experience here. (Obsidian provides TS SDK and plugin template even it is close-sourced. Many people misunderstood Obsidian is opensourced because of its opensource plugin community. Consider how it attract modern web developers to contribute so much plugins)
The text was updated successfully, but these errors were encountered: