These are the guidelines for writing Electron documentation.
#
-level title at the top.##
-level headings.#
in the heading according to
their nesting depth.Using Quick Start
as example:
# Quick Start
...
## Main process
...
## Renderer process
...
## Run your app
...
### Run as a distribution
...
### Manually downloaded Electron binary
...
For API references, there are exceptions to this rule.
This repository uses the markdownlint
package to enforce consistent
Markdown styling. For the exact rules, see the .markdownlint.json
file in the root
folder.
There are a few style guidelines that aren't covered by the linter rules:
sh
instead of cmd
in code blocks (due to the syntax highlighter).js
and javascript
code blocks are linted with
standard-markdown.The following rules only apply to the documentation of APIs.
Each module's API doc must use the actual object name returned by require('electron')
as its title (such as BrowserWindow
, autoUpdater
, and session
).
Directly under the page title, add a one-line description of the module
as a markdown quote (beginning with >
).
Using the session
module as an example:
# session
> Manage browser sessions, cookies, cache, proxy settings, etc.
For modules that are not classes, their methods and events must be listed under
the ## Methods
and ## Events
chapters.
Using autoUpdater
as an example:
# autoUpdater
## Events
### Event: 'error'
## Methods
### `autoUpdater.setFeedURL(url[, requestHeaders])`
## Class: TheClassName
chapter.###
-level headings.### Static Methods
chapter.### Instance Methods
chapter.[TYPE]
- [Return description]"
Object
, its structure can be specified using a colon
followed by a newline then an unordered list of properties in the same style as
function parameters.### Instance Events
chapter.### Instance Properties
chapter.
Using the Session
and Cookies
classes as an example:
# session
## Methods
### session.fromPartition(partition)
## Static Properties
### session.defaultSession
## Class: Session
### Instance Events
#### Event: 'will-download'
### Instance Methods
#### `ses.getCacheSize()`
### Instance Properties
#### `ses.cookies`
## Class: Cookies
### Instance Methods
#### `cookies.get(filter, callback)`
The methods chapter must be in the following form:
### `objectName.methodName(required[, optional]))`
* `required` string - A parameter description.
* `optional` Integer (optional) - Another parameter description.
...
The heading can be ###
or ####
-levels depending on whether the method
belongs to a module or a class.
For modules, the objectName
is the module's name. For classes, it must be the
name of the instance of the class, and must not be the same as the module's
name.
For example, the methods of the Session
class under the session
module must
use ses
as the objectName
.
Optional arguments are notated by square brackets []
surrounding the optional
argument as well as the comma required if this optional argument follows another
argument:
required[, optional]
More detailed information on each of the arguments is noted in an unordered list
below the method. The type of argument is notated by either JavaScript primitives
(e.g. string
, Promise
, or Object
), a custom API structure like Electron's
Cookie
, or the wildcard any
.
If the argument is of type Array
, use []
shorthand with the type of value
inside the array (for example,any[]
or string[]
).
If the argument is of type Promise
, parametrize the type with what the promise
resolves to (for example, Promise<void>
or Promise<string>
).
If an argument can be of multiple types, separate the types with |
.
The description for Function
type arguments should make it clear how it may be
called and list the types of the parameters that will be passed to it.
If an argument or a method is unique to certain platforms, those platforms are
denoted using a space-delimited italicized list following the datatype. Values
can be macOS
, Windows
or Linux
.
* `animate` boolean (optional) _macOS_ _Windows_ - Animate the thing.
The events chapter must be in following form:
### Event: 'wake-up'
Returns:
* `time` string
...
The heading can be ###
or ####
-levels depending on whether the event
belongs to a module or a class.
The arguments of an event follow the same rules as methods.
The properties chapter must be in following form:
### session.defaultSession
...
The heading can be ###
or ####
-levels depending on whether the property
belongs to a module or a class.
See electron/i18n