A web tool to explore the ASTs generated by various parsers.
This is the release that breaks with Parse. From now on, all URLs, i.e. also the old URLs (/#/abcdef/3
) are served via the astexplorer express app (665bfc410544a0830a1630b20b88899a5f0cfe70 and beb4cc0a15e330300c2fe07ebb30de50ff3ba71b).
Thank you @ParsePlatform for getting astexplorer off the ground!
It's been a long time coming, but now it's here: astexplorer moved to Gists as storage backend!
Because Parse is shutting down, we had to find another solution for storing snippets. Using Gists as a backend has a couple of advantages, for example that is has a revision system built-in.
When you are storing a snippet, a new secret gist created, owned by the astexplorer user that was created for just this purpose (storing the Gist under your account is coming in the future).
A gist contains up to three files:
astexplorer.json
: A JSON file containing meta-data, such as the selected parser or parser settings.source.[js,css,html,..]
: The file that contains the code/source.transform.js
: The transformer code, if a transformer was used.These Gist snippets work pretty much the same as the Parse snippets:
Since all gists are secret, it's not possible to browse them.
There are some difference to Parse snippets as well, especially that revision are not numbered consecutively anymore. Things like these might be improved in the future. Please give us feedback so we can make gist integration in astexplorer a good experience.
In order to provide this service, astexplorer.net is now running on its own server (not GitHub anymore). That also gives us much more opportunities for future expansions.
Existing snippets and URL will continue to work but you won't be able to save changes to the them. You can fork them though, which will create a new gist.
There have been many other noteworthy changes:
New menu item: "Save" and "Fork" have been moved into a dropdown menu, "Snippet". That menu also provides two new entries "New" and "Share". "New" will reset the code and transforms to the default code examples. "Share" will show a dialog with copyable URLs to the loaded snippet.
A small "Save" or "Fork" button is available next to the "Snippet" menu header as a shortcut.
URLs for accessing latest snippet version: /<snippetid>/latest
instead of /<snippetid>/<revisionid>
now allows you to link to the latest revision of a snippet. This will be even more useful later when you can store gists on your GitHub account that only you can edit.
Parser settings are stored in snippets: This should make sharing snippets better because it ensures that the other person uses the same configuration.
Last used transform is loaded on visit: Just as the last used parser is automatically selected, the last used transform is now selected as well.
Restoring previously entered code: If you entered code and didn't save, coming back to the site will now restore the code from local storage.
More parsers: @skratchdot, @mohsen1 and @Turbo87 have been adding parsers for sqlite, YAML and handlebars.
Since v0.3.21, jscodeshift also supports babylon
(v6) and flow
as parsers. astexplorer was updated to respect the parser
export in the transform. I.e. you can now add
export const parser = 'flow';
to the transform and jscodeshift will use that parser: http://astexplorer.net/#/uIl3Ja2nAO
Babylon and flow have been added as additional parser options to recast
.
Note: If you change the parser in the transformer, you should also select the corresponding parser in the recast settings to properly reflect the AST:
Open preferences: Select parser:
I also added a simple implementation for the stats
API method. When used, it will log the collected values to the console: http://astexplorer.net/#/u2ALD6fmMy (open the browser console):
A probably lesser known feature is that the just opened node in the tree view is available in the console (global scope) via $node
. The tree view know shows a = $node
after the name to indicate that.
Fixed saving transforms.
parent
property of Traceur nodes.We now have rudimentary support for code completion for the following APIs, thanks to Tern.
j.Literal
)j.literal
)NodePath
methods (recast)Commands:
The API definition file is partially auto-generated. The manual part of it (which defines the methods for recast, ast-types and jscodeshift's core API) is still missing some descriptions and methods, if anybody wants to help out :)
The integration with Tern is a bit hacky, but in the long run I hope we can provide similar support for other transformers.