Skip to content

Commit e14d04f

Browse files
committed
v0.3.1
1 parent 72fd9e4 commit e14d04f

18 files changed

Lines changed: 1585 additions & 415 deletions

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.3.1 - alpha - ????-??-??
1+
## 0.3.1 - alpha - 2026-03-13
22

33
### Added
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**High-level Python AST manipulation that preserves formatting**
44

5-
[![PyPI version](https://img.shields.io/badge/pypi-0.3.0-orange.svg)](https://pypi.org/project/pfst/)
5+
[![PyPI version](https://img.shields.io/badge/pypi-0.3.1-orange.svg)](https://pypi.org/project/pfst/)
66
[![Python versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14%20%7C%203.15a-blue.svg)](https://www.python.org/)
77
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
88

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1.dev202603121952
1+
0.3.1

docs/fst.html

Lines changed: 129 additions & 14 deletions
Large diffs are not rendered by default.

docs/fst/common.html

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ <h2>API Documentation</h2>
3131
<li>
3232
<a class="class" href="#NodeError">NodeError</a>
3333
<ul class="memberlist">
34-
<li>
35-
<a class="variable" href="#NodeError.rawable">rawable</a>
36-
</li>
3734
</ul>
3835

3936
</li>
@@ -149,17 +146,6 @@ <h1 class="modulename">
149146
</div>
150147

151148

152-
<div id="NodeError.rawable" class="classattr">
153-
<div class="attr variable">
154-
<span class="name">rawable</span><span class="annotation">: bool</span>
155-
156-
157-
</div>
158-
<a class="headerlink" href="#NodeError.rawable"></a>
159-
160-
161-
162-
</div>
163149
</section>
164150
<section id="astfield">
165151
<div class="attr class">

docs/fst/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h1 class="modulename">
5959

6060
<div class="docstring"><p>This is rather crude documentation that hopefully can show usage through many small examples.</p>
6161

62-
<p><code><a href="docs/d01_parse.html">fst.docs.d01_parse</a></code>: Parse and unparse from source or <code>AST</code></p>
62+
<p><code><a href="docs/d01_parse.html">fst.docs.d01_parse</a></code>: Parse and unparse from source or AST</p>
6363

6464
<p><code><a href="docs/d02_locations.html">fst.docs.d02_locations</a></code>: Node locations in the source code</p>
6565

docs/fst/docs/d01_parse.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<h2>Contents</h2>
2828
<ul>
29-
<li><a href="#parse-and-unparse-from-source-or-ast">Parse and unparse from source or <code>AST</code></a>
29+
<li><a href="#parse-and-unparse-from-source-or-ast">Parse and unparse from source or AST</a>
3030
<ul>
3131
<li><a href="#parse">Parse</a></li>
3232
<li><a href="#basic-structure">Basic structure</a></li>
@@ -36,6 +36,7 @@ <h2>Contents</h2>
3636
<li><a href="#from-fst-nodes">From <code>FST</code> nodes</a></li>
3737
<li><a href="#underlying-functions">Underlying functions</a></li>
3838
<li><a href="#source">Source</a></li>
39+
<li><a href="#parse_ast"><code>parse_ast()</code></a></li>
3940
</ul></li>
4041
</ul>
4142

@@ -55,7 +56,7 @@ <h2>Contents</h2>
5556
<h1 class="modulename">
5657
<a href="./../../fst.html">fst</a><wbr>.<a href="./../docs.html">docs</a><wbr>.d01_parse </h1>
5758

58-
<div class="docstring"><h1 id="parse-and-unparse-from-source-or-ast">Parse and unparse from source or <code>AST</code></h1>
59+
<div class="docstring"><h1 id="parse-and-unparse-from-source-or-ast">Parse and unparse from source or AST</h1>
5960

6061
<p>To be able to execute the examples, import this.</p>
6162

@@ -551,6 +552,33 @@ <h2 id="source">Source</h2>
551552
<span class="go"> .operand Name &#39;a&#39; Load - 4,15..4,16</span>
552553
</code></pre>
553554
</div>
555+
556+
<h2 id="parse_ast"><code>parse_ast()</code></h2>
557+
558+
<p>The <code>FST</code> class makes its internal extended <code>AST</code> parsing available via the <code>FST.parse_ast()</code> function. This allows
559+
parsing individual nodes as pure <code>AST</code> (without any <code>FST</code> nodes added) that are otherwise unparsable by themselves by
560+
the standard <code>ast</code> module.</p>
561+
562+
<div class="pdoc-code codehilite">
563+
<pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">dump</span><span class="p">(</span><span class="n">FST</span><span class="o">.</span><span class="n">parse_ast</span><span class="p">(</span><span class="s1">&#39;except Exception: pass&#39;</span><span class="p">)))</span>
564+
<span class="go">ExceptHandler(type=Name(id=&#39;Exception&#39;, ctx=Load()), body=[Pass()])</span>
565+
</code></pre>
566+
</div>
567+
568+
<div class="pdoc-code codehilite">
569+
<pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">dump</span><span class="p">(</span><span class="n">FST</span><span class="o">.</span><span class="n">parse_ast</span><span class="p">(</span><span class="s1">&#39;kw=value&#39;</span><span class="p">,</span> <span class="s1">&#39;keyword&#39;</span><span class="p">)))</span>
570+
<span class="go">keyword(arg=&#39;kw&#39;, value=Name(id=&#39;value&#39;, ctx=Load()))</span>
571+
</code></pre>
572+
</div>
573+
574+
<div class="pdoc-code codehilite">
575+
<pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">dump</span><span class="p">(</span><span class="n">FST</span><span class="o">.</span><span class="n">parse_ast</span><span class="p">(</span><span class="s1">&#39;upper:lower:step&#39;</span><span class="p">,</span> <span class="n">Slice</span><span class="p">),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">))</span>
576+
<span class="go">Slice(</span>
577+
<span class="go"> lower=Name(id=&#39;upper&#39;, ctx=Load()),</span>
578+
<span class="go"> upper=Name(id=&#39;lower&#39;, ctx=Load()),</span>
579+
<span class="go"> step=Name(id=&#39;step&#39;, ctx=Load()))</span>
580+
</code></pre>
581+
</div>
554582
</div>
555583

556584

0 commit comments

Comments
 (0)