History

Move language-specific debugging docs to the page for each language (#33692)

Release Notes: - N/A

Cole Miller committed 1 year ago

Commit b7bfdd31 parent 0e2e5b813 files · +409 −343Browse files

Showing the changes to docs/src/languages/python.md (1 of 13 files). Show all

Unified · Split

docs/src/languages/python.md+65−0
@@ -6,6 +6,7 @@ Python support is available natively in Zed. · 5 unmodified lines
66 - Language Servers:
77 - [microsoft/pyright](https://github.com/microsoft/pyright)
88 - [python-lsp/python-lsp-server](https://github.com/python-lsp/python-lsp-server) (PyLSP)
9+- Debug Adapter: [debugpy](https://github.com/microsoft/debugpy)
910
1011 ## Language Servers
1112
@@ -125,3 +126,67 @@ A common tool for formatting Python code is [Ruff](https://docs.astral.sh/ruff/) · 113 unmodified lines
125126 TBD: Expand Python Ruff docs.
126127 TBD: Ruff pyproject.toml, ruff.toml docs. `ruff.configuration`.
127128 -->
129+
130+## Debugging
131+
132+Zed supports zero-configuration debugging of Python module entry points and pytest tests.
133+Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list for the current project.
134+For greater control, you can add debug configurations to `.zed/debug.json`. See the examples below.
135+
136+### Debug Active File
137+
138+```json
139+[
140+ {
141+ "label": "Python Active File",
142+ "adapter": "Debugpy",
143+ "program": "$ZED_FILE",
144+ "request": "launch"
145+ }
146+]
147+```
148+
149+### Flask App
150+
151+For a common Flask Application with a file structure similar to the following:
152+
153+```
154+.venv/
155+app/
156+ init.py
157+ main.py
158+ routes.py
159+templates/
160+ index.html
161+static/
162+ style.css
163+requirements.txt
164+```
165+
166+…the following configuration can be used:
167+
168+```json
169+[
170+ {
171+ "label": "Python: Flask",
172+ "adapter": "Debugpy",
173+ "request": "launch",
174+ "module": "app",
175+ "cwd": "$ZED_WORKTREE_ROOT",
176+ "env": {
177+ "FLASK_APP": "app",
178+ "FLASK_DEBUG": "1"
179+ },
180+ "args": [
181+ "run",
182+ "--reload", // Enables Flask reloader that watches for file changes
183+ "--debugger" // Enables Flask debugger
184+ ],
185+ "autoReload": {
186+ "enable": true
187+ },
188+ "jinja": true,
189+ "justMyCode": true
190+ }
191+]
192+```