-
Notifications
You must be signed in to change notification settings - Fork 22
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
Infer section schema types via LiquidDoc #166
Comments
Following this up from discord because when I begin writing the capability, discord is a huge pain to find historical conversations. Maybe @muchisx has a point here: Given the novice appealing nature of Liquid and the general development level of folks, I don't know how many people are comfortable or even aware of Type annotations, which begs to ask the question whether dot Personally, I am far more inclined to achieve and using TypeScript inspired syntax, as per @davidwarrington initial approaches: If we take into consideration projects like jsdocs and sassdoc both of these use overlapping syntaxes or ones which correlate to some degree. I think @davidwarrington was on target with moving to an Anyway, moving on and getting to the approach we should take.
Example of file-specific targetingThe
Example of Object property specific targetingThe
ExamplesBased on chats we have been having in discord, I think it boils down to these 2 (as a starting point). Of course, I am very much open to ideas/thoughts. Option 1Below we use {% comment %}
@accepts
- bar: Section<'filename'>
- qux: Section<'filename', 'setting-name'>
- foo: Section.Blocks<'filename', 'type-name'>
- baz: Product.variants
{% endcomment %} Option 2 (Sections)Below is based on @muchisx suggestion here, which feels a tad extraneous tbh, but maybe easier for folks to apply? {% comment %}
@accepts
- bar: Section<'filename'>
- qux: Section<'filename', 'setting.name'>
- foo: Section <'filename', ['blocks']['type']['type-name']>
- baz: Product.variants
{% endcomment %} |
how about a combination of both?
This would be assuming that the It's arbitrary, since both objects have other properties that could be used for filtering but these are usually the ones used by Liquid devs. When you render a section within liquid you use the So it should be intuitive for developers even if arbitrary? |
Making some action on this one. We will adopt the {% comment %}
@accepts
- bar: Section<'filename'>
- qux: Section<'filename', 'setting-name'>
- foo: Section.Blocks<'filename', 'type-name'>
- baz: Product.variants
{% endcomment %} Completions will only be made available for folks who adopt the I'll need to write up a specific guide and ruleset, hoping someone can help with that. |
This will come in v4.1 - You can track the progress in #186 - Will update as it progresses. |
As per our chat on Discord it would be really nice if in LiquidDoc we had access to a global type that can infer schemas from other sections.
For example this would infer the type from the
sections/collection-filters.liquid
schema rather than the author having to create a custom type themselves (when that's eventually possible).It would also be safer if the schema changes as the type will automatically reflect it.
The syntax is borrowed from TypeScript as that's what I'm familiar with.
The text was updated successfully, but these errors were encountered: