Skip to content

Releases: cdfmlr/pyflowchart

v0.4.0-alpha.4

03 Nov 13:06
dcb5128
Compare
Choose a tag to compare

Support match-case with Python 3.10+

v0.3.1

27 Aug 04:29
24017fa
Compare
Choose a tag to compare
  • fix a backward compatibility bug introduced in v0.3.0: #26
  • code format & docs cleanup

v0.3.0

09 Aug 00:31
Compare
Choose a tag to compare

🎉 Supports outputting HTML. Thanks to @ddfault.

Python Code --> Flowchart --> HTML

CLI: ouput the generated flowchart.js DSL into an html by adding the parameter -o output.html where you specify an output filename ending in .html or .htm.

Python: from pyflowchart import output_html and call output_html(output_name: str, field_name: str, flowchart: str) -> None

Opening the output.html in a browser to visualize the diagrams. Click run to update the diagram. Click links to download the flowchart as a .svg or .png image.


See README for more usage. See discussions in #24 for design & implementation details.

Goto https://pypi.org/project/pyflowchart/0.3.0/ for installing or upgrading.


v0.2.3

14 Feb 03:51
94a4150
Compare
Choose a tag to compare

https://pypi.org/project/pyflowchart/0.2.3/

What's Changed

  • condition node alignment support by @cdfmlr in #15

Thanks @angerhang for digging out this feature.

Full Changelog: v0.1.4...v0.2.3r

v0.2.0 issue-14-align-conds

Support Node.set_param(key, value) to generate flowchart like this:

element(param1=value1,param2=value2)=>start: Start

And as a grammar sugar, support ConditionNode.no_align_next() to set a param align-next=no.

cond2(align-next=no)=>condition: Yes or No?

For convenience, you can also specify this operation when constructing a ConditionNode by:

ConditionNode("a cond node", align_next=False)

(Version 0.2.0 and 0.2.1 do not involve anything function of python code to flowchart, but are features regarding writing flowcharts in python.)

v0.2.1 connect_direction setting for human!

I find it's hard to make something like cond2(yes,right)->io5 when testing the v0.2.0. So I modified some interfaces to make it better.

To set a connection direction, Instead of calling the Node.set_connect_direction(), since v0.2.1 you can just pass a second parameter to connect(), which seems more human:

st = StartNode('a_pyflow_test')
op = OperationNode('do something')
cond1 = ConditionNode('Yes or No?', align_next=False)
cond2 = ConditionNode('True or False?', align_next=False)
cond3 = ConditionNode('1 or 0?', align_next=False)
io1 = InputOutputNode(InputOutputNode.OUTPUT, 'something...')
io2 = InputOutputNode(InputOutputNode.OUTPUT, 'anything...')
io3 = InputOutputNode(InputOutputNode.OUTPUT, 'nothing...')
sub = SubroutineNode('A Subroutine')
e = EndNode('a_pyflow_test')

st.connect(op, 'right')
op.connect(cond1)
cond1.connect_yes(io1, 'right')
cond2.connect_yes(io2, 'right')
cond3.connect_yes(io3, 'right')
cond1.connect_no(cond2)
cond2.connect_no(cond3)
io1.connect(sub, 'right')
io2.connect(sub, 'right')
io3.connect(sub, 'right')
sub.connect(e)

fc = Flowchart(st)
print(fc.flowchart())

Outputs:

st0=>start: start a_pyflow_test
op1=>operation: do something
cond2(align-next=no)=>condition: Yes or No?
io5=>inputoutput: output: something...
sub8=>subroutine: A Subroutine
e9=>end: end a_pyflow_test
cond3(align-next=no)=>condition: True or False?
io6=>inputoutput: output: anything...
cond4(align-next=no)=>condition: 1 or 0?
io7=>inputoutput: output: nothing...

st0(right)->op1
op1->cond2
cond2->
cond2->
cond2(yes, right)->io5
io5(right)->sub8
sub8->e9
cond2(no)->cond3
cond3->
cond3->
cond3(yes, right)->io6
io6(right)->sub8
cond3(no)->cond4
cond4->
cond4(yes, right)->io7
io7(right)->sub8

result

v0.2.2 conds-align for py2flowchart

Improve the flowchart of consecutive If statements converted from python code with the new feature of v0.2.0:

# example-conds-align.py
if cond1:
	op1
if cond2:
	op2
if cond3:
	op3
op_end

It works fine in v0.1.4 with the default simplify feature:

 python3 -m pyflowchart example.py   
cond3=>operation: op1 if  cond1
cond14=>operation: op2 if  cond2
cond25=>operation: op3 if  cond3
op35=>operation: op_end

cond3->cond14
cond14->cond25
cond25->op35

result-simplify

But if we run it with --no-simplify:

python3 -m pyflowchart --no-simplify example-condsalign.py
cond3=>condition: if cond1
op7=>operation: op1
cond13=>condition: if cond2
op17=>operation: op2
cond23=>condition: if cond3
op27=>operation: op3
op32=>operation: op_end

cond3(yes)->op7
op7->cond13
cond13(yes)->op17
op17->cond23
cond23(yes)->op27
op27->op32
cond23(no)->op32
cond13(no)->cond23
cond3(no)->cond13

result-old

Ugly, right? No more~! This version offers a new --conds-align flag to beautify these consecutive If statements.

python3 -m pyflowchart --no-simplify --conds-align example.py

or in python:

import pyflowchart
with open('example.py') as f:
	code = f.read()

fc = pyflowchart.Flowchart.from_code(code, simplify=False, conds_align=True)
print(fc.flowchart())

Outputs:

cond3(align-next=no)=>condition: if cond1
op7=>operation: op1
cond13(align-next=no)=>condition: if cond2
op17=>operation: op2
cond23=>condition: if cond3
op27=>operation: op3
op32=>operation: op_end

cond3(yes, right)->op7
op7->cond13
cond13(yes, right)->op17
op17->cond23
cond23(yes, right)->op27
op27->op32
cond23(no)->op32
cond13(no)->cond23
cond3(no)->cond13

result-conds-align

v0.2.3 fix a bug

v0.2.1 (ddc4486) does something wrong causing the old way Node.set_connect_direction() invalid. This version fixed it. So you can use both

sub.set_connect_direction("right")
sub.connect(op)

and

sub.connect(op, "right")

On a top level.

docs updates

Updates README, docs new features above.

v0.1.4

04 Jul 14:21
7eaed90
Compare
Choose a tag to compare

Simplify the generated node names from:

st4303462304=>start: start a_pyflow_test
op4302546112=>operation: do something
cond4303774096=>condition: Yes or No?
io4303237472=>inputoutput: output: something...
e4303275104=>end: end a_pyflow_test
sub4303240064=>subroutine: A Subroutine

st4303462304->op4302546112
op4302546112->cond4303774096
cond4303774096(yes)->io4303237472
io4303237472->e4303275104
cond4303774096(no)->sub4303240064
sub4303240064(right)->op4302546112

To:

st0=>start: start a_pyflow_test
op1=>operation: do something
cond2=>condition: Yes or No?
io3=>inputoutput: output: something...
e5=>end: end a_pyflow_test
sub4=>subroutine: A Subroutine

st0->op1
op1->cond2
cond2(yes)->io3
io3->e5
cond2(no)->sub4
sub4(right)->op1

v0.1.3

07 Mar 07:55
4e54d8e
Compare
Choose a tag to compare

v0.1.3 supports no simplify

🙏 Thanks Sung-En Chiu.

#6: Let users choose simplify or not

The If and Loop in ast_node.py have methods called simplify to simplify the condition sentences that has one-line-body from

while xxx      <------
   |                 |
   ---yes-> loop body in one line
   |
   |no
   v

into a single node:

<loop body> while xxx

Previous versions (starting from v0.0.1) hardcoded this feature. And users has no choice to close it.

This PR makes simplify can be disabled by

  1. Flowchart.from_code(..., simplify=False) with Python, or
  2. --no-simplify with CLI.

#7 fix a #6(v0.1.2) bug: simplify works with nested if/func/loop

v0.1.1

16 Jan 07:41
dd4bff7
Compare
Choose a tag to compare

Bug fix: decode error when read the code file inputed from CLI

This version resolved #4. Rather than call open('rt') without a special encoding, this new version will open file in binary and then auto detect file encoding before decode it.

Thanks @BackMountainDevil.

v0.1.0

03 Dec 08:35
Compare
Choose a tag to compare

support specifying a field of code to generate flowchart.

Thanks to @xxcdd.

https://pypi.org/project/pyflowchart/0.1.0/

v0.0.2

30 Oct 14:17
Compare
Choose a tag to compare

fix an encoding bug for Windows.

https://pypi.org/project/pyflowchart/0.0.2/

v0.0.1

23 Oct 12:20
Compare
Choose a tag to compare