JupyterLab Debugger 使用教程
1. 项目的目录结构及介绍
JupyterLab Debugger 项目的目录结构如下:
jupyterlab/
├── .github/
├── docs/
├── examples/
├── packages/
│ ├── debugger/
│ ├── debugger-extension/
│ ├── ...
├── scripts/
├── style/
├── tests/
├── tsconfigbase.json
├── ...
目录介绍
- .github/: 包含 GitHub 相关的配置文件,如 issue 模板、PR 模板等。
- docs/: 包含项目的文档文件,如用户指南、开发者文档等。
- examples/: 包含示例代码,帮助用户理解如何使用该项目。
- packages/: 包含项目的各个子包,其中
debugger
和debugger-extension
是核心包。 - scripts/: 包含一些脚本文件,用于项目的构建、测试等。
- style/: 包含项目的样式文件。
- tests/: 包含项目的测试文件。
- tsconfigbase.json: TypeScript 配置文件。
2. 项目的启动文件介绍
JupyterLab Debugger 的启动文件主要位于 packages/debugger-extension
目录下。关键文件包括:
- src/index.ts: 这是扩展的入口文件,负责初始化和注册调试器扩展。
- src/tokens.ts: 定义了调试器扩展所需的一些 Token 和接口。
- src/debugger.ts: 包含了调试器的主要逻辑和功能。
启动文件介绍
- index.ts:
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; import { IDebugger } from './tokens'; import { Debugger } from './debugger'; /** * Initialization data for the debugger-extension extension. */ const extension: JupyterFrontEndPlugin<IDebugger> = { id: 'debugger-extension:plugin', autoStart: true, provides: IDebugger, activate: (app: JupyterFrontEnd) => { const debuggerInstance = new Debugger(); return debuggerInstance; } }; export default extension;
3. 项目的配置文件介绍
JupyterLab Debugger 的配置文件主要位于项目的根目录下。关键配置文件包括:
- package.json: 包含了项目的依赖、脚本命令、版本信息等。
- tsconfig.json: TypeScript 的编译配置文件。
- jupyterlab_debugger.json: 可能包含一些特定于调试器的配置选项。
配置文件介绍
- package.json:
{ "name": "jupyterlab-debugger", "version": "0.3.0", "description": "A JupyterLab extension for debugging.", "keywords": [ "jupyter", "jupyterlab", "jupyterlab-extension" ], "homepage": "https://github.com/jupyterlab/debugger", "bugs": { "url": "https://github.com/jupyterlab/debugger/issues" }, "license": "BSD-3-Clause", "author": "Project Jupyter", "main": "lib/index.js", "types": "lib/index.d.ts", "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" ], "repository": { "type": "git", "url": "https://github.com/jupyterlab/debugger.git" }, "scripts": { "build": "tsc", "clean": "rimraf lib", "prepare": "npm run clean && npm run build", "watch": "tsc -w" }, "dependencies": { "@jupyterlab/application": "^2.