-
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
feat: add JSDoc example #8533
Draft
linonetwo
wants to merge
19
commits into
TiddlyWiki:master
Choose a base branch
from
linonetwo:feat/ast-type
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: add JSDoc example #8533
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
602e5ea
feat: add example
linonetwo 270aeba
chore: add ts file so tsc --noEmit works
linonetwo 492d812
refactor: remove // @ts-check
linonetwo ac308e0
feat: Allow `import('$:/core/modules/...')` instead of `import('../..…
linonetwo b6f219a
feat: make $tw.wiki globally available
linonetwo a5feb38
feat: add an example jsdoc to $tw.wiki.getTiddlerText
linonetwo c5304b4
fix: Declaration emit for this file requires using private name 'Widg…
linonetwo 43eff4e
fix: duplication of types
linonetwo cdceedd
docs: shorten JSDoc comment as requsted
linonetwo 8f0d37e
refactor: move some type to base class
linonetwo 24279cc
feat: allow type in /generated to work
linonetwo e3fc9b4
feat: import base type
linonetwo 18517b6
refactor: generate types to /types/core instead for simplicity
linonetwo c56afea
feat: add ast type that wikiast is using
linonetwo 06204b1
feat: refine the ast type
linonetwo 0c92f1b
Update tw.d.ts
linonetwo 562a308
fix: ignore base file
linonetwo 3cc1849
Update wiki.js
linonetwo 2eaadcd
Update npm-publish.sh
linonetwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ node_modules/ | |
/playwright-report/ | ||
/playwright/.cache/ | ||
$__StoryList.tid | ||
types/core/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,8 @@ | |
|
||
./bin/clean.sh | ||
|
||
# Build typings | ||
npm i typescript | ||
npx tsc | ||
|
||
npm publish || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Represents an attribute in a parse tree node | ||
* | ||
* @typedef {Object} ParseTreeAttribute | ||
* @property {number} [end] - End position of attribute in source text | ||
* @property {string} [name] - Name of attribute | ||
* @property {number} [start] - Start position of attribute in source text | ||
* @property {'string' | 'number' | 'bigint' | 'boolean' | 'macro' | 'macro-parameter'} type - Type of attribute | ||
* @property {string | IMacroCallParseTreeNode} value - Actual value of attribute | ||
*/ | ||
|
||
/** | ||
* Base structure for a parse node | ||
* | ||
* @typedef {Object} ParseTreeNode | ||
* @property {string} type - Type of widget that will render this node | ||
* @property {string} rule - Parse rule that generated this node. One rule can generate multiple types of nodes | ||
* @property {number} start - Rule start marker in source text | ||
* @property {number} end - Rule end marker in source text | ||
* @property {Record<string,ParseTreeAttribute>} [attributes] - Attributes of widget | ||
* @property {ParseTreeNode[]} [children] - Array of child parse nodes | ||
*/ | ||
|
||
/** | ||
* Base class for parsers. This only provides typing | ||
* | ||
* @class | ||
* @param {string} type - Content type of text to be parsed | ||
* @param {string} text - Text to be parsed | ||
* @param {Object} options - Parser options | ||
* @param {boolean} [options.parseAsInline=false] - If true, text will be parsed as an inline run | ||
* @param {Object} options.wiki - Reference to wiki store in use | ||
* @param {string} [options._canonical_uri] - Optional URI of content if text is missing or empty | ||
* @param {boolean} [options.configTrimWhiteSpace=false] - If true, parser trims white space | ||
*/ | ||
function Parser(type, text, options) { | ||
/** | ||
* Result AST | ||
* @type {ParseTreeNode[]} | ||
*/ | ||
this.tree = []; | ||
|
||
/** | ||
* Original text without modifications | ||
* @type {string} | ||
*/ | ||
this.source = text; | ||
|
||
/** | ||
* Source content type in MIME format | ||
* @type {string} | ||
*/ | ||
this.type = type; | ||
} | ||
|
||
exports.Parser = Parser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO having
@property {string} type
and then- The type of the widget, which is "codeblock".
is the same thing. Both elements describe: "What it is". -- I think the second part should describe: "What it does", otherwise we can skip it.eg:
Should be as short as possible and still valid. Especially see
type, rule, start, end
which are properties of "CodeblockNode"I did remove the "full stops" from all
@
elements. They are not neededThe first intro sentence has a full stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'd copy that.
I have to admit, all jsdoc are generated by github copilot. I don't have time for this detail, I will leave it for future refinement. I'm still debugging the type when I'm using it in my plugin project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new type information will significantly increase the TW code-size. So if there is redundant information it should be removed.
And even more important it has to be valid. So if the co-pilot only adds comments in a more verbose form than the parameters are. There should not be any comments at all -- They have no value.
So if there are no comments, we actually know, that we have to add them manually. IMO for the tooltips it would be OK to start with the type info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we must remove comments before publishing HTML wiki. I think these JSDoc will basically double the size.
This won't be a big problem, because 1. I use the method body as input too. And 2. we can auto merge "comment" type of PR based on #7542 , so people can update comment quickly. I find this is quite frequent when maintaining https://github.com/tiddly-gittly/TW5-Typed