Skip to content

Commit d45bb80

Browse files
committed
Merge branch 'master' of github.com:pgbovine/OnlinePythonTutor
2 parents 27b16b0 + b2d5376 commit d45bb80

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎v3/docs/opt-trace-format.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,28 @@ is that `trace.length` is the number of execution steps that the frontend render
125125

126126
Ok, still with me? Let's now dig into what an individual element in `trace` looks like.
127127

128+
## Interlude: Viewing a trace in the OPT frontend
129+
130+
To view a trace locally on your computer without setting up a Webserver, load up `v3/demo.html` in your browser.
131+
Now create a trace file called `v3/test-trace.js`, which contains a single trace variable like so:
132+
133+
```javascript
134+
var trace = { ... your trace object ... };
135+
```
136+
137+
Now reload `v3/demo.html`, and if everything works out, it will create a new visualization using the trace in the `trace`
138+
variable from `v3/test-trace.js`. I use this technique as a quick way of testing out what different traces look like
139+
without setting up a server.
140+
141+
**If you open up your browser console, you will see the current trace entry being printed out as you step through the
142+
visualization, which can help you debug.**
143+
144+
P.S. to create a trace file in the appropriate format using the defaault OPT Python frontend, run `generate_json_trace.py` using the `--create_jsvar` option:
145+
146+
```python
147+
python generate_json_trace.py --create_jsvar=trace example.py > test-trace.js
148+
```
149+
128150

129151
## Execution Point Objects
130152

0 commit comments

Comments
 (0)