-
Notifications
You must be signed in to change notification settings - Fork 20
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
Default arguments support #24 #62
Open
theseanl
wants to merge
25
commits into
siefkenj:main
Choose a base branch
from
theseanl:default-arguments
base: main
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.
Open
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ee4c8e5
feat: Attach default arguments to AST
theseanl 58077cd
feat: Support default arguments for embellishments
theseanl 76d88c1
test: add macro with default argument case in CLI test, make it work on
theseanl 48c30a7
chore: remove an obsolete snapshot
theseanl c07f7b8
Merge branch 'main' into default-arguments
theseanl af91693
[WIP] fix 'until' behavior, support multi-token stop
theseanl 0c3e598
build: Switch to nodejs export conditions from TS project references
theseanl da0e74c
Merge branch 'main' into ditch-ts-project-references
theseanl b69517b
build: use _bundle export condition on esm bundle as well
theseanl 9035e2a
chore: make prettier format json
theseanl 768a308
build: set forceConsistentCasingInFileNames
theseanl 191c53c
Merge branch 'ditch-ts-project-references' into default-arguments
theseanl 2067555
feat: support multi-stop token in 'until', macro delimiters
theseanl 6cb5599
refactor: move default argument logic to expandMacros
theseanl 20976aa
feat: Support default arguments referencing other arguments
theseanl 21a1733
chore: revert early return in gobble-single-argument.ts
theseanl bd1f972
feat: default argument support for \newcommand
theseanl 7d12d13
chore: simplify codes
theseanl af5e25d
build: use import instead of _bundle
theseanl 8de3294
Merge branch 'ditch-ts-project-references' into default-arguments
theseanl d63b24e
chore: fix cli test, regenerate package lock
theseanl dcb22be
Merge branch 'main' into default-arguments
theseanl 916e10f
chore: minor change as per reviews
theseanl 38a18e2
Merge branch 'main' into default-arguments
theseanl 6b9e249
fix: optional argument without default value
theseanl 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
packages/unified-latex-cli/libs/macros/expand-document-macros-plugin.ts
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
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
48 changes: 33 additions & 15 deletions
48
packages/unified-latex-util-argspec/libs/argspec-types.ts
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 |
---|---|---|
@@ -1,42 +1,60 @@ | ||
export type Ast = Node[] | Node; | ||
export type Node = Optional | Mandatory | Verbatim | Body | Group | Until; | ||
export type Node = Optional | Mandatory | Verbatim | Body | Until; | ||
type Optional = OptionalArg | OptionalStar | OptionalToken | Embellishment; | ||
interface AstNode { | ||
|
||
// Make several optional properties available in all `AstNode`s | ||
interface AstNode | ||
extends Partial<Arg>, | ||
Partial<LeadingWhitespace>, | ||
DefaultArgument { | ||
type: string; | ||
} | ||
interface Arg extends AstNode { | ||
|
||
// Mixins | ||
interface Arg { | ||
openBrace: string; | ||
closeBrace: string; | ||
} | ||
export interface LeadingWhitespace { | ||
interface LeadingWhitespace { | ||
noLeadingWhitespace: boolean | undefined; | ||
} | ||
export interface DefaultArgument { | ||
defaultArg?: Group; | ||
interface DefaultArgument { | ||
defaultArg?: string; | ||
} | ||
interface Verbatim extends Arg { | ||
|
||
// Make `openBrace` and `closeBrace` required by extending both. | ||
// Typescript requires specifying those properties to be specified in interface body, | ||
// otherwise the compilation will error out. | ||
interface Verbatim extends AstNode, Arg { | ||
type: "verbatim"; | ||
openBrace: string; | ||
closeBrace: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very strange to me and seems to be missing the benefits of the mixins. Let's just use types for this. type Braces = {openBrace: string; closeBrace: string};
type DefaultArg = {defaultArg?: string};
type LeadingWhitespace = {leadingWhitespace: boolean};
type AstNode = Partial<Braces> & Partial<LeadingWhitespace> & DefaultArg;
type Verbatim = AstNode & Braces;
... |
||
} | ||
interface OptionalArg extends LeadingWhitespace, DefaultArgument, Arg { | ||
interface OptionalArg extends LeadingWhitespace, DefaultArgument, AstNode, Arg { | ||
type: "optional"; | ||
openBrace: string; | ||
closeBrace: string; | ||
noLeadingWhitespace: boolean | undefined; | ||
defaultArg?: string; | ||
} | ||
interface OptionalStar extends LeadingWhitespace, AstNode { | ||
type: "optionalStar"; | ||
noLeadingWhitespace: boolean | undefined; | ||
} | ||
interface OptionalToken extends LeadingWhitespace, AstNode { | ||
type: "optionalToken"; | ||
token: string; | ||
noLeadingWhitespace: boolean | undefined; | ||
} | ||
export interface Embellishment extends DefaultArgument, AstNode { | ||
export interface Embellishment extends AstNode { | ||
type: "embellishment"; | ||
embellishmentTokens: string[]; | ||
tokens: string[]; | ||
defaultArgs?: string[]; // Embellishment default arguments are always a collection of arguments | ||
} | ||
interface Mandatory extends LeadingWhitespace, DefaultArgument, Arg { | ||
interface Mandatory extends DefaultArgument, AstNode, Arg { | ||
type: "mandatory"; | ||
} | ||
export interface Group extends AstNode { | ||
type: "group"; | ||
content: (Group | string)[]; | ||
openBrace: string; | ||
closeBrace: string; | ||
} | ||
interface Body extends AstNode { | ||
type: "body"; | ||
|
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.
Why not
#${node.number}
?