ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
139 lines (111 loc) • 6.98 kB
HTML
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>ts-simple-ast - AST Viewers</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="/assets/css/style.css?v=502728dc7b09041e36b06c50f79a13adbfb6f1b2">
<!--
<link rel="stylesheet" href="/assets/css/style.css?v=502728dc7b09041e36b06c50f79a13adbfb6f1b2">
<link rel="stylesheet" href="/assets/css/custom-style.css?v=502728dc7b09041e36b06c50f79a13adbfb6f1b2">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/assets/js/main.js"></script>-->
</head>
<body>
<div class="main">
<header class="container">
<div class="row">
<h1 onclick="document.location.href = '/'" class="headerLink">ts-simple-ast</h1>
<!--<p class="subText">Simple way to navigate and manipulate the TypeScript AST.</p>-->
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-3">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<nav class="sidebar-nav" id="navbarSupportedContent">
<ul class="navbar-nav navbar-default">
<li class="nav-item">
<a class="nav-link" href="/">Overview</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/setup">Setup</a>
<ul>
<li class=""><a href="/setup/index">Instantiating</a></li>
<li class=""><a href="/setup/adding-source-files">Adding Source Files</a></li>
<li class=""><a href="/setup/diagnostics">Diagnostics</a></li>
<li class=""><a href="/setup/file-system">File System</a></li>
<li class="active"><a href="/setup/ast-viewers">AST Viewers</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/navigation">Navigation</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/manipulation">Manipulation</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/emitting">Emitting</a>
</li>
<li class="">
<a class="nav-link" href="/details/index">Details</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/utilities">Utilities</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://github.com/dsherret/ts-simple-ast">View on GitHub</a>
</li>
</ul>
</nav>
</div>
<section class="container-fluid col-md-9">
<h2 id="ast-viewers">AST Viewers</h2>
<p>An AST viewer is a useful way to help understand the TypeScript AST for some source code.</p>
<h3 id="typescript-ast-viewer">TypeScript AST Viewer</h3>
<p>I’ve created this very basic web-based TypeScript AST viewer.</p>
<p><a href="https://dsherret.github.io/ts-ast-viewer/">TypeScript AST Viewer</a></p>
<p>Features:</p>
<ul>
<li>View code on left, tree in middle, and selected node’s properties on right.</li>
<li>Select a node in the tree to focus on that node’s properties.</li>
</ul>
<p><a href="https://dsherret.github.io/ts-ast-viewer/"><img src="/setup/images/ts-ast-viewer.png" alt="TypeScript AST Viewer" /></a></p>
<p>I will improve and add more functionality to this in the future, but for now it will give you a good understanding of the tree.</p>
<h3 id="atom-typescript">Atom TypeScript</h3>
<p>This AST viewer gives an excellent view of the AST.</p>
<ol>
<li>Install <a href="https://atom.io/">Atom</a>.</li>
<li>Install <a href="https://atom.io/packages/atom-typescript">atom-typescript</a>.</li>
<li>Create a new typescript file.</li>
<li>
<p>Paste in your typescript code.</p>
<p><img src="/setup/images/atom-file.png" alt="TypeScript file" /></p>
</li>
<li>Important: Ensure the current typescript document has focus.</li>
<li>Open the command palette (Windows/Linux: <code class="highlighter-rouge">ctrl+shift+p</code>, Mac: <code class="highlighter-rouge">cmd+shift+p</code>).</li>
<li>
<p>Type <code class="highlighter-rouge">TypeScript: Ast Full</code> and hit enter.</p>
<p><img src="/setup/images/atom-command-palette.png" alt="Command Palette" /></p>
</li>
<li>
<p>A new tab will appear with the AST.</p>
<p><a href="images/atom-ast.png"><img src="/setup/images/atom-ast_small.png" alt="atom-typescript AST Viewer" /></a></p>
</li>
</ol>
<p><strong>Bug warning:</strong> There seems to be an issue with the AST viewer where you have to close the “TypeScript AST” tab before running the <code class="highlighter-rouge">TypeScript: Ast Full</code> command again.</p>
</section>
</div>
</div>
<footer>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>