Skip to content

Commit 635e09d

Browse files
authored
docs: define TSDoc convention and align IPC docs (#3528)
* docs(preload): align IPC contract documentation * docs(preload): describe resolved values semantically * docs: define the TSDoc convention
1 parent 215bb5c commit 635e09d

5 files changed

Lines changed: 53 additions & 11 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,42 @@ the macOS native vibrancy material, which Chromium cannot render.
9999
- See [ARCHITECTURE.md](./ARCHITECTURE.md) for the renderer's module layering, state ownership, and side-effect conventions.
100100
- Keep commit messages clear and descriptive.
101101

102+
#### 📝 TSDoc
103+
104+
Every TSDoc block follows the [TSDoc][tsdoc-website] standard. Add TSDoc to
105+
exported APIs whose contract is not obvious from the signature; trivial
106+
presentational components may omit it. Existing files are not the standard:
107+
proposals and new changes follow this section.
108+
109+
- Start with a one-sentence summary.
110+
- Document every parameter with `@param name - description`. Put optional or
111+
default behaviour in the description; never add JSDoc type annotations.
112+
- Use `@returns` (not `@return`) for every non-void return. Describe the
113+
resolved value, its format, or its success and failure branches. Do not
114+
repeat the TypeScript type or write "Promise resolving to".
115+
- Let named result types own object shapes. Document fields on the type, then
116+
name or link the type from `@returns` instead of restating the shape.
117+
- Use `@throws` for each thrown error condition, `@remarks` for extended
118+
context, `@example` for non-obvious usage, and `@typeParam` for generic
119+
parameters.
120+
- Use `{@link Symbol}` for internal references and backticks for identifiers
121+
and literals.
122+
- Omit `@returns` for `void` and `Promise<void>`.
123+
- Update TSDoc in the same pull request as the behaviour change. Do not
124+
suppress a TSDoc lint finding; fix it or change this convention in a separate
125+
proposal.
126+
127+
```ts
128+
/**
129+
* Read the token the locally installed GitHub CLI holds for a host.
130+
*
131+
* @param hostname - Host to read the token for (e.g. `github.com`).
132+
* @returns The CLI token, or a classified failure with an optional detail line.
133+
*/
134+
```
135+
136+
TSDoc syntax is validated by the shared lint configuration through `pnpm check`.
137+
102138
### 🐛 How to Report Bugs or Request Features
103139

104140
If you encounter a bug or have a feature request, please [open an issue][github-issues] with clear steps to reproduce or a detailed description of your idea. Check for existing issues before creating a new one.
@@ -163,6 +199,7 @@ Currently supported forges: **GitHub** (Cloud, Enterprise Server, Enterprise Clo
163199
<!-- LINK LABELS -->
164200

165201
[vite-plus-website]: https://viteplus.dev/
202+
[tsdoc-website]: https://tsdoc.org/
166203
[conventional-commits]: https://www.conventionalcommits.org
167204
[release-please]: https://github.com/googleapis/release-please
168205
[github-dependency-dashboard]: https://github.com/gitify-app/gitify/issues/576

‎src/main/events.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export function handleMainEvent<E extends EventType>(
4242
*
4343
* @param mb - The menubar instance whose window receives the event.
4444
* @param event - The IPC channel/event name to emit.
45-
* @param data - Optional payload sent with the event.
45+
* @param args - Payload arguments for the event; omitted for events with no
46+
* request payload.
4647
*/
4748
export function sendRendererEvent<E extends EventType>(
4849
mb: Menubar,

‎src/main/handlers/github-cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const HOSTNAME_PATTERN = /^[a-z0-9][a-z0-9.-]*$/i;
3636
* is the only credential `gh` has.
3737
*
3838
* @param hostname - Host to read the token for (e.g. `github.com`).
39-
* @returns The token, or the reason the CLI could not supply one.
39+
* @returns The CLI token, or a classified failure with an optional detail line.
4040
*/
4141
export async function readGitHubCliToken(hostname: string): Promise<IGitHubCliTokenResult> {
4242
if (typeof hostname !== 'string' || !HOSTNAME_PATTERN.test(hostname)) {

‎src/preload/index.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ export const api = {
3838
* Decrypt an encrypted string using Electron's safe storage.
3939
*
4040
* @param value - The encrypted string to decrypt.
41-
* @returns A promise resolving to the plaintext string.
41+
* @returns The decrypted token and, when the OS keychain rotated keys, the
42+
* re-encrypted ciphertext to persist.
4243
*/
4344
decryptValue: (value: string) => invokeMainEvent(EVENTS.SAFE_STORAGE_DECRYPT, value),
4445

4546
/**
4647
* Read the token the locally installed GitHub CLI holds for a host.
4748
*
4849
* @param hostname - Host to read the token for (e.g. `github.com`).
49-
* @returns The token, or the reason the CLI could not supply one.
50+
* @returns The CLI token, or a classified failure with an optional detail line.
5051
*/
5152
githubCliToken: (hostname: string) => invokeMainEvent(EVENTS.GITHUB_CLI_TOKEN, hostname),
5253

@@ -93,13 +94,17 @@ export const api = {
9394
/**
9495
* Enable or disable the macOS window vibrancy material for Glass. Resolves once
9596
* the material has been applied so the renderer can order the visual switch.
97+
*
98+
* @param enabled - `true` to enable the vibrancy material, `false` to remove it.
9699
*/
97100
setWindowVibrancy: (enabled: boolean) => invokeMainEvent(EVENTS.SET_WINDOW_VIBRANCY, enabled),
98101

99102
/**
100103
* Sync the native window appearance (`nativeTheme.themeSource`) with the app's
101104
* color mode, so the macOS vibrancy material renders light/dark to match —
102105
* otherwise dark Glass gets a light material and its light text washes out.
106+
*
107+
* @param source - The native appearance to apply.
103108
*/
104109
setNativeTheme: (source: NativeThemeSource) => invokeMainEvent(EVENTS.SET_NATIVE_THEME, source),
105110

@@ -136,6 +141,7 @@ export const api = {
136141
/**
137142
* Set the idle tray icon appearance independently of the app theme.
138143
*
144+
* @param value - The idle icon appearance to use.
139145
*/
140146
setAppearance: (value: TrayIconAppearance) =>
141147
sendMainEvent(EVENTS.SET_TRAY_ICON_APPEARANCE, value),

‎src/renderer/utils/system/comms.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function openExternalLink(url: Link): void {
2727
/**
2828
* Returns the current application version string.
2929
*
30-
* @returns Promise resolving to the app version (e.g. `"6.18.0"`).
30+
* @returns The version prefixed with `v`, or `dev` in development.
3131
*/
3232
export async function getAppVersion(): Promise<string> {
3333
return await window.gitify.app.version();
@@ -46,11 +46,9 @@ export async function encryptValue(value: string): Promise<string> {
4646
/**
4747
* Decrypts a previously encrypted string using the native Electron decryption bridge.
4848
*
49-
* Resolves to the decrypted token. When the OS keychain rotated keys during
50-
* decryption, `reEncryptedToken` is also set so callers can persist the new
51-
* ciphertext alongside or in place of the original.
52-
*
5349
* @param value - The encrypted string to decrypt.
50+
* @returns The decrypted token and, when the OS keychain rotated keys, the
51+
* re-encrypted ciphertext to persist.
5452
*/
5553
export async function decryptValue(value: string): Promise<ISafeStorageDecryptResult> {
5654
return await window.gitify.decryptValue(value);
@@ -59,8 +57,8 @@ export async function decryptValue(value: string): Promise<ISafeStorageDecryptRe
5957
/**
6058
* Asks the locally installed GitHub CLI for the token it holds for a host.
6159
*
62-
* @param hostname The host to read the token for.
63-
* @returns The token, or the reason the CLI could not supply one.
60+
* @param hostname - The host to read the token for.
61+
* @returns The CLI token, or a classified failure with an optional detail line.
6462
*/
6563
export async function readGitHubCliToken(hostname: string): Promise<IGitHubCliTokenResult> {
6664
return await window.gitify.githubCliToken(hostname);

0 commit comments

Comments
 (0)