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

Add named schemas for missing built in types #18

Merged
merged 17 commits into from
Jun 7, 2024

Conversation

jamesrswift
Copy link
Member

@jamesrswift jamesrswift commented Jun 2, 2024

Added the following missing common types:

  • Gradient
  • Schema
  • Version
  • bytes
  • function
  • location
  • plugin
  • regex
  • selector
  • label
  • alignment
  • angle
  • direction
  • fraction
  • length
  • ratio
  • relative
  • symbol

Prior to merge, ensure that:

  • Docs are up to date
  • All newly added types have sufficient coverage in tests

@jamesrswift jamesrswift linked an issue Jun 2, 2024 that may be closed by this pull request
Copy link
Member

@tingerrr tingerrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense overall, I've attached a list of types that I compiled when I scraped the Typst docs manually.

tests/types/gradient/test.typ Outdated Show resolved Hide resolved
src/types.typ Outdated Show resolved Hide resolved
tests/types/stroke/test.typ Outdated Show resolved Hide resolved
tests/types/version/test.typ Outdated Show resolved Hide resolved
@jamesrswift jamesrswift changed the base branch from main to next June 2, 2024 16:17
Base automatically changed from next to main June 2, 2024 19:19
@jamesrswift jamesrswift marked this pull request as ready for review June 3, 2024 12:00
Copy link
Member

@tingerrr tingerrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think we can add most of them as they are.

But I think we should (in another PR) add some coercions for some of those types, like stroke.

Some of them may also need default post-transformations.

Comment on lines +29 to +32
#let relative = base-type.with(
name: "relative",
types: (relative, ratio, length),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned about this one, length and ratio will not have the same methods as relative for example, z.parse would return whatever type is passed without converting it to a relative.

This can be problematic, as shown here.

Should we be less permissive about the types or add a default post-transformation?

@jamesrswift jamesrswift merged commit c630cfc into main Jun 7, 2024
@tingerrr tingerrr deleted the 13-add-named-schemas-for-missing-built-in-types branch June 10, 2024 15:26
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

Successfully merging this pull request may close these issues.

Add named schemas for missing built-in types
2 participants