Skip to content

Commit ab3ceae

Browse files
author
Vic-Nas
committed
Auto-generate docs and bump version to 0.25 [skip ci]
1 parent 2ec4595 commit ab3ceae

File tree

3 files changed

+51
-21
lines changed

3 files changed

+51
-21
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.24
1+
0.25

setup.py

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

77
setup(
88
name="vicutils",
9-
version="0.24",
9+
version="0.25",
1010
packages=find_packages(),
1111
install_requires=[],
1212

vicutils/printBin.html

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>
7979
<div class="desc"><p>Calculates the depth (height) of a binary tree.</p></div>
8080
</dd>
8181
<dt id="printBin.mapNodesToCodes"><code class="name flex">
82-
<span>def <span class="ident">mapNodesToCodes</span></span>(<span>node, valueFillChar, unitSize, code='', memo=None)</span>
82+
<span>def <span class="ident">mapNodesToCodes</span></span>(<span>node, valueFillChar, unitSize, code='')</span>
8383
</code></dt>
8484
<dd>
8585
<details class="source">
8686
<summary>
8787
<span>Expand source code</span>
8888
</summary>
89-
<pre><code class="python">def mapNodesToCodes(node, valueFillChar, unitSize, code=&#34;&#34;, memo=None):
89+
<pre><code class="python">def mapNodesToCodes(node, valueFillChar, unitSize, code=&#34;&#34;):
9090
&#34;&#34;&#34;
9191
Recursively maps all nodes to their binary path codes.
9292

@@ -98,12 +98,15 @@ <h2 class="section-title" id="header-functions">Functions</h2>
9898
Returns:
9999
Dictionary mapping binary codes to centered node values
100100
&#34;&#34;&#34;
101-
if memo is None:
102-
memo = {}
103-
if node:
104-
memo[code] = center(node.val, unitSize=unitSize, fillChar=valueFillChar)
105-
mapNodesToCodes(node.left, valueFillChar, unitSize, code + &#34;0&#34;, memo)
106-
mapNodesToCodes(node.right, valueFillChar, unitSize, code + &#34;1&#34;, memo)
101+
memo = {}
102+
103+
def recurse(node, code):
104+
if node:
105+
memo[code] = center(node.val, unitSize=unitSize, fillChar=valueFillChar)
106+
recurse(node.left, code + &#34;0&#34;)
107+
recurse(node.right, code + &#34;1&#34;)
108+
109+
recurse(node, code)
107110
return memo</code></pre>
108111
</details>
109112
<div class="desc"><p>Recursively maps all nodes to their binary path codes.</p>
@@ -185,10 +188,28 @@ <h2 id="returns">Returns</h2>
185188
if prevValueIndexes is not None:
186189
for i in range(0, len(prevValueIndexes), 2):
187190
if i + 1 &lt; len(prevValueIndexes):
188-
parentCol = (prevValueIndexes[i] + prevValueIndexes[i + 1]) // 2
189-
for col in range(prevValueIndexes[i] + 1, prevValueIndexes[i + 1]):
191+
leftChildCol = prevValueIndexes[i]
192+
rightChildCol = prevValueIndexes[i + 1]
193+
parentCol = (leftChildCol + rightChildCol) // 2
194+
195+
# Fill columns between children, except parent position
196+
for col in range(leftChildCol + 1, rightChildCol):
190197
if col != parentCol:
191198
mat[level][col] = center(&#34;&#34;, unitSize=unitSize, fillChar=connectorFillChar)
199+
200+
# Special handling for child positions if unitSize &gt; 1
201+
if unitSize &gt; 1 and connectors is not None:
202+
# Left child: fill chars positioned to the right of where / appears
203+
# The connector / is centered, so it appears at position unitSize // 2
204+
# We want fill chars after it
205+
leftFill = &#34; &#34; * (unitSize // 2 + 1) + connectorFillChar * (unitSize - unitSize // 2 - 1)
206+
mat[level][leftChildCol] = leftFill
207+
208+
# Right child: fill chars positioned to the left of where \ appears
209+
# The connector \ is centered, so it appears at position unitSize // 2
210+
# We want fill chars before it
211+
rightFill = connectorFillChar * (unitSize // 2) + &#34; &#34; * (unitSize - unitSize // 2)
212+
mat[level][rightChildCol] = rightFill
192213

193214
prevValueIndexes = valueIndexes
194215

@@ -243,7 +264,7 @@ <h2 id="args">Args</h2>
243264
&#34;&#34;&#34;
244265
Converts a binary tree into a string representation for visualization.
245266

246-
Args:Y
267+
Args:
247268
node: The root node of the tree to visualize
248269
depth: The depth of the tree (-1 for auto-calculation)
249270
valueFillChar: Character for padding node values (e.g., &#34;_5_&#34;)
@@ -262,14 +283,23 @@ <h2 id="args">Args</h2>
262283
return &#34;\n&#34;.join(&#34;&#34;.join(mat[i]) for i in range(0, len(mat), 2))</code></pre>
263284
</details>
264285
<div class="desc"><p>Converts a binary tree into a string representation for visualization.</p>
265-
<p>Args:Y
266-
node: The root node of the tree to visualize
267-
depth: The depth of the tree (-1 for auto-calculation)
268-
valueFillChar: Character for padding node values (e.g., "<em>5</em>")
269-
connectorFillChar: Character for filling horizontal gaps between node pairs
270-
unitSize: Size for centering values
271-
removeEmpty: Whether to remove empty leading columns
272-
connectors: Two-character string for connectors (e.g., "/" or "||"), None to skip connector rows</p></div>
286+
<h2 id="args">Args</h2>
287+
<dl>
288+
<dt><strong><code>node</code></strong></dt>
289+
<dd>The root node of the tree to visualize</dd>
290+
<dt><strong><code>depth</code></strong></dt>
291+
<dd>The depth of the tree (-1 for auto-calculation)</dd>
292+
<dt><strong><code>valueFillChar</code></strong></dt>
293+
<dd>Character for padding node values (e.g., "<em>5</em>")</dd>
294+
<dt><strong><code>connectorFillChar</code></strong></dt>
295+
<dd>Character for filling horizontal gaps between node pairs</dd>
296+
<dt><strong><code>unitSize</code></strong></dt>
297+
<dd>Size for centering values</dd>
298+
<dt><strong><code>removeEmpty</code></strong></dt>
299+
<dd>Whether to remove empty leading columns</dd>
300+
<dt><strong><code>connectors</code></strong></dt>
301+
<dd>Two-character string for connectors (e.g., "/" or "||"), None to skip connector rows</dd>
302+
</dl></div>
273303
</dd>
274304
</dl>
275305
</section>

0 commit comments

Comments
 (0)