Skip to content

Commit a0e3522

Browse files
committed
Update developer-overview.md
1 parent 5da5b80 commit a0e3522

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

‎v3/docs/developer-overview.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ I'm assuming that you're competent in Python, JavaScript, command-line-fu, and G
1212
and [command-line BS](http://www.pgbovine.net/command-line-bullshittery.htm).
1313

1414
This guide isn't meant to be comprehensive; rather, it's a starting point for learning about the code
15-
and development workflow. You will undoubtedly still be confused about details after reading it, so
15+
and development workflow. You may still be confused about details after reading it, so
1616
feel free to email philip@pgbovine.net if you have questions.
1717

1818

@@ -32,22 +32,20 @@ And then run:
3232
Use `python3` if you want to test the Python 3 backend. Note that when you run with bottle, you will **always trigger the backend for the version of Python used to invoke it**, so the Python 2/3 language toggle selector on the frontend is meaningless. You will also not be able to test other language backends locally.
3333

3434

35-
If all goes well, when you visit this URL, you should see the Python Tutor visualizer:
35+
If all goes well, when you visit this URL, you should see the Python Tutor visualizer: http://localhost:8003/visualize.html
3636

37-
http://localhost:8003/visualize.html
38-
39-
Note that you can run bottle with both Python 2 and 3.
37+
And the live programming mode is here: http://localhost:8003/live.html
4038

4139
However, **only** run this app locally for testing, not in production, since all security checks are disabled.
4240

4341

4442
## Overall system architecture
4543

4644
OPT consists of a pure-Python backend and an HTML/CSS/JavaScript frontend.
47-
Here is a typical user interaction sequence:
45+
Here is a typical user interaction sequence for Python (this will differ for other languages):
4846

4947
1. The user visits [visualize.html](http://pythontutor.com/visualize.html) and types in Python code in the web-based text editor.
50-
2. The user hits the "Visualize execution" button.
48+
2. The user hits the "Visualize Execution" button.
5149
3. The OPT frontend sends the user's Python code as a string to the backend by making an Ajax GET request.
5250
4. The backend executes the Python code under the supervision of the Python [bdb](http://docs.python.org/library/bdb.html) debugger, produces an execution trace, and sends that trace back to the frontend in JSON format.
5351
5. The frontend switches to a visualization display, parses the execution trace, and renders the appropriate stack frames, heap objects, and pointers.
@@ -60,6 +58,7 @@ The frontend consists of:
6058
visualize.html
6159
css/opt-frontend.css
6260
js/opt-frontend.js
61+
js/opt-frontend-common.js
6362
css/pytutor.css
6463
js/pytutor.js
6564
<a bunch of auxiliary css and js files such as libraries>
@@ -79,19 +78,19 @@ to embed on the same webpage without them interfering with one another.
7978
`opt-frontend.[js|css]` contain code that is specific to the `visualize.html` page and doesn't make sense for, say,
8079
embedding OPT visualizations into other webpages.
8180

82-
The backend consists of:
81+
The Python backend consists of:
8382
```
8483
pg_logger.py - the main entry point to the OPT backend
8584
pg_encoder.py - encodes the trace format into JSON to send to frontend
8685
generate_json_trace.py - script to test the backend independent of the frontend
87-
app.yaml, pythontutor.py - files for deploying on Google App Engine
86+
app.yaml, pythontutor.py - files for deploying on Google App Engine (obsolete)
8887
web_exec.py - example CGI script for deploying backend on CGI-enabled webservers
8988
```
9089

91-
The backend works with both Python 2 and 3. (Other language backends are located in [v4-cokapi/](https://github.com/pgbovine/OnlinePythonTutor/tree/master/v4-cokapi), not in v3/)
90+
This backend works with both Python 2 and 3. (Other language backends are located in [v4-cokapi/](https://github.com/pgbovine/OnlinePythonTutor/tree/master/v4-cokapi), not in v3/)
9291

9392

94-
## Hacking the backend
93+
## Hacking the Python backend
9594

9695
To modify the Python backend, you will mainly need to understand `pg_logger.py` and `pg_encoder.py`.
9796

@@ -115,7 +114,7 @@ This data is exactly what the backend sends to the frontend.
115114
But for testing purposes, I've made the trace more human-readable.)
116115

117116
Second, when you're "print debugging" in the backend, you can't simply print to stdout, since `pg_logger.py`
118-
*redirects* stdout to a buffer. Instead, you need to write all of your print statements as:
117+
*redirects* stdout to a buffer. Instead, you need to write all of your print statements (in Python 2) as:
119118

120119
```python
121120
print >> sys.stderr, <your debug message>
@@ -124,7 +123,7 @@ print >> sys.stderr, <your debug message>
124123
so that the output goes to stderr.
125124

126125
The easiest way to debug or investigate how some part of the code works is to **insert in print statements (to stderr)
127-
and then run `generate_json_trace.py` on small code examples**. Trust me -- being able to do this is way more
126+
and then run `generate_json_trace.py` on small code examples**. Trust me -- being able to do this well is way more
128127
effective than memorizing detailed documentation (which could be outdated by the time you read it).
129128

130129

@@ -228,6 +227,7 @@ entry is created. At the end of execution, `self.trace` contains as many trace e
228227
in the user's program execution. Each step more-or-less corresponds to one line being executed.
229228
(To guard against infinite loops, `PGLogger` terminates execution when `MAX_EXECUTED_LINES` steps have been executed.)
230229

230+
231231
### Execution Trace Format
232232

233233
A lot of complicated stuff happens within `interaction` to grab a snapshot of the execution state and encode

0 commit comments

Comments
 (0)