Skip to content

Commit ef72f43

Browse files
committed
build: publish TypeScript API docs to GitHub Pages
1 parent dd33c9d commit ef72f43

File tree

10 files changed

+80
-8
lines changed

10 files changed

+80
-8
lines changed

.github/workflows/docs.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- v[0-9]+.[0-9]+.[0-9]+*
9+
10+
jobs:
11+
docs:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Fetch all git branches
16+
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
17+
- uses: actions/setup-node@v1
18+
with:
19+
node-version: 12.x
20+
- run: npm install --engine-strict --no-lockfile
21+
- run: npm run docs:build
22+
- uses: docker://malept/gha-gh-pages:1.0.0
23+
with:
24+
docsPath: typedoc
25+
showUnderscoreFiles: true
26+
versionDocs: true
27+
env:
28+
DOCS_SSH_DEPLOY_KEY: ${{ secrets.DOCS_SSH_DEPLOY_KEY }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ yarn.lock
88
test/fixtures/basic/main-link.js
99
!test/fixtures/prune-is-module/node_modules
1010
test/work
11+
typedoc
1112
.DS_Store
1213
.nyc_output
1314
npm-debug.log

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Package your [Electron](https://electronjs.org) app into OS-specific bundles (`.
1010
[Supported Platforms](#supported-platforms) |
1111
[Installation](#installation) |
1212
[Usage](#usage) |
13-
[API](https://github.com/electron/electron-packager/blob/master/docs/api.md) |
13+
[API](https://electron.github.io/electron-packager/master/) |
1414
[Contributing](https://github.com/electron/electron-packager/blob/master/CONTRIBUTING.md) |
1515
[Support](https://github.com/electron/electron-packager/blob/master/SUPPORT.md) |
1616
[Related Apps/Libraries](#related) |
@@ -72,7 +72,7 @@ later needs to be installed. On macOS, it is installable via [Homebrew](http://b
7272

7373
## Usage
7474

75-
JavaScript API usage can be found in the [API documentation](https://github.com/electron/electron-packager/blob/master/docs/api.md).
75+
JavaScript API usage can be found in the [API documentation](https://electron.github.io/electron-packager/master/modules/electronpackager.html).
7676

7777
### From the Command Line
7878

@@ -95,7 +95,7 @@ This will:
9595

9696
For an overview of the other optional flags, run `electron-packager --help` or see
9797
[usage.txt](https://github.com/electron/electron-packager/blob/master/usage.txt). For
98-
detailed descriptions, see the [API documentation](https://github.com/electron/electron-packager/blob/master/docs/api.md).
98+
detailed descriptions, see the [API documentation](https://electron.github.io/electron-packager/master/modules/electronpackager.html).
9999

100100
If `appname` is omitted, this will use the name specified by "productName" or "name" in the nearest package.json.
101101

docs/_config.yml

-1
This file was deleted.

docs/api.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[API Documentation](https://electron.github.io/electron-packager/) has moved.

docs/faq.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and packaged modes, you'll need to [define it yourself](https://electronjs.org/d
1414

1515
## Why isn't my `ignore` option working?
1616

17-
As stated in the documentation for [`ignore`](https://github.com/electron/electron-packager/blob/master/docs/api.md#ignore), it uses "[one] or more additional
17+
As stated in the documentation for [`ignore`](https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#ignore), it uses "[one] or more additional
1818
[regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
1919
patterns. [] Please note that [glob patterns](https://en.wikipedia.org/wiki/Glob_%28programming%29)
2020
will not work."
@@ -44,7 +44,7 @@ console.log(require(jsonFilename));
4444

4545
## How do I set an icon on Linux?
4646

47-
The docs for [`icon`](https://github.com/electron/electron-packager/blob/master/docs/api.md#icon)
47+
The docs for [`icon`](https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#icon)
4848
already show how to set an icon on your `BrowserWindow`, but your dock/taskbar may not use that and
4949
instead use the `Icon` value in your `.desktop` file. The [Linux distributable creators](https://github.com/electron/electron-packager#distributable-creators)
5050
can help you set/distribute the appropriate icon in that case.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"pkg-up": "^3.0.1",
6363
"sinon": "^9.0.0",
6464
"tsd": "^0.11.0",
65+
"typedoc": "^0.16.10",
6566
"typescript": "^3.7.5"
6667
},
6768
"engines": {
@@ -71,6 +72,7 @@
7172
"ava": "ava test/index.js",
7273
"codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
7374
"coverage": "nyc npm run ava",
75+
"docs:build": "node test/ci/build_docs.js",
7476
"lint": "npm run lint:js && npm run lint:ts",
7577
"lint:js": "eslint .",
7678
"lint:ts": "eslint --config .eslintrc.typescript.js --ext .ts .",

src/infer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function errorMessageForProperty (prop) {
3434

3535
return `Unable to determine ${propDescription}. Please specify an ${propDescription}\n\n` +
3636
'For more information, please see\n' +
37-
`https://github.com/electron/electron-packager/blob/master/docs/api.md#${hash}\n`
37+
`https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#${hash}\n`
3838
}
3939

4040
function resolvePromise (id, options) {

test/ci/build_docs.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
4+
const { Application } = require('typedoc')
5+
6+
const config = {
7+
excludeExternals: true,
8+
excludePrivate: true,
9+
excludeProtected: true,
10+
includeDeclarations: true,
11+
mode: 'file'
12+
}
13+
14+
const replaceRef = /^refs\/(head|tag)s\//
15+
16+
function gitRevisionFromGitHubRef () {
17+
const githubRef = process.env.GITHUB_REF
18+
if (githubRef) {
19+
return githubRef.replace(replaceRef, '')
20+
}
21+
}
22+
23+
const gitRevision = process.argv[2] || gitRevisionFromGitHubRef()
24+
if (gitRevision) {
25+
if (/^[0-9a-f]+$/i.test(gitRevision)) {
26+
config.gitRevision = gitRevision
27+
} else if (gitRevision.startsWith('v')) {
28+
config.includeVersion = true
29+
}
30+
}
31+
32+
const app = new Application()
33+
app.bootstrap(config)
34+
35+
const project = app.convert(['src/index.d.ts'])
36+
if (project) {
37+
app.generateDocs(project, 'typedoc')
38+
} else {
39+
console.error('Could not generate API documentation from TypeScript definition!')
40+
process.exit(1)
41+
}

usage.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extra-resource a file to copy into the app's resources directory
5454
icon the local path to an icon file to use as the icon for the app.
5555
Note: Format depends on platform.
5656
ignore do not copy files into app whose filenames RegExp.match this string. See also:
57-
https://github.com/electron/electron-packager/blob/master/docs/api.md#ignore
57+
https://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#ignore
5858
and --no-prune. Can be specified multiple times
5959
no-deref-symlinks make sure symlinks are not dereferenced within the app source
6060
no-junk do not ignore system junk files from the packaged app

0 commit comments

Comments
 (0)