-
Notifications
You must be signed in to change notification settings - Fork 1
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
Less Public API Proposal - Next version #31
Comments
Initial list of tree nodes to be be supported as function return values:
I don't think DetachedRulesets or variable calls should be on the Public API until those syntaxes are unified with mixins in the future. Anything else seem necessary? |
I'm wondering if rather than a 'public' and 'private' API a 'high-level' API and a 'low-level' API should be considered. Might make it easier to work on plugin functions while the high-level API is not yet complete; is lagging behind in completeness of new features; or to cover cases where the high-level API simply cannot cope. |
Can you clarify with an example? |
It's simple really: Rather than making everything under For instance: the While there aren't very many reasons to have those, there are a few valid ones. |
Maybe what I said was confusing. Long and short: I wasn't suggesting making it private. I guess I'm looking at this from the perspective of documentation. Right now we have no publicly documented API. When documented, the Less nodes can look pretty hairy. And yes, they're subject to change. |
I guess the other thing I'd say is that the Less nodes have arguments that are really strictly for the parser "marking" them in a certain way for evaluation. They're just not designed to be public facing. Also, for legacy reasons, some nodes have parser index and fileInfo passed to them as the last 2 arguments, but some don't. |
Then don't name them like that either, I'd say. Hence the suggestion to name them high-level / low-level. Thinking some more about it; maybe something like public / semi-internal is better. It atleast gives off a strong signal that their should be some expectations of future breakages and that things are -- :: ahem :: -- "subject to change" ^_^ |
Ha, fair. I really just meant in terms of public visibility, not
|
I was reading in on less plugins at the official docs and found this note:
Where |
I wouldn't call it active development as I haven't had time to iterate on it. In general, the "public" API has the same signature as the "internal" one. For the most part, any JavaScript function called from less should be returning one of these nodes: https://github.com/less/less.js/tree/master/lib/less/tree Mostly, these will be basic value nodes, like anonymous, dimension, or color values, unless your plugin is doing something more complex. |
Per discussion in #15, I created some helpers within nodes in 3.0 to cast strings in various cases to Nodes, but I think that should be changed moving forward for a public API.
That is:
In addition, there are many cases where the Less tree nodes are just not relevant for a public API. So, what I'm hoping is we can:
less
object namespace to just what is "public" i.e. won't change (although existing properties/methods can exist in the prototype chain for back-compat)tree.Declaration
type returns from functions.As an example of the Public API being different from the Less internal node structure, a
less.tree
implementation currently looks like:A public API would be something like:
One reason this is necessary: occasionally new features / parsing changes do require changes in the function arguments for less tree nodes. A Public API could however be more stable.
I would propose these are the main properties of a public API:
parse
render
visitors
Any others? Thoughts? If you agree, what are the internal nodes that should be exposed as a public API?
The text was updated successfully, but these errors were encountered: