Line wrap 80
This commit is contained in:
parent
d7fda9c8cc
commit
9b84dc4e1a
3 changed files with 52 additions and 37 deletions
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
The `app` module is responsible for controlling the application's lifecycle.
|
The `app` module is responsible for controlling the application's lifecycle.
|
||||||
|
|
||||||
The following example shows how to quit the application when the last window is closed:
|
The following example shows how to quit the application when the last window is
|
||||||
|
closed:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var app = require('app');
|
var app = require('app');
|
||||||
|
@ -19,9 +20,9 @@ The `app` object emits the following events:
|
||||||
|
|
||||||
Emitted when the application has finished basic startup. On Windows and Linux,
|
Emitted when the application has finished basic startup. On Windows and Linux,
|
||||||
the `will-finish-launching` event is the same as the `ready` event; on OS X,
|
the `will-finish-launching` event is the same as the `ready` event; on OS X,
|
||||||
this event represents the `applicationWillFinishLaunching` notification of `NSApplication`.
|
this event represents the `applicationWillFinishLaunching` notification of
|
||||||
You would usually set up listeners for the `open-file` and `open-url` events here,
|
`NSApplication`. You would usually set up listeners for the `open-file` and
|
||||||
and start the crash reporter and auto updater.
|
`open-url` events here, and start the crash reporter and auto updater.
|
||||||
|
|
||||||
In most cases, you should just do everything in the `ready` event handler.
|
In most cases, you should just do everything in the `ready` event handler.
|
||||||
|
|
||||||
|
@ -58,7 +59,8 @@ Emitted when all windows have been closed and the application will quit.
|
||||||
Calling `event.preventDefault()` will prevent the default behaviour, which is
|
Calling `event.preventDefault()` will prevent the default behaviour, which is
|
||||||
terminating the application.
|
terminating the application.
|
||||||
|
|
||||||
See the description of the `window-all-closed` event for the differences between the `will-quit` and `window-all-closed` events.
|
See the description of the `window-all-closed` event for the differences between
|
||||||
|
the `will-quit` and `window-all-closed` events.
|
||||||
|
|
||||||
### Event: 'quit'
|
### Event: 'quit'
|
||||||
|
|
||||||
|
@ -71,12 +73,12 @@ Returns:
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `path` String
|
* `path` String
|
||||||
|
|
||||||
Emitted when the user wants to open a file with the application. The `open-file` event
|
Emitted when the user wants to open a file with the application. The `open-file`
|
||||||
is usually emitted when the application is already open and the OS wants to reuse the
|
event is usually emitted when the application is already open and the OS wants
|
||||||
application to open the file. `open-file` is also emitted when a file is dropped onto the
|
to reuse the application to open the file. `open-file` is also emitted when a
|
||||||
dock and the application is not yet running. Make sure to listen for the `open-file`
|
file is dropped onto the dock and the application is not yet running. Make sure
|
||||||
event very early in your application startup to handle this case (even before the
|
to listen for the `open-file` event very early in your application startup to
|
||||||
`ready` event is emitted).
|
handle this case (even before the `ready` event is emitted).
|
||||||
|
|
||||||
You should call `event.preventDefault()` if you want to handle this event.
|
You should call `event.preventDefault()` if you want to handle this event.
|
||||||
|
|
||||||
|
@ -95,8 +97,8 @@ You should call `event.preventDefault()` if you want to handle this event.
|
||||||
### Event: 'activate-with-no-open-windows'
|
### Event: 'activate-with-no-open-windows'
|
||||||
|
|
||||||
Emitted when the application is activated while there are no open windows, which
|
Emitted when the application is activated while there are no open windows, which
|
||||||
usually happens when the user has closed all of the application's windows and then
|
usually happens when the user has closed all of the application's windows and
|
||||||
clicks on the application's dock icon.
|
then clicks on the application's dock icon.
|
||||||
|
|
||||||
### Event: 'browser-window-blur'
|
### Event: 'browser-window-blur'
|
||||||
|
|
||||||
|
@ -137,9 +139,10 @@ app.on('select-certificate', function(event, host, url, list, callback) {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
The `url` corresponds to the navigation entry requesting the client certificate and `callback` needs to be called with an entry filtered from the list.
|
The `url` corresponds to the navigation entry requesting the client certificate
|
||||||
Using `event.preventDefault()` prevents the application from using the first certificate
|
and `callback` needs to be called with an entry filtered from the list. Using
|
||||||
from the store.
|
`event.preventDefault()` prevents the application from using the first
|
||||||
|
certificate from the store.
|
||||||
|
|
||||||
### Event: 'gpu-process-crashed'
|
### Event: 'gpu-process-crashed'
|
||||||
|
|
||||||
|
@ -155,9 +158,9 @@ Try to close all windows. The `before-quit` event will emitted first. If all
|
||||||
windows are successfully closed, the `will-quit` event will be emitted and by
|
windows are successfully closed, the `will-quit` event will be emitted and by
|
||||||
default the application will terminate.
|
default the application will terminate.
|
||||||
|
|
||||||
This method guarantees that all `beforeunload` and `unload` event handlers are correctly
|
This method guarantees that all `beforeunload` and `unload` event handlers are
|
||||||
executed. It is possible that a window cancels the quitting by returning
|
correctly executed. It is possible that a window cancels the quitting by
|
||||||
`false` in the `beforeunload` event handler.
|
returning `false` in the `beforeunload` event handler.
|
||||||
|
|
||||||
### `app.getAppPath()`
|
### `app.getAppPath()`
|
||||||
|
|
||||||
|
@ -208,8 +211,8 @@ directory. If you want to change this location, you have to override the
|
||||||
### `app.getVersion()`
|
### `app.getVersion()`
|
||||||
|
|
||||||
Returns the version of the loaded application. If no version is found in the
|
Returns the version of the loaded application. If no version is found in the
|
||||||
application's `package.json` file, the version of the current bundle or executable is
|
application's `package.json` file, the version of the current bundle or
|
||||||
returned.
|
executable is returned.
|
||||||
|
|
||||||
### `app.getName()`
|
### `app.getName()`
|
||||||
|
|
||||||
|
@ -258,8 +261,8 @@ Adds `tasks` to the [Tasks][tasks] category of the JumpList on Windows.
|
||||||
* `title` String - The string to be displayed in a JumpList.
|
* `title` String - The string to be displayed in a JumpList.
|
||||||
* `description` String - Description of this task.
|
* `description` String - Description of this task.
|
||||||
* `iconPath` String - The absolute path to an icon to be displayed in a
|
* `iconPath` String - The absolute path to an icon to be displayed in a
|
||||||
JumpList, which can be an arbitrary resource file that contains an icon. You can
|
JumpList, which can be an arbitrary resource file that contains an icon. You
|
||||||
usually specify `process.execPath` to show the icon of the program.
|
can usually specify `process.execPath` to show the icon of the program.
|
||||||
* `iconIndex` Integer - The icon index in the icon file. If an icon file
|
* `iconIndex` Integer - The icon index in the icon file. If an icon file
|
||||||
consists of two or more icons, set this value to identify the icon. If an
|
consists of two or more icons, set this value to identify the icon. If an
|
||||||
icon file consists of one icon, this value is 0.
|
icon file consists of one icon, this value is 0.
|
||||||
|
@ -275,7 +278,8 @@ to control some low-level Chromium behaviors.
|
||||||
|
|
||||||
### `app.commandLine.appendArgument(value)`
|
### `app.commandLine.appendArgument(value)`
|
||||||
|
|
||||||
Append an argument to Chromium's command line. The argument will be quoted correctly.
|
Append an argument to Chromium's command line. The argument will be quoted
|
||||||
|
correctly.
|
||||||
|
|
||||||
**Note:** This will not affect `process.argv`.
|
**Note:** This will not affect `process.argv`.
|
||||||
|
|
||||||
|
@ -287,9 +291,9 @@ Append an argument to Chromium's command line. The argument will be quoted corre
|
||||||
When `critical` is passed, the dock icon will bounce until either the
|
When `critical` is passed, the dock icon will bounce until either the
|
||||||
application becomes active or the request is canceled.
|
application becomes active or the request is canceled.
|
||||||
|
|
||||||
When `informational` is passed, the dock icon will bounce for one second. However,
|
When `informational` is passed, the dock icon will bounce for one second.
|
||||||
the request remains active until either the application becomes active or
|
However, the request remains active until either the application becomes active
|
||||||
the request is canceled.
|
or the request is canceled.
|
||||||
|
|
||||||
Returns an ID representing the request.
|
Returns an ID representing the request.
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ Returns:
|
||||||
* `updateUrl` String
|
* `updateUrl` String
|
||||||
* `quitAndUpdate` Function
|
* `quitAndUpdate` Function
|
||||||
|
|
||||||
Emitted when an update has been downloaded. Calling `quitAndUpdate()` will restart
|
Emitted when an update has been downloaded. Calling `quitAndUpdate()` will
|
||||||
the application and install the update.
|
restart the application and install the update.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Electron Documentation Styleguide
|
# Electron Documentation Styleguide
|
||||||
|
|
||||||
Find the appropriate section for your task: [reading Electron documentation](#) or [writing Electron documentation](#).
|
Find the appropriate section for your task: [reading Electron documentation](#)
|
||||||
|
or [writing Electron documentation](#).
|
||||||
|
|
||||||
## Writing Electron Documentation
|
## Writing Electron Documentation
|
||||||
|
|
||||||
|
@ -8,12 +9,14 @@ These are the ways that we construct the Electron documentation.
|
||||||
|
|
||||||
- Maximum one `h1` title per page.
|
- Maximum one `h1` title per page.
|
||||||
- Use `bash` instead of `cmd` in code blocks (because of syntax highlighter).
|
- Use `bash` instead of `cmd` in code blocks (because of syntax highlighter).
|
||||||
- Doc `h1` titles should match object name (i.e. `browser-window` → `BrowserWindow`).
|
- Doc `h1` titles should match object name (i.e. `browser-window` →
|
||||||
|
`BrowserWindow`).
|
||||||
- Hyphen separated filenames, however, are fine.
|
- Hyphen separated filenames, however, are fine.
|
||||||
- No headers following headers, add at least a one-sentence description.
|
- No headers following headers, add at least a one-sentence description.
|
||||||
- Methods headers are wrapped in `code` ticks.
|
- Methods headers are wrapped in `code` ticks.
|
||||||
- Event headers are wrapped in singe 'quotation' marks.
|
- Event headers are wrapped in singe 'quotation' marks.
|
||||||
- No nesting lists more than 2 levels (unfortunately because of markdown renderer).
|
- No nesting lists more than 2 levels (unfortunately because of markdown
|
||||||
|
renderer).
|
||||||
- Add section titles: Events, Class Methods and Instance Methods.
|
- Add section titles: Events, Class Methods and Instance Methods.
|
||||||
- Use 'will' over 'would' when describing outcomes.
|
- Use 'will' over 'would' when describing outcomes.
|
||||||
- Events and methods are `h3` headers.
|
- Events and methods are `h3` headers.
|
||||||
|
@ -25,7 +28,8 @@ Here are some tips for understanding Electron documentation syntax.
|
||||||
|
|
||||||
### Methods
|
### Methods
|
||||||
|
|
||||||
An example of [method](https://developer.mozilla.org/en-US/docs/Glossary/Method) documentation:
|
An example of [method](https://developer.mozilla.org/en-US/docs/Glossary/Method)
|
||||||
|
documentation:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -36,13 +40,18 @@ An example of [method](https://developer.mozilla.org/en-US/docs/Glossary/Method)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
The method name is followed by the arguments it takes. Optional arguments are notated by brackets surrounding the optional argument as well as the comma required if this optional argument follows another argument.
|
The method name is followed by the arguments it takes. Optional arguments are
|
||||||
|
notated by brackets surrounding the optional argument as well as the comma
|
||||||
|
required if this optional argument follows another argument.
|
||||||
|
|
||||||
Below the method is more detailed information on each of the arguments. The type of argument is notated by either the common types: [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object), [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) or a custom type like Electron's [`webContent`](api/web-content.md).
|
Below the method is more detailed information on each of the arguments. The type
|
||||||
|
of argument is notated by either the common types: [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object), [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||||
|
or a custom type like Electron's [`webContent`](api/web-content.md).
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
An example of [event](https://developer.mozilla.org/en-US/docs/Web/API/Event) documentation:
|
An example of [event](https://developer.mozilla.org/en-US/docs/Web/API/Event)
|
||||||
|
documentation:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -54,7 +63,9 @@ Returns:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
The event is a string that is used after a `.on` listener method. If it returns a value it and its type is noted below. If you were to listen and respond to this event it might look something like this:
|
The event is a string that is used after a `.on` listener method. If it returns
|
||||||
|
a value it and its type is noted below. If you were to listen and respond to
|
||||||
|
this event it might look something like this:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
Alarm.on('wake-up', function(time) {
|
Alarm.on('wake-up', function(time) {
|
||||||
|
|
Loading…
Reference in a new issue