-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Request for suggestions: LiquidDoc #1852
Comments
I really like this idea but the syntax feels brittle—if that’s a thing. Would something like this work?
|
wow... really agree with that!!! many of devs are coming from js freontend frameworks, where they use props... |
+1 for Galen syntax, feels more like TypeScript than JSDoc |
lol |
I believe LiquidDocs should stick to comments instead of a separate
|
Correct. |
I had the same first thoughts as @kinngh and agree with him. Existing comment tag + letting the dev tools handle this instead of needing of modifying liquid. |
@panoply — Definitely thanks and credit where it's due, both in putting this on my radar, and in building the experience you did in the Liquify extension! Huge fan of what you've done there. These ideas are definitely not new, and something the team has been thinking about for a long time: Shopify/theme-tools#114 — and as you'll see with the syntax and differences from the convention in Dawn, we've decided to align with JSDoc so you can keep the same muscle memory everywhere. Very much borrowing from the prior art we've seen elsewhere, but a good note for us in the future to keep acknowledgements in our RFCs. I will say I did really like you calling it "LiquidDoc" and I specifically wanted to make that the official name after we talked about aligning the syntax with JSDoc. Thank you & Aurélien for that nudge! @kinngh — we originally were thinking about the So while there are some short term tradeoffs here in having to learn a new tag, we feel pretty confident in the long term benefits we can create. Definitely appreciate highlighting those points though — will take it all into consideration. |
@galenking can you say more about what feels brittle? The syntax we're proposing is meant to match JSDoc: https://jsdoc.app/ Providing explicit tags and symbols allows us to more predictably/reliably show the right thing with Intellisense — and keeping the same notation as JSDoc means devs can use one syntax everywhere, and tools like Copilot should do a better job of figuring out what to do. There's also the opportunity for our own extension to automatically suggest these docs, and help you keep them in sync with your markup. |
Indeed, it's nice to see things get ironed out. Crazy how in August we began to discuss that logic panoply/vscode-liquid#166 and then in September you legends were on the same path Shopify/theme-tools#114. Super excited to see what you come out on and how it was spec'd. |
@benjaminsehl, good question. I guess to me it feels like it’s based more around a convention than an explicit structure and it might be hard to learn and remember the syntax—or convention—and it would be easy to be sloppy and inconsistent. If the contents of this doc tag are going to be rendered in tooltips or inline docs, it feels like it needs to be more explicit to avoid inadvertent sloppiness. But, honestly, I don’t have experience with JSDoc so perhaps what’s being proposed makes good sense and has precedent 🤷♂ |
I like this approach and generally have been using the same approach as Dawn. The one thing I have noticed is it's often easy for those comment tags to get outdated if changes are made to a snippet without updating the comment. |
Have to agree here. A mirror of JSDoc is completely useless when it is not maintained. I am not saying this is not a worthwhile implementation but it will realistically provide zero benefit to the average developer. An alternate tag such as @galenking’s suggestion could provide benefits beyond just props. E.g) When spec tag is used lock the spec/defined props, skip resolving globals, etc—an alternate tag opens the door for more Intelligent caching and rendering. If you must then add it to the language server. I don’t see how this belongs in the Liquid implementation. |
I'm a huge fan of this. since liquid doesn't typically just error out on missing values I can't count how many times I've had to double check required params. comments work fine if you can enforce them, but as mentioned, there is slippage and there's no feedback from comments in the point where you're using the snippet if a type system is going to be introduced, tbh, I would prefer it to be strict. personally I would rather get an error in my console that says "hey dummy you forgot a required property". maybe a lint process would be fine but the most common mistakes that make it to production are minor changes in one file by someone less familiar with the code base, that then have unexpected impacts on some seemingly unrelated functionality |
What if we paired the intellisense with the following behaviour?
e.g. {% doc %}
Do some stuff
@param unused - this param will be yellow squiggly lined
{% enddoc %}
{% # using the missing variable that isn't a global %}
{{ missing }} After accepting linting suggestions (can't be autofixed because we can't be sure of your intentions) {% doc %}
Do some stuff
@param missing - TODO
{% enddoc %}
{% # using the missing variable that isn't a global %}
{{ missing }} |
@charlespwd Those are nice enhancements for intellisense/themecheck/language server and could encourage others to keep the tag/docs current. At worst, it would allow for more tooling to be built to detect and prevent those breaking changes. Will Intellisense be supported for the online theme editor? Historically, I see the 'quick fixes' or changes happening there that lead to snippet tag/docs being out of date or, worse, usage of a snippet being broken in another area. |
+1 on @0x15f 's suggestion - a lot of quick fixes happen directly on Shopify's Editor and if we don't have pretty/linting support, it all becomes a mess again^T |
Author: Shopify
Expected end date: December 5, 2024
Background
Snippets are the primary method for reusing logic in Liquid. However, their weak interfaces make it easy to overlook dependencies when rendering them.
Is
render
missing some dependency?It shouldn't be hard to answer this question. Projects such as Dawn have adopted headers as a convention to define such interfaces. This makes it easier to render snippets, as all dependencies are clearly listed, and there is no need to review the entire snippet to check if we're missing a dependency.
While that convention is very helpful, it relies heavily on manual work to keep the list of dependencies updated and to manually check them when rendering.
Proposal
We should officially support these headers in Liquid as documentation, similar to how JSDoc works. This way, tools such as the Liquid language server can support features around these definitions, such as:
{% render "icon", █
){% doc %}
tag with the proper type inference (thus, for a@param {string} foo
,{{ foo |█ }}
displays filters for string objects){% render ... %}
is missing parameters@param
) in the{% doc %}
tag (auto-fix means: add missing parameters and remove unused ones){% render ... %}
snippetsThe
doc
tag behaves just like thecomment
tag but has a special name to be handled differently by Liquid tooling.Call for suggestions
We welcome any feedback or opinions on this proposal. Please share your thoughts by December 5, 2024. Your input is valuable as we prepare to begin active development on this initiative.
Context
The text was updated successfully, but these errors were encountered: