From 095f9067a7f9fa9edca0379acccb26d244e23f75 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Thu, 16 Mar 2023 17:05:15 -0700 Subject: [PATCH] docs: delete synopsis.md (#37580) * docs: delete synopsis.md * remove code references to doc --- docs/README.md | 1 - docs/api/synopsis.md | 93 ---------------------------------- filenames.auto.gni | 1 - spec/ts-smoke/electron/main.ts | 3 -- 4 files changed, 98 deletions(-) delete mode 100644 docs/api/synopsis.md diff --git a/docs/README.md b/docs/README.md index 30306ecb0e..d86583f97e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -90,7 +90,6 @@ These individual tutorials expand on topics discussed in the guide above. ## API References -* [Synopsis](api/synopsis.md) * [Process Object](api/process.md) * [Supported Command Line Switches](api/command-line-switches.md) * [Environment Variables](api/environment-variables.md) diff --git a/docs/api/synopsis.md b/docs/api/synopsis.md deleted file mode 100644 index 667c1dcd35..0000000000 --- a/docs/api/synopsis.md +++ /dev/null @@ -1,93 +0,0 @@ -# Synopsis - -> How to use Node.js and Electron APIs. - -All of [Node.js's built-in modules](https://nodejs.org/api/) are available in -Electron and third-party node modules also fully supported as well (including -the [native modules](../tutorial/using-native-node-modules.md)). - -Electron also provides some extra built-in modules for developing native -desktop applications. Some modules are only available in the main process, some -are only available in the renderer process (web page), and some can be used in -either process type. - -The basic rule is: if a module is [GUI][gui] or low-level system related, then -it should be only available in the main process. You need to be familiar with -the concept of main process vs. renderer process -scripts to be able to use those modules. - -The main process script is like a normal Node.js script: - -```javascript -const { app, BrowserWindow } = require('electron') -let win = null - -app.whenReady().then(() => { - win = new BrowserWindow({ width: 800, height: 600 }) - win.loadURL('https://github.com') -}) -``` - -The renderer process is no different than a normal web page, except for the -extra ability to use node modules if `nodeIntegration` is enabled: - -```html - - - - - - -``` - -## Destructuring assignment - -As of 0.37, you can use -[destructuring assignment][destructuring-assignment] to make it easier to use -built-in modules. - -```javascript -const { app, BrowserWindow } = require('electron') - -let win - -app.whenReady().then(() => { - win = new BrowserWindow() - win.loadURL('https://github.com') -}) -``` - -If you need the entire `electron` module, you can require it and then using -destructuring to access the individual modules from `electron`. - -```javascript -const electron = require('electron') -const { app, BrowserWindow } = electron - -let win - -app.whenReady().then(() => { - win = new BrowserWindow() - win.loadURL('https://github.com') -}) -``` - -This is equivalent to the following code: - -```javascript -const electron = require('electron') -const app = electron.app -const BrowserWindow = electron.BrowserWindow -let win - -app.whenReady().then(() => { - win = new BrowserWindow() - win.loadURL('https://github.com') -}) -``` - -[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface -[destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment diff --git a/filenames.auto.gni b/filenames.auto.gni index fdbd7f0dfd..c29eebcb20 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -49,7 +49,6 @@ auto_filenames = { "docs/api/share-menu.md", "docs/api/shell.md", "docs/api/structures", - "docs/api/synopsis.md", "docs/api/system-preferences.md", "docs/api/touch-bar-button.md", "docs/api/touch-bar-color-picker.md", diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 09519f83c2..468d16df7f 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -331,9 +331,6 @@ ipcMain.on('online-status-changed', (event, status: any) => { console.log(status); }); -// Synopsis -// https://github.com/electron/electron/blob/main/docs/api/synopsis.md - app.whenReady().then(() => { window = new BrowserWindow({ width: 800,