From a82bbd010e5ef53edd758007f631e8a183da3cd3 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 20 Mar 2019 21:12:47 +0100 Subject: [PATCH] build: strip trailing whitespace in docs (#17488) --- docs/api/auto-updater.md | 6 +-- docs/api/breaking-changes.md | 2 +- docs/api/dialog.md | 2 +- docs/api/process.md | 4 +- docs/api/system-preferences.md | 10 ++--- docs/development/build-instructions-gn.md | 2 +- docs/development/releasing.md | 2 +- docs/tutorial/security.md | 22 +++++----- docs/tutorial/updates.md | 12 +++--- filenames.auto.gni | 1 + package.json | 3 +- script/check-trailing-whitespace.py | 52 +++++++++++++++++++++++ 12 files changed, 86 insertions(+), 32 deletions(-) create mode 100755 script/check-trailing-whitespace.py diff --git a/docs/api/auto-updater.md b/docs/api/auto-updater.md index 7f840f07102a..07a9fed4ff03 100644 --- a/docs/api/auto-updater.md +++ b/docs/api/auto-updater.md @@ -84,7 +84,7 @@ Emitted when an update has been downloaded. On Windows only `releaseName` is available. -**Note:** It is not strictly necessary to handle this event. A successfully +**Note:** It is not strictly necessary to handle this event. A successfully downloaded update will still be applied the next time the application starts. ### Event: 'before-quit-for-update' @@ -125,8 +125,8 @@ Under the hood calling `autoUpdater.quitAndInstall()` will close all application windows first, and automatically call `app.quit()` after all windows have been closed. -**Note:** It is not strictly necessary to call this function to apply an update, -as a successfully downloaded update will always be applied the next time the +**Note:** It is not strictly necessary to call this function to apply an update, +as a successfully downloaded update will always be applied the next time the application starts. [squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac diff --git a/docs/api/breaking-changes.md b/docs/api/breaking-changes.md index 883bd4ccc060..8aded66183bf 100644 --- a/docs/api/breaking-changes.md +++ b/docs/api/breaking-changes.md @@ -102,7 +102,7 @@ Child windows opened with the `nativeWindowOpen` option will always have Node.js Renderer process APIs `webFrame.setRegisterURLSchemeAsPrivileged` and `webFrame.registerURLSchemeAsBypassingCSP` as well as browser process API `protocol.registerStandardSchemes` have been removed. A new API, `protocol.registerSchemesAsPrivileged` has been added and should be used for registering custom schemes with the required privileges. Custom schemes are required to be registered before app ready. -## webFrame Isolated World APIs +## webFrame Isolated World APIs ```js // Deprecated diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 59971c655e0b..6b6d519f0f6b 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -115,7 +115,7 @@ dialog.showOpenDialogSync(mainWindow, { Returns `Promise` - Resolve wih an object containing the following: -* `canceled` - Boolean - whether or not the dialog was canceled. +* `canceled` - Boolean - whether or not the dialog was canceled. * `filePaths` String[] (optional) - An array of file paths chosen by the user. If the dialog is cancelled this will be an empty array. * `bookmarks` String[] (optional) _macOS_ _mas_ - An array matching the `filePaths` array of base64 encoded strings which contains security scoped bookmark data. `securityScopedBookmarks` must be enabled for this to be populated. diff --git a/docs/api/process.md b/docs/api/process.md index 239786127da2..76a78fc0c30d 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -84,7 +84,7 @@ instead of the `--no-deprecation` command line flag. ### `process.enablePromiseAPIs` A `Boolean` that controls whether or not deprecation warnings are printed to `stderr` when -formerly callback-based APIs converted to Promises are invoked using callbacks. Setting this to `true` +formerly callback-based APIs converted to Promises are invoked using callbacks. Setting this to `true` will enable deprecation warnings. ### `process.resourcesPath` @@ -178,7 +178,7 @@ Returns an object giving memory usage statistics about the current process. Note that all statistics are reported in Kilobytes. This api should be called after app ready. -Chromium does not provide `residentSet` value for macOS. This is because macOS +Chromium does not provide `residentSet` value for macOS. This is because macOS performs in-memory compression of pages that haven't been recently used. As a result the resident set size value is not what one would expect. `private` memory is more representative of the actual pre-compression memory usage of the process diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index f3ca49cbd7f0..e15a6df8af5b 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -90,7 +90,7 @@ that contains the user information dictionary sent along with the notification. * `callback` Function * `event` String * `userInfo` Object - + Returns `Number` - The ID of this subscription Subscribes to native notifications of macOS, `callback` will be called with @@ -115,7 +115,7 @@ example values of `event` are: * `callback` Function * `event` String * `userInfo` Object - + Returns `Number` - The ID of this subscription Same as `subscribeNotification`, but uses `NSNotificationCenter` for local defaults. @@ -149,9 +149,9 @@ Same as `unsubscribeNotification`, but removes the subscriber from `NSNotificati Same as `unsubscribeNotification`, but removes the subscriber from `NSWorkspace.sharedWorkspace.notificationCenter`. -### `systemPreferences.registerDefaults(defaults)` _macOS_ +### `systemPreferences.registerDefaults(defaults)` _macOS_ -* `defaults` Object - a dictionary of (`key: value`) user defaults +* `defaults` Object - a dictionary of (`key: value`) user defaults Add the specified defaults to your application's `NSUserDefaults`. @@ -319,7 +319,7 @@ This API is only available on macOS 10.14 Mojave or newer. * `unemphasized-selected-text-background` - A background for selected text in a non-key window or view. * `unemphasized-selected-text` - Selected text in a non-key window or view. * `window-background` - The background of a window. - * `window-frame-text` - The text in the window's titlebar area. + * `window-frame-text` - The text in the window's titlebar area. Returns `String` - The system color setting in RGB hexadecimal form (`#ABCDEF`). See the [Windows docs][windows-colors] and the [MacOS docs][macos-colors] for more details. diff --git a/docs/development/build-instructions-gn.md b/docs/development/build-instructions-gn.md index 5b98bfc9522d..8a095b4d0b91 100644 --- a/docs/development/build-instructions-gn.md +++ b/docs/development/build-instructions-gn.md @@ -89,7 +89,7 @@ $ git branch --set-upstream-to=origin/master $ cd - ``` -:memo: `gclient` works by checking a file called `DEPS` inside the +:memo: `gclient` works by checking a file called `DEPS` inside the `src/electron` folder for dependencies (like Chromium or Node.js). Running `gclient sync -f` ensures that all dependencies required to build Electron match that file. diff --git a/docs/development/releasing.md b/docs/development/releasing.md index fcd90805dd48..c37315bc0818 100644 --- a/docs/development/releasing.md +++ b/docs/development/releasing.md @@ -26,7 +26,7 @@ with the scope of `Build (read and execute)`. If you don't have these, ask a team member to help you. Once you've generated these tokens, put them in a `.env` file in the root directory -of the project. This file is gitignored, and will be loaded into the +of the project. This file is gitignored, and will be loaded into the environment by the release scripts. diff --git a/docs/tutorial/security.md b/docs/tutorial/security.md index 081c948b559b..fdd411bfcdc4 100644 --- a/docs/tutorial/security.md +++ b/docs/tutorial/security.md @@ -48,21 +48,21 @@ the result of the overall security of the framework foundation your code. As such, it is your responsibility to follow a few important best practices: -* **Keep your application up-to-date with the latest Electron framework release.** -When releasing your product, you’re also shipping a bundle composed of Electron, -Chromium shared library and Node.js. Vulnerabilities affecting these components -may impact the security of your application. By updating Electron to the latest -version, you ensure that critical vulnerabilities (such as *nodeIntegration bypasses*) +* **Keep your application up-to-date with the latest Electron framework release.** +When releasing your product, you’re also shipping a bundle composed of Electron, +Chromium shared library and Node.js. Vulnerabilities affecting these components +may impact the security of your application. By updating Electron to the latest +version, you ensure that critical vulnerabilities (such as *nodeIntegration bypasses*) are already patched and cannot be exploited in your application. -* **Evaluate your dependencies.** While NPM provides half a million reusable packages, -it is your responsibility to choose trusted 3rd-party libraries. If you use outdated -libraries affected by known vulnerabilities or rely on poorly maintained code, +* **Evaluate your dependencies.** While NPM provides half a million reusable packages, +it is your responsibility to choose trusted 3rd-party libraries. If you use outdated +libraries affected by known vulnerabilities or rely on poorly maintained code, your application security could be in jeopardy. -* **Adopt secure coding practices.** The first line of defense for your application -is your own code. Common web vulnerabilities, such as Cross-Site Scripting (XSS), -have a higher security impact on Electron applications hence it is highly recommended +* **Adopt secure coding practices.** The first line of defense for your application +is your own code. Common web vulnerabilities, such as Cross-Site Scripting (XSS), +have a higher security impact on Electron applications hence it is highly recommended to adopt secure software development best practices and perform security testing. diff --git a/docs/tutorial/updates.md b/docs/tutorial/updates.md index 05f2b133ee1e..e0245b2f6866 100644 --- a/docs/tutorial/updates.md +++ b/docs/tutorial/updates.md @@ -8,7 +8,7 @@ Electron's [autoUpdater](../api/auto-updater.md) module. ## Using `update.electronjs.org` GitHub's Electron team maintains [update.electronjs.org], a free and open-source -webservice that Electron apps can use to self-update. The service is designed +webservice that Electron apps can use to self-update. The service is designed for Electron apps that meet the following criteria: - App runs on macOS or Windows @@ -31,13 +31,13 @@ Invoke the updater from your app's main process file: require('update-electron-app')() ``` -By default, this module will check for updates at app startup, then every ten -minutes. When an update is found, it will automatically be downloaded in the background. When the download completes, a dialog is displayed allowing the user +By default, this module will check for updates at app startup, then every ten +minutes. When an update is found, it will automatically be downloaded in the background. When the download completes, a dialog is displayed allowing the user to restart the app. -If you need to customize your configuration, you can +If you need to customize your configuration, you can [pass options to `update-electron-app`][update-electron-app] -or +or [use the update service directly][update.electronjs.org]. ## Using `electron-builder` @@ -51,7 +51,7 @@ update mechanism, meaning that the rest of this documentation will not apply to ## Deploying an Update Server If you're developing a private Electron application, or if you're not -publishing releases to GitHub Releases, it may be necessary to run your own +publishing releases to GitHub Releases, it may be necessary to run your own update server. Depending on your needs, you can choose from one of these: diff --git a/filenames.auto.gni b/filenames.auto.gni index 7416d79af44d..5191cda90fb6 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -86,6 +86,7 @@ auto_filenames = { "docs/api/structures/notification-action.md", "docs/api/structures/point.md", "docs/api/structures/printer-info.md", + "docs/api/structures/process-memory-info.md", "docs/api/structures/process-metric.md", "docs/api/structures/product.md", "docs/api/structures/rectangle.md", diff --git a/package.json b/package.json index d41c64a1aeb3..a618a5d34d43 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,9 @@ "lint:cpp": "node ./script/lint.js --cc", "lint:py": "node ./script/lint.js --py", "lint:gn": "node ./script/lint.js --gn", - "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links", + "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links && npm run lint:check-trailing-whitespace", "lint:docs-relative-links": "python ./script/check-relative-doc-links.py", + "lint:check-trailing-whitespace": "python ./script/check-trailing-whitespace.py", "lint:js-in-markdown": "standard-markdown docs", "create-api-json": "electron-docs-linter docs --outfile=electron-api.json", "create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --in=electron-api.json --out=electron.d.ts && node spec/ts-smoke/runner.js", diff --git a/script/check-trailing-whitespace.py b/script/check-trailing-whitespace.py new file mode 100755 index 000000000000..3951ba40d3b3 --- /dev/null +++ b/script/check-trailing-whitespace.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import os +import sys + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +DOCS_DIR = os.path.join(SOURCE_ROOT, 'docs') + +def main(): + os.chdir(SOURCE_ROOT) + + filepaths = [] + totalDirs = 0 + try: + for root, dirs, files in os.walk(DOCS_DIR): + totalDirs += len(dirs) + for f in files: + if f.endswith('.md'): + filepaths.append(os.path.join(root, f)) + except KeyboardInterrupt: + print('Keyboard interruption. Please try again.') + return + + trailingWhiteSpaceFiles = 0 + for path in filepaths: + trailingWhiteSpaceFiles += hasTrailingWhiteSpace(path) + + print('Parsed through ' + str(len(filepaths)) + + ' files within docs directory and its ' + + str(totalDirs) + ' subdirectories.') + print('Found ' + str(trailingWhiteSpaceFiles) + + ' files with trailing whitespace.') + return trailingWhiteSpaceFiles + +def hasTrailingWhiteSpace(filepath): + try: + f = open(filepath, 'r') + lines = f.read().splitlines() + except KeyboardInterrupt: + print('Keyboard interruption whle parsing. Please try again.') + finally: + f.close() + + for line in lines: + if line != line.rstrip(): + print "Trailing whitespace in: " + filepath + return True + + return False + +if __name__ == '__main__': + sys.exit(main())