renderdag 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- renderdag-0.1.0/LICENSE +21 -0
- renderdag-0.1.0/PKG-INFO +152 -0
- renderdag-0.1.0/README.md +113 -0
- renderdag-0.1.0/pyproject.toml +33 -0
- renderdag-0.1.0/src/renderdag/__init__.py +25 -0
- renderdag-0.1.0/src/renderdag/_ascii.py +165 -0
- renderdag-0.1.0/src/renderdag/_ascii_large.py +196 -0
- renderdag-0.1.0/src/renderdag/_box_drawing.py +246 -0
- renderdag-0.1.0/src/renderdag/_column.py +134 -0
- renderdag-0.1.0/src/renderdag/_output.py +35 -0
- renderdag-0.1.0/src/renderdag/_pad.py +13 -0
- renderdag-0.1.0/src/renderdag/_render.py +411 -0
- renderdag-0.1.0/src/renderdag/py.typed +0 -0
renderdag-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
renderdag-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: renderdag
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Render directed acyclic graphs (DAGs) as text, ported from sapling-renderdag
|
|
5
|
+
Keywords: dag,graph,visualization,git,terminal
|
|
6
|
+
Author: Sam Watson
|
|
7
|
+
Author-email: Sam Watson <sam.watson@aprioriinvestments.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
35
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
36
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
37
|
+
Requires-Python: >=3.10
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# renderdag
|
|
41
|
+
|
|
42
|
+
A Python port of Meta's [sapling-renderdag](https://github.com/facebook/sapling/tree/main/eden/scm/lib/renderdag) Rust library for rendering directed acyclic graphs (DAGs) as text.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Renderers
|
|
46
|
+
|
|
47
|
+
**ASCII** — basic characters, compact:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
o E merge commit
|
|
51
|
+
|\
|
|
52
|
+
o | D
|
|
53
|
+
| |
|
|
54
|
+
| o C branch
|
|
55
|
+
|/
|
|
56
|
+
o B
|
|
57
|
+
|
|
|
58
|
+
o A
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**ASCII Large** — wider spacing, easier to read:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
o E merge commit
|
|
65
|
+
|\
|
|
66
|
+
| \
|
|
67
|
+
o | D
|
|
68
|
+
| |
|
|
69
|
+
| o C branch
|
|
70
|
+
| /
|
|
71
|
+
|/
|
|
72
|
+
o B
|
|
73
|
+
|
|
|
74
|
+
o A
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Box Drawing** — Unicode line-drawing characters:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
o E merge commit
|
|
81
|
+
├─╮
|
|
82
|
+
o │ D
|
|
83
|
+
│ │
|
|
84
|
+
│ o C branch
|
|
85
|
+
├─╯
|
|
86
|
+
o B
|
|
87
|
+
│
|
|
88
|
+
o A
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Install
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
pip install renderdag
|
|
95
|
+
# or
|
|
96
|
+
uv add renderdag
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from renderdag import Ancestor, GraphRowRenderer
|
|
103
|
+
|
|
104
|
+
renderer = GraphRowRenderer().output().build_box_drawing()
|
|
105
|
+
|
|
106
|
+
# Render rows top-down (most recent commit first)
|
|
107
|
+
print(renderer.next_row("C", [Ancestor.parent("B")], "o", "C latest"))
|
|
108
|
+
print(renderer.next_row("B", [Ancestor.parent("A")], "o", "B"))
|
|
109
|
+
print(renderer.next_row("A", [], "o", "A root"))
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The API follows a row-at-a-time model: call `next_row()` for each node in topological order (heads first), passing the node identifier, its parents as `Ancestor` values, a glyph string, and a message. The renderer tracks column state and returns the formatted string for that row.
|
|
113
|
+
|
|
114
|
+
### Ancestor types
|
|
115
|
+
|
|
116
|
+
- `Ancestor.parent(node)` — direct parent (solid line)
|
|
117
|
+
- `Ancestor.ancestor(node)` — indirect ancestor (dotted line)
|
|
118
|
+
- `Ancestor.anonymous()` — unknown/missing parent (terminator `~`)
|
|
119
|
+
|
|
120
|
+
### Builder options
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
# ASCII renderer
|
|
124
|
+
renderer = GraphRowRenderer().output().build_ascii()
|
|
125
|
+
|
|
126
|
+
# ASCII Large with taller rows
|
|
127
|
+
renderer = GraphRowRenderer().output().with_min_row_height(3).build_ascii_large()
|
|
128
|
+
|
|
129
|
+
# Box Drawing with square corners instead of curved
|
|
130
|
+
renderer = GraphRowRenderer().output().build_box_drawing().with_square_glyphs()
|
|
131
|
+
|
|
132
|
+
# Reserve a column for a node before it appears
|
|
133
|
+
renderer.reserve("some-node")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
Requires [uv](https://docs.astral.sh/uv/) and [just](https://just.systems/).
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
just demo # see example output from all renderers
|
|
142
|
+
just test # run all tests
|
|
143
|
+
just test-fast # skip Rust cross-validation
|
|
144
|
+
just test-xval # run only Rust cross-validation
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT. This is a derivative work of [sapling-renderdag](https://github.com/facebook/sapling/tree/main/eden/scm/lib/renderdag) by Meta Platforms, Inc. See [LICENSE](LICENSE) for details.
|
|
150
|
+
|
|
151
|
+
*Note: this library was created using LLMs.*
|
|
152
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# renderdag
|
|
2
|
+
|
|
3
|
+
A Python port of Meta's [sapling-renderdag](https://github.com/facebook/sapling/tree/main/eden/scm/lib/renderdag) Rust library for rendering directed acyclic graphs (DAGs) as text.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Renderers
|
|
7
|
+
|
|
8
|
+
**ASCII** — basic characters, compact:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
o E merge commit
|
|
12
|
+
|\
|
|
13
|
+
o | D
|
|
14
|
+
| |
|
|
15
|
+
| o C branch
|
|
16
|
+
|/
|
|
17
|
+
o B
|
|
18
|
+
|
|
|
19
|
+
o A
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**ASCII Large** — wider spacing, easier to read:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
o E merge commit
|
|
26
|
+
|\
|
|
27
|
+
| \
|
|
28
|
+
o | D
|
|
29
|
+
| |
|
|
30
|
+
| o C branch
|
|
31
|
+
| /
|
|
32
|
+
|/
|
|
33
|
+
o B
|
|
34
|
+
|
|
|
35
|
+
o A
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Box Drawing** — Unicode line-drawing characters:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
o E merge commit
|
|
42
|
+
├─╮
|
|
43
|
+
o │ D
|
|
44
|
+
│ │
|
|
45
|
+
│ o C branch
|
|
46
|
+
├─╯
|
|
47
|
+
o B
|
|
48
|
+
│
|
|
49
|
+
o A
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
pip install renderdag
|
|
56
|
+
# or
|
|
57
|
+
uv add renderdag
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from renderdag import Ancestor, GraphRowRenderer
|
|
64
|
+
|
|
65
|
+
renderer = GraphRowRenderer().output().build_box_drawing()
|
|
66
|
+
|
|
67
|
+
# Render rows top-down (most recent commit first)
|
|
68
|
+
print(renderer.next_row("C", [Ancestor.parent("B")], "o", "C latest"))
|
|
69
|
+
print(renderer.next_row("B", [Ancestor.parent("A")], "o", "B"))
|
|
70
|
+
print(renderer.next_row("A", [], "o", "A root"))
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The API follows a row-at-a-time model: call `next_row()` for each node in topological order (heads first), passing the node identifier, its parents as `Ancestor` values, a glyph string, and a message. The renderer tracks column state and returns the formatted string for that row.
|
|
74
|
+
|
|
75
|
+
### Ancestor types
|
|
76
|
+
|
|
77
|
+
- `Ancestor.parent(node)` — direct parent (solid line)
|
|
78
|
+
- `Ancestor.ancestor(node)` — indirect ancestor (dotted line)
|
|
79
|
+
- `Ancestor.anonymous()` — unknown/missing parent (terminator `~`)
|
|
80
|
+
|
|
81
|
+
### Builder options
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
# ASCII renderer
|
|
85
|
+
renderer = GraphRowRenderer().output().build_ascii()
|
|
86
|
+
|
|
87
|
+
# ASCII Large with taller rows
|
|
88
|
+
renderer = GraphRowRenderer().output().with_min_row_height(3).build_ascii_large()
|
|
89
|
+
|
|
90
|
+
# Box Drawing with square corners instead of curved
|
|
91
|
+
renderer = GraphRowRenderer().output().build_box_drawing().with_square_glyphs()
|
|
92
|
+
|
|
93
|
+
# Reserve a column for a node before it appears
|
|
94
|
+
renderer.reserve("some-node")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
Requires [uv](https://docs.astral.sh/uv/) and [just](https://just.systems/).
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
just demo # see example output from all renderers
|
|
103
|
+
just test # run all tests
|
|
104
|
+
just test-fast # skip Rust cross-validation
|
|
105
|
+
just test-xval # run only Rust cross-validation
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT. This is a derivative work of [sapling-renderdag](https://github.com/facebook/sapling/tree/main/eden/scm/lib/renderdag) by Meta Platforms, Inc. See [LICENSE](LICENSE) for details.
|
|
111
|
+
|
|
112
|
+
*Note: this library was created using LLMs.*
|
|
113
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "renderdag"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Render directed acyclic graphs (DAGs) as text, ported from sapling-renderdag"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = { file = "LICENSE" }
|
|
7
|
+
keywords = ["dag", "graph", "visualization", "git", "terminal"]
|
|
8
|
+
classifiers = [
|
|
9
|
+
"License :: OSI Approved :: MIT License",
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
16
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
17
|
+
]
|
|
18
|
+
authors = [
|
|
19
|
+
{ name = "Sam Watson", email = "sam.watson@aprioriinvestments.com" }
|
|
20
|
+
]
|
|
21
|
+
requires-python = ">=3.10"
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["uv_build>=0.10.1,<0.11.0"]
|
|
26
|
+
build-backend = "uv_build"
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"marimo[mcp]>=0.19.9",
|
|
31
|
+
"polars>=1.38.1",
|
|
32
|
+
"pytest>=8.0",
|
|
33
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from ._render import (
|
|
2
|
+
Ancestor,
|
|
3
|
+
AncestorType,
|
|
4
|
+
GraphRow,
|
|
5
|
+
GraphRowRenderer,
|
|
6
|
+
LinkLine,
|
|
7
|
+
NodeLine,
|
|
8
|
+
PadLine,
|
|
9
|
+
)
|
|
10
|
+
from ._ascii import AsciiRenderer
|
|
11
|
+
from ._ascii_large import AsciiLargeRenderer
|
|
12
|
+
from ._box_drawing import BoxDrawingRenderer
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Ancestor",
|
|
16
|
+
"AncestorType",
|
|
17
|
+
"GraphRow",
|
|
18
|
+
"GraphRowRenderer",
|
|
19
|
+
"LinkLine",
|
|
20
|
+
"NodeLine",
|
|
21
|
+
"PadLine",
|
|
22
|
+
"AsciiRenderer",
|
|
23
|
+
"AsciiLargeRenderer",
|
|
24
|
+
"BoxDrawingRenderer",
|
|
25
|
+
]
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from ._output import OutputRendererOptions
|
|
4
|
+
from ._pad import pad_lines
|
|
5
|
+
from ._render import (
|
|
6
|
+
AncestorType,
|
|
7
|
+
GraphRow,
|
|
8
|
+
GraphRowRenderer,
|
|
9
|
+
LinkLine,
|
|
10
|
+
NodeLine,
|
|
11
|
+
PadLine,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AsciiRenderer:
|
|
16
|
+
def __init__(self, inner: GraphRowRenderer, options: OutputRendererOptions) -> None:
|
|
17
|
+
self._inner = inner
|
|
18
|
+
self._options = options
|
|
19
|
+
self._extra_pad_line: str | None = None
|
|
20
|
+
|
|
21
|
+
def width(
|
|
22
|
+
self,
|
|
23
|
+
node: object | None = None,
|
|
24
|
+
parents: list[AncestorType] | None = None,
|
|
25
|
+
) -> int:
|
|
26
|
+
return self._inner.width(node, parents) * 2 + 1
|
|
27
|
+
|
|
28
|
+
def reserve(self, node: object) -> None:
|
|
29
|
+
self._inner.reserve(node)
|
|
30
|
+
|
|
31
|
+
def next_row(
|
|
32
|
+
self,
|
|
33
|
+
node: object,
|
|
34
|
+
parents: list[AncestorType],
|
|
35
|
+
glyph: str,
|
|
36
|
+
message: str,
|
|
37
|
+
) -> str:
|
|
38
|
+
line = self._inner.next_row(node, parents, glyph, message)
|
|
39
|
+
out: list[str] = []
|
|
40
|
+
message_lines = pad_lines(
|
|
41
|
+
line.message.splitlines(), self._options.min_row_height
|
|
42
|
+
)
|
|
43
|
+
message_iter = iter(message_lines)
|
|
44
|
+
need_extra_pad_line = False
|
|
45
|
+
|
|
46
|
+
if self._extra_pad_line is not None:
|
|
47
|
+
out.append(self._extra_pad_line.rstrip())
|
|
48
|
+
out.append("\n")
|
|
49
|
+
self._extra_pad_line = None
|
|
50
|
+
|
|
51
|
+
# Node line
|
|
52
|
+
node_line_str = ""
|
|
53
|
+
for entry in line.node_line:
|
|
54
|
+
if entry == NodeLine.NODE:
|
|
55
|
+
node_line_str += line.glyph + " "
|
|
56
|
+
elif entry == NodeLine.PARENT:
|
|
57
|
+
node_line_str += "| "
|
|
58
|
+
elif entry == NodeLine.ANCESTOR:
|
|
59
|
+
node_line_str += ". "
|
|
60
|
+
else:
|
|
61
|
+
node_line_str += " "
|
|
62
|
+
msg = next(message_iter, None)
|
|
63
|
+
if msg is not None:
|
|
64
|
+
node_line_str += " " + msg
|
|
65
|
+
out.append(node_line_str.rstrip())
|
|
66
|
+
out.append("\n")
|
|
67
|
+
|
|
68
|
+
# Link line
|
|
69
|
+
if line.link_line is not None:
|
|
70
|
+
link_row = line.link_line
|
|
71
|
+
any_horizontal = any(
|
|
72
|
+
cur.intersects(LinkLine.HORIZONTAL) for cur in link_row
|
|
73
|
+
)
|
|
74
|
+
link_line_str = ""
|
|
75
|
+
extended = list(link_row) + [LinkLine(0)]
|
|
76
|
+
for idx in range(len(link_row)):
|
|
77
|
+
cur = extended[idx]
|
|
78
|
+
nxt = extended[idx + 1]
|
|
79
|
+
|
|
80
|
+
# Column character
|
|
81
|
+
if cur.intersects(LinkLine.HORIZONTAL):
|
|
82
|
+
if cur.intersects(LinkLine.CHILD | LinkLine.ANY_FORK_OR_MERGE):
|
|
83
|
+
link_line_str += "+"
|
|
84
|
+
else:
|
|
85
|
+
link_line_str += "-"
|
|
86
|
+
elif cur.intersects(LinkLine.VERTICAL):
|
|
87
|
+
if cur.intersects(LinkLine.ANY_FORK_OR_MERGE) and any_horizontal:
|
|
88
|
+
link_line_str += "+"
|
|
89
|
+
elif cur.intersects(LinkLine.VERT_PARENT):
|
|
90
|
+
link_line_str += "|"
|
|
91
|
+
else:
|
|
92
|
+
link_line_str += "."
|
|
93
|
+
elif cur.intersects(LinkLine.ANY_MERGE) and any_horizontal:
|
|
94
|
+
link_line_str += "'"
|
|
95
|
+
elif cur.intersects(LinkLine.ANY_FORK) and any_horizontal:
|
|
96
|
+
link_line_str += "."
|
|
97
|
+
else:
|
|
98
|
+
link_line_str += " "
|
|
99
|
+
|
|
100
|
+
# Connecting character
|
|
101
|
+
if cur.intersects(LinkLine.HORIZONTAL):
|
|
102
|
+
link_line_str += "-"
|
|
103
|
+
elif cur.intersects(LinkLine.RIGHT_MERGE):
|
|
104
|
+
if nxt.intersects(LinkLine.LEFT_FORK) and not any_horizontal:
|
|
105
|
+
link_line_str += "\\"
|
|
106
|
+
else:
|
|
107
|
+
link_line_str += "-"
|
|
108
|
+
elif cur.intersects(LinkLine.RIGHT_FORK):
|
|
109
|
+
if nxt.intersects(LinkLine.LEFT_MERGE) and not any_horizontal:
|
|
110
|
+
link_line_str += "/"
|
|
111
|
+
else:
|
|
112
|
+
link_line_str += "-"
|
|
113
|
+
else:
|
|
114
|
+
link_line_str += " "
|
|
115
|
+
|
|
116
|
+
msg = next(message_iter, None)
|
|
117
|
+
if msg is not None:
|
|
118
|
+
link_line_str += " " + msg
|
|
119
|
+
out.append(link_line_str.rstrip())
|
|
120
|
+
out.append("\n")
|
|
121
|
+
|
|
122
|
+
# Term line
|
|
123
|
+
if line.term_line is not None:
|
|
124
|
+
term_row = line.term_line
|
|
125
|
+
term_strs = ["| ", "~ "]
|
|
126
|
+
for term_str in term_strs:
|
|
127
|
+
term_line_str = ""
|
|
128
|
+
for i, term in enumerate(term_row):
|
|
129
|
+
if term:
|
|
130
|
+
term_line_str += term_str
|
|
131
|
+
else:
|
|
132
|
+
if line.pad_lines[i] == PadLine.PARENT:
|
|
133
|
+
term_line_str += "| "
|
|
134
|
+
elif line.pad_lines[i] == PadLine.ANCESTOR:
|
|
135
|
+
term_line_str += ". "
|
|
136
|
+
else:
|
|
137
|
+
term_line_str += " "
|
|
138
|
+
msg = next(message_iter, None)
|
|
139
|
+
if msg is not None:
|
|
140
|
+
term_line_str += " " + msg
|
|
141
|
+
out.append(term_line_str.rstrip())
|
|
142
|
+
out.append("\n")
|
|
143
|
+
need_extra_pad_line = True
|
|
144
|
+
|
|
145
|
+
# Base pad line
|
|
146
|
+
base_pad_line = ""
|
|
147
|
+
for entry in line.pad_lines:
|
|
148
|
+
if entry == PadLine.PARENT:
|
|
149
|
+
base_pad_line += "| "
|
|
150
|
+
elif entry == PadLine.ANCESTOR:
|
|
151
|
+
base_pad_line += ". "
|
|
152
|
+
else:
|
|
153
|
+
base_pad_line += " "
|
|
154
|
+
|
|
155
|
+
# Remaining message lines
|
|
156
|
+
for msg in message_iter:
|
|
157
|
+
pad_line = base_pad_line + " " + msg
|
|
158
|
+
out.append(pad_line.rstrip())
|
|
159
|
+
out.append("\n")
|
|
160
|
+
need_extra_pad_line = False
|
|
161
|
+
|
|
162
|
+
if need_extra_pad_line:
|
|
163
|
+
self._extra_pad_line = base_pad_line
|
|
164
|
+
|
|
165
|
+
return "".join(out)
|