Skip to content

Commit e9bf035

Browse files
committed
refractored documentation
1 parent cf0844d commit e9bf035

15 files changed

Lines changed: 2537 additions & 2475 deletions

File tree

README.md

Lines changed: 18 additions & 2441 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[⬅ Back to main readme file](../README.md)
2+
3+
# Common Pitfalls
4+
5+
- **C++20 required** - Won't compile with older standards
6+
- **No automatic conversions from strings** - Use `Int()`, `Float()`, etc. when converting from strings
7+
- **Dictionary keys** - Currently only support string keys
8+
- **Index checking** - Out of bounds returns None instead of throwing
9+
- **Comparison** - Different types compare as not equal (no implicit conversion)
10+
- **Operator ambiguity with slicing** - When using `slice()` with `None`, wrap numeric literals in `var()`: `slice(None, None, var(-1))`
11+
- **Index ambiguity** - Use `size_t` for list indices when 0 might be ambiguous: `lst[size_t(0)]`
12+
- **DynamicVar arithmetic** - Convert `let()` variables to `var` first for arithmetic: `var v = let(x); let(x) = v + 50;`
13+
- **Type Conversions** - The `var` type provides explicit conversion operators, so `static_cast<int>()`, `static_cast<double>()` work correctly. However, for clarity and best practice, prefer using the explicit conversion methods `.toInt()`, `.toDouble()`, `.toString()`:
14+
15+
```cpp
16+
var x = 42;
17+
int i1 = static_cast<int>(x); // Works ✓ (returns 42)
18+
int i2 = x.toInt(); // Recommended ✓ (clearer intent)
19+
20+
// For list/path access, both work:
21+
var path = list(0, 2, 4, 3);
22+
size_t idx1 = static_cast<size_t>(static_cast<int>(path[1])); // Works ✓
23+
size_t idx2 = static_cast<size_t>(path[1].toInt()); // Clearer ✓
24+
```
25+
26+
# Safety Features
27+
28+
- **Overflow Detection** - Integer arithmetic operations (+, -, \*, /) are checked for overflow and throw `PythonicOverflowError`
29+
- **Zero Division** - Division/Modulo by zero throws `PythonicZeroDivisionError`
30+
- **Safe Iteration** - `as_span()` provides safe views of list data

docs/Var/graph_helpers.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,64 @@ This page documents all user-facing graph APIs for `var` when holding a graph, i
66

77
---
88

9+
---
10+
11+
## Interactive Graph Viewer (GUI)
12+
13+
Pythonic provides a powerful interactive viewer for your graphs, powered by OpenGL/ImGui. This lets you visualize, edit, and explore graphs in real time.
14+
15+
### Enabling the Viewer
16+
17+
To use the interactive viewer, build with the following CMake option:
18+
19+
```bash
20+
cmake -DPYTHONIC_ENABLE_GRAPH_VIEWER=ON ..
21+
```
22+
23+
### Usage
24+
25+
Once enabled, simply call:
26+
27+
```cpp
28+
g.show();
29+
```
30+
31+
or
32+
33+
```cpp
34+
g.show(false); // disables auto-layout, preserves current node positions
35+
```
36+
37+
### Features
38+
39+
- **View Mode**:
40+
- Drag nodes (physics snaps them back to preserve topology)
41+
- Hover over nodes/edges to see metadata/weights
42+
- **Click nodes** to trigger animated signal waves
43+
- **Edit Mode** (toggle with 🔒 icon):
44+
- **Double-click** empty space to add nodes
45+
- **Drag** from node to node to add edges
46+
- **Select + Delete** to remove nodes/edges
47+
- All changes are saved back to your `var` graph
48+
49+
### Controls & Tips
50+
51+
| Action | Effect |
52+
| ------------------------- | ----------------------------------- |
53+
| Drag node | Move node (snaps back in View mode) |
54+
| Hover node/edge | Show metadata/weight |
55+
| Click node | Trigger animated signal wave |
56+
| Double-click empty space | Add new node (Edit mode) |
57+
| Drag from node to node | Add edge (Edit mode) |
58+
| Select node/edge + Delete | Remove element (Edit mode) |
59+
| 🔒 icon (top bar) | Toggle between View/Edit mode |
60+
| Mouse wheel | Zoom in/out |
61+
| Right-click background | Pan view |
62+
63+
**Note:** The viewer is only available if built with the appropriate CMake flag. If `g.show()` does nothing, check your build configuration.
64+
65+
---
66+
967
## Graph Properties & Queries
1068

1169
| Method | Description | Example |

docs/api_reference.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)