Skip to content

Programmatic API

Tom Raviv edited this page May 1, 2022 · 2 revisions

Main API

The API that used in most cases by itself. The main entry point being new Stylable() with stylable.analyze() and stylable.transform(), and may include higher level API containers in the future, for example: StylableLanguageService, StylableEditor, etc.

Low-level API

APIs that are not required for the normal transform flow offered by new Stylable(), like introspection & editing APIs, are exposed from @stylable/core. This is similar to the way Stylable exposes this type of API today, but is improved by setting formal naming conventions in order to help DX:

feature level APIs "[action] [feature] [context]":

  • parse - parseModuleImportStatement
  • validate - validateCustomPropertyName
  • ensure - ensureModuleImport
  • remove - removeModuleImport
  • get - getMixinSymbols / getModuleDependencies

high level APIs "[action] [context]":

  • parse - parseStylesheet
  • transform - transformSelector / transformAST / transformSelector

Contextual API sugar

Some APIs are commonly used and might be cumbersome or complex so a simpler alternative is exposed on Stylable / StylableMeta instances:

  • stylable.getDependencies(meta)
  • stylable.transform
Clone this wiki locally