2015-08-22 15:07:45 +03:00
|
|
|
# Electron Documentation Styleguide
|
|
|
|
|
2015-09-09 23:32:56 +03:00
|
|
|
Find the appropriate section for your task: [reading Electron documentation](#reading-electron-documentation)
|
|
|
|
or [writing Electron documentation](#writing-electron-documentation).
|
2015-08-22 15:07:45 +03:00
|
|
|
|
|
|
|
## Writing Electron Documentation
|
|
|
|
|
|
|
|
These are the ways that we construct the Electron documentation.
|
|
|
|
|
|
|
|
- Maximum one `h1` title per page.
|
|
|
|
- Use `bash` instead of `cmd` in code blocks (because of syntax highlighter).
|
2015-08-24 15:38:29 +03:00
|
|
|
- Doc `h1` titles should match object name (i.e. `browser-window` →
|
|
|
|
`BrowserWindow`).
|
2015-08-22 15:07:45 +03:00
|
|
|
- Hyphen separated filenames, however, are fine.
|
|
|
|
- No headers following headers, add at least a one-sentence description.
|
|
|
|
- Methods headers are wrapped in `code` ticks.
|
2015-08-25 01:18:40 +03:00
|
|
|
- Event headers are wrapped in single 'quotation' marks.
|
2015-08-24 15:38:29 +03:00
|
|
|
- No nesting lists more than 2 levels (unfortunately because of markdown
|
|
|
|
renderer).
|
2015-08-22 15:07:45 +03:00
|
|
|
- Add section titles: Events, Class Methods and Instance Methods.
|
|
|
|
- Use 'will' over 'would' when describing outcomes.
|
|
|
|
- Events and methods are `h3` headers.
|
|
|
|
- Optional arguments written as `function (required[, optional])`.
|
2015-08-25 01:18:40 +03:00
|
|
|
- Optional arguments are denoted when called out in list.
|
|
|
|
- Line length is 80-column wrapped.
|
|
|
|
- Platform specific methods are noted in italics following method header.
|
2016-06-18 16:26:26 +03:00
|
|
|
- ```### `method(foo, bar)` _macOS_```
|
2015-09-04 23:44:40 +03:00
|
|
|
- Prefer 'in the ___ process' over 'on'
|
2015-08-22 15:07:45 +03:00
|
|
|
|
2015-09-09 23:33:11 +03:00
|
|
|
### Documentation Translations
|
|
|
|
|
|
|
|
Translations of the Electron docs are located within the `docs-translations`
|
|
|
|
directory.
|
|
|
|
|
|
|
|
To add another set (or partial set):
|
|
|
|
|
|
|
|
- Create a subdirectory named by language abbreviation.
|
|
|
|
- Within that subdirectory, duplicate the `docs` directory, keeping the
|
|
|
|
names of directories and files same.
|
|
|
|
- Translate the files.
|
|
|
|
- Update the `README.md` within your language directory to link to the files
|
|
|
|
you have translated.
|
2016-04-01 02:49:59 +03:00
|
|
|
- Add a link to your translation directory on the main Electron [README](https://github.com/electron/electron#documentation-translations).
|
2015-09-09 23:33:11 +03:00
|
|
|
|
2015-08-22 15:07:45 +03:00
|
|
|
## Reading Electron Documentation
|
|
|
|
|
|
|
|
Here are some tips for understanding Electron documentation syntax.
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
2015-08-24 15:38:29 +03:00
|
|
|
An example of [method](https://developer.mozilla.org/en-US/docs/Glossary/Method)
|
|
|
|
documentation:
|
2015-08-22 15:07:45 +03:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
`methodName(required[, optional]))`
|
|
|
|
|
2015-12-18 06:12:07 +03:00
|
|
|
* `require` String (**required**)
|
2015-08-22 15:07:45 +03:00
|
|
|
* `optional` Integer
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-08-24 15:38:29 +03:00
|
|
|
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.
|
2015-08-22 15:07:45 +03:00
|
|
|
|
2015-08-24 15:38:29 +03:00
|
|
|
Below the method is more detailed information on each of the arguments. The type
|
2015-10-09 09:19:16 +03:00
|
|
|
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)
|
2015-08-24 15:38:29 +03:00
|
|
|
or a custom type like Electron's [`webContent`](api/web-content.md).
|
2015-08-22 15:07:45 +03:00
|
|
|
|
|
|
|
### Events
|
|
|
|
|
2015-08-24 15:38:29 +03:00
|
|
|
An example of [event](https://developer.mozilla.org/en-US/docs/Web/API/Event)
|
|
|
|
documentation:
|
2015-08-22 15:07:45 +03:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
Event: 'wake-up'
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
* `time` String
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-08-24 15:38:29 +03:00
|
|
|
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:
|
2015-08-22 15:07:45 +03:00
|
|
|
|
|
|
|
```javascript
|
2016-05-04 19:55:05 +03:00
|
|
|
Alarm.on('wake-up', (time) => {
|
2016-05-10 19:57:55 +03:00
|
|
|
console.log(time);
|
|
|
|
});
|
2015-08-22 15:07:45 +03:00
|
|
|
```
|