Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: strip trailing whitespace in docs #17488

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/api/auto-updater.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/api/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/api/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ dialog.showOpenDialogSync(mainWindow, {

Returns `Promise<Object>` - 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.

Expand Down
4 changes: 2 additions & 2 deletions docs/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/api/system-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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`.

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/build-instructions-gn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
22 changes: 11 additions & 11 deletions docs/tutorial/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
12 changes: 6 additions & 6 deletions docs/tutorial/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions filenames.auto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"docs/api/structures/process-metric.md",
"docs/api/structures/product.md",
"docs/api/structures/rectangle.md",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
52 changes: 52 additions & 0 deletions script/check-trailing-whitespace.py
Original file line number Diff line number Diff line change
@@ -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())