Skip to content

Commit

Permalink
docs: typedoc improvements (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Jan 30, 2025
1 parent 372911b commit 6791547
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 63 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"nyc": "^15.0.0",
"pkg-up": "^4.0.0",
"sinon": "^18.0.0",
"typedoc": "^0.25.4",
"typedoc": "~0.25.4",
"typescript": "^5.2.2"
},
"engines": {
Expand All @@ -83,7 +83,7 @@
"postbuild": "copyfiles -f ./temp/targets.js ./src",
"coverage": "nyc ava test/index.js",
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov",
"docs:build": "node test/ci/build_docs.js",
"docs:build": "npx typedoc",
"lint": "eslint .",
"prepublish": "npm run build",
"pretest": "npm run build",
Expand Down
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async function packageAllSpecifiedCombos(opts: Options, archs: SupportedArch[],
* - finds or downloads the correct release of Electron
* - uses that version of Electron to create a app in `<out>/<appname>-<platform>-<arch>`
*
* Short example:
* @example
*
* ```javascript
* const packager = require('@electron/packager')
Expand Down
55 changes: 37 additions & 18 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { SignOptions as OSXInternalSignOptions } from '@electron/osx-sign/dist/e
import { SignOptions as WindowsInternalSignOptions } from '@electron/windows-sign/dist/esm/types';
import type { makeUniversalApp } from '@electron/universal';

/**
* @internal
*/
export type MakeUniversalOpts = Parameters<typeof makeUniversalApp>[0]

/**
Expand Down Expand Up @@ -48,7 +51,7 @@ export type SupportedPlatform = OfficialPlatform | 'all';
/**
* A predicate function that, given an absolute file `path`, returns `true` if the file should be
* ignored, or `false` if the file should be kept. *This does not use any of the default ignored
* files/directories listed for the {@link ignore} option.*
* files/directories listed for the {@link Options.ignore | ignore} option.*
*/

export type IgnoreFunction = (path: string) => boolean;
Expand All @@ -61,7 +64,18 @@ export type HookFunctionErrorCallback = (err?: Error | null) => void
* By default, the functions are called in parallel (via
* [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)).
* If you need the functions called serially, there is a utility function provided. Please note that
* **callback-style functions are not supported by `serialHooks`.** For example:
* **callback-style functions are not supported by `serialHooks`.**
*
* @param buildPath - For {@link Options.afterExtract | afterExtract}, the path to the temporary folder where the prebuilt
* Electron binary has been extracted to. For {@link Options.afterCopy | afterCopy} and {@link Options.afterPrune | afterPrune}, the path to the
* folder where the Electron app has been copied to. For {@link Options.afterComplete | afterComplete}, the final directory
* of the packaged application.
* @param electronVersion - the version of Electron that is being bundled with the application.
* @param platform - The target platform you are packaging for.
* @param arch - The target architecture you are packaging for.
* @param callback - Must be called once you have completed your actions.
*
* @example
*
* ```javascript
* const packager = require('@electron/packager')
Expand Down Expand Up @@ -90,16 +104,6 @@ export type HookFunctionErrorCallback = (err?: Error | null) => void
* plugins](https://github.com/electron/packager#plugins).
*/
export type HookFunction =
/**
* @param buildPath - For {@link afterExtract}, the path to the temporary folder where the prebuilt
* Electron binary has been extracted to. For {@link afterCopy} and {@link afterPrune}, the path to the
* folder where the Electron app has been copied to. For {@link afterComplete}, the final directory
* of the packaged application.
* @param electronVersion - the version of Electron that is being bundled with the application.
* @param platform - The target platform you are packaging for.
* @param arch - The target architecture you are packaging for.
* @param callback - Must be called once you have completed your actions.
*/
(
buildPath: string,
electronVersion: string,
Expand All @@ -114,15 +118,21 @@ export type TargetDefinition = {
}
export type FinalizePackageTargetsHookFunction = (targets: TargetDefinition[], callback: HookFunctionErrorCallback) => void;

/** See the documentation for [`@electron/osx-sign`](https://npm.im/@electron/osx-sign#opts) for details. */
/** See the documentation for [`@electron/osx-sign`](https://npm.im/@electron/osx-sign#opts) for details.
* @interface
*/
export type OsxSignOptions = Omit<OSXInternalSignOptions, 'app' | 'binaries' | 'platform' | 'version'>;

/**
* See the documentation for [`@electron/universal`](https://github.com/electron/universal)
* for details.
* @interface
*/
export type OsxUniversalOptions = Omit<MakeUniversalOpts, 'x64AppPath' | 'arm64AppPath' | 'outAppPath' | 'force'>

/**
* @internal
*/
export type IgnoreFunc = (platform: string, arch: string) => boolean;

/**
Expand Down Expand Up @@ -256,7 +266,7 @@ export interface Options {
* Arbitrary combinations of individual architectures are also supported via a comma-delimited
* string or array of strings. The non-`all` values correspond to the architecture names used
* by [Electron releases](https://github.com/electron/electron/releases). This value
* is not restricted to the official set if [[download|`download.mirrorOptions`]] is set.
* is not restricted to the official set if {@link download|`download.mirrorOptions`} is set.
*
* Defaults to the arch of the host computer running Electron Packager.
*
Expand Down Expand Up @@ -417,7 +427,7 @@ export interface Options {
* to show up in the dock/window list.* Setting the icon in the file manager is not currently supported.
*
* If the file extension is omitted, it is auto-completed to the correct extension based on the
* platform, including when [[platform|`platform: 'all'`]] is in effect.
* platform, including when {@link platform |`platform: 'all'`} is in effect.
*/
icon?: string;
/**
Expand Down Expand Up @@ -506,7 +516,7 @@ export interface Options {
*
* The official non-`all` values correspond to the platform names used by [Electron
* releases](https://github.com/electron/electron/releases). This value is not restricted to
* the official set if [[download|`download.mirrorOptions]] is set.
* the official set if {@link download|`download.mirrorOptions`} is set.
*
* Defaults to the platform of the host computer running Electron Packager.
*
Expand All @@ -516,7 +526,7 @@ export interface Options {
* - `mas` (macOS, specifically for submitting to the Mac App Store)
* - `win32`
*/
platform?: PlatformOption | PlatformOption[];
platform?: TargetPlatform | 'all' | Array<TargetPlatform | 'all'>;
/**
* The path to a prebuilt ASAR file.
*
Expand Down Expand Up @@ -569,7 +579,7 @@ export interface Options {
* Valid properties are the [Cocoa keys for MacOS](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
* of the pattern `NS(.*)UsageDescription`, where the captured group is the key to use.
*
* Example:
* @example
*
* ```javascript
* {
Expand Down Expand Up @@ -598,16 +608,25 @@ export interface Options {
windowsSign?: true | WindowsSignOptions;
}

/**
* @internal
*/
interface OptionsWithRequiredArchAndPlatform extends Options {
arch: Exclude<Options['arch'], undefined>;
platform: Exclude<Options['platform'], undefined>;
}

/**
* @internal
*/
export interface DownloadOptions extends OptionsWithRequiredArchAndPlatform {
artifactName: string;
version: string;
}

/**
* @internal
*/
export interface ComboOptions extends Options {
arch: OptionsWithRequiredArchAndPlatform['arch']
platform: OptionsWithRequiredArchAndPlatform['platform']
Expand Down
41 changes: 0 additions & 41 deletions test/ci/build_docs.js

This file was deleted.

14 changes: 14 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"entryPoints": ["src/index.ts"],
"out": "./typedoc",
"excludeInternal": true,
"sort": ["kind", "required-first", "alphabetical"],
"externalSymbolLinkMappings": {
"@electron/notarize": {
"NotaryToolCredentials": "https://packages.electronjs.org/notarize/main/types/NotaryToolCredentials.html"
},
"@electron/get": {
"ElectronDownloadRequestOptions": "https://github.com/electron/get/blob/79dab2b26df3a6841062b676f11d3e7bb1f8995e/src/types.ts#L57"
}
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4549,7 +4549,7 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typedoc@^0.25.4:
typedoc@~0.25.4:
version "0.25.13"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.13.tgz#9a98819e3b2d155a6d78589b46fa4c03768f0922"
integrity sha512-pQqiwiJ+Z4pigfOnnysObszLiU3mVLWAExSPf+Mu06G/qsc3wzbuM56SZQvONhHLncLUhYzOVkjFFpFfL5AzhQ==
Expand Down

0 comments on commit 6791547

Please sign in to comment.