MIT License

项目介绍

fkling/astexplorer 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 6.5k 个 Star、752 次 Fork。

仓库全名
fkling/astexplorer
开源许可证
MIT License
Star 数
6.5k
Fork 数
752
未关闭 Issue
115

README 摘要

AST explorer Paste or drop code into the editor and inspect the generated AST on https://astexplorer.net/ The AST explorer provides following code parsers: CSS: [cssom][] [csstree][] [postcss][] + [postcss-safe-parser][] & [postcss-scss][] [rework][] [GraphQL][] Graphviz: [redot][] Handlebars: [glimmer][] [handlebars][] [ember-template-recast][] HTML: [htmlparser2][] [parse5][] [@angular/compiler][]…

完整内容见 GitHub 原始 README 或本页 。

常见问题

astexplorer 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 6.5k 个 Star。

astexplorer 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 astexplorer 的源码?

可以直接克隆仓库:git clone https://github.com/fkling/astexplorer.git,默认分支为 master;安装与运行步骤见仓库 README。

astexplorer 最近还在维护吗?

仓库最近一次更新为 2024年4月26日,当前有 115 个未关闭 Issue;Star 数为 6.5k,可作为社区活跃度的参考。

简要分析

热度分
8101
价值分
4150
活跃状态
活跃

语言占比

CSS
EJS
HTML
JavaScript
Shell

Release

README

AST explorer

Gitpod ready-to-code Join the chat at https://gitter.im/astexplorer/Lobby Build Status

Paste or drop code into the editor and inspect the generated AST on https://astexplorer.net/

The AST explorer provides following code parsers:

Experimental / custom syntax

Depending on the parser settings, it not only supports ES5/CSS3 but also

Transforms

Since future syntax is supported, the AST explorer is a useful tool for developers who want to create AST transforms. In fact, following transformers are included so you can prototype your own plugins:

More Features

  • Save and fork code snippets. Copy the URL to share them.
  • Copying an AST or dropping a file containing an AST into the window will parse the AST and update the code using escodegen.
  • Otherwise, the content of text editor will be replaced with the content of the file (i.e. you can drag and drop JS files).
  • Choose between multiple parsers and configure them.
  • shift+click on a node expands the full subtree.
  • Hovering over a node highlights the corresponding text in the source code
  • Editing the source or moving the cursor around will automatically highlight the corresponding AST node (or its ancestors of it isn’t expanded)
  • You can use $node in the console to refer to the last opened/toggled AST node.

Contributions

I’m happy about any feedback, feature request or PR to make this tool as useful as possible!


How to add a new parser
  1. Go to website/.
  2. Install the new parser as dependency: yarn add theParser
  3. Copy one of the existing examples in src/parsers/{language}.
  4. Adjust the code as necessary:
  • Update metadata.
  • Load the right parser (loadParser).
  • Call the right parsing method with the right/necessary options in parse.
  • Implement the nodeToRange method (this is for highlighting).
  • Implement the getNodeName method (this is for quick look through the tree).
  • Implement opensByDefault method for auto-expansion of specific properties.
  • Define _ignoredProperties set or implement forEachProperty generator method for filtering.
  • Provide a renderSettings method if applicable.
How to add a new transformer
  1. Go to website/.
  2. Install the new transformer as dependency.
  3. Copy one of the existing examples in src/parsers/{language}/transformers.
  4. Adjust the code as necessary:
  • Update metadata and defaultParserID.
  • Load the right transformer (loadTransformer).
  • Call the transformation method in transform.
  • Change sample transformation code in codeExample.txt.
Build your own version for development

IMPORTANT: For various reasons the project still requires Node.js version 16 (see .tools-versions). If you use a tool like asdf switching versions will happen automatically.

  1. Clone the repository.
  2. Go to website/.
  3. Install all dependencies with yarn install

Run yarn run build for the final minimized version. Run yarn run watch for incremental builds.

Run yarn start to start a simple static webserver.

评论

暂无评论