Skip to content

Source Code Organization

Rich Chiodo edited this page Jul 19, 2022 · 5 revisions

Layers

The code under src is partitioned into the following layers

  • platform: Provides general utilities and infrastructure code/services that can be used in any other layer.
  • kernels: Code related to raw kernel detection, executing kernels and communicating with Jupyter server.
  • notebooks: Code related to VS Code notebook editor/document/controller. It's responsible for integrating Jupyter kernels into .ipynb notebooks managed by VS Code builtin serializer.
  • interactive-window. Interactive Window specific code. IW is an embed editor which consists of notebook and monaco editors.
  • webviews: Webview based features we offer to users, including Variable view, data viewer, and plot viewer. Each feature has an extension side and webview side.
  • standalone. This is where we host all other standalone features to offer rich Jupyter development experience. Each component is well decoupled, usually has one single responsibility and doesn't affect how the core system functions. Examples include API (expose extensibility points for external partners to interface with), Intellisense (offer rich language features to Jupyter notebook and IW).
image

Source Organization

To ensure we don't introduce layer breaking changes into the project, we have set up ESLint rules. In a nutshell:

  • platform can use nothing else
  • kernels can only use platform
  • notebooks can only use platform and kernels
  • interactive-window can only use platform, notebooks, and kernels. Please note that interactive-window knows about notebooks but not the other way around. In notebooks land, interactive-window is seen as an embed notebook.
  • webviews can depend all components, except standalone.
  • standalone can depend all others, but no one can depend on standalone.

In addition to these top components, we have three global utilities which are shared by the whole code base and serve as living documents:

  • commands.ts. Typings for VS Code builtin commands and commands we contribute.
  • telemetry.ts. Typings for all our telemetry events and base utilities for sending telemetry.
  • messageTypes.ts. Typings for messages between extension node code and webview code.

Jupyter for Desktop and Web

We ship the Jupyter extension to both Desktop (run in nodejs environment) and Web (run in web worker environment). Most code in the project is isomorphic and writing code for only Desktop and Web are exceptions.

To distinguish the environments in the product we build, there are entry files that define all the components which will be included in the environment:

  • src/**/serviceRegistry.node.ts for desktop features
  • src/**/serviceRegistry.web.ts for web features

We intentionally append env in file extension if the code is not generic/shared. Code that is used only in Web is named as *.web.ts and code only used in Desktop is named as *.node.ts. Shared code will not end with *.node.ts or *.web.ts.

Clone this wiki locally