Skip to content

Commit 8b96831

Browse files
docs: improve documentation formatting and type references
- Add {@linkcode} tags for type references - Use backticks for code references - Add blockquote syntax for notes - Improve documentation consistency across files
1 parent 8734f1f commit 8b96831

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

browser/dom/_internal.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Encodes `AddEventListenerOptions` into a number for equality comparison.
2+
* Encodes {@linkcode AddEventListenerOptions} into a number for equality comparison.
33
* This function converts the options object into a single number where each bit
44
* represents a specific option (capture, once, passive).
55
*/
@@ -16,16 +16,16 @@ export const encode = (
1616
);
1717
};
1818
/**
19-
* Decodes a number back into `AddEventListenerOptions` object.
19+
* Decodes a number back into {@linkcode AddEventListenerOptions} object.
2020
* Each bit in the encoded number represents a specific option:
2121
*
2222
* - `capture`: `0b001` (bit 0)
2323
* - `once`: `0b010` (bit 1)
2424
* - `passive`: `0b100` (bit 2)
2525
* - `0`: returns `undefined`
2626
*
27-
* @param encoded The number containing encoded `AddEventListenerOptions` flags
28-
* @returns An `AddEventListenerOptions` object or `undefined` if encoded value is 0
27+
* @param encoded The number containing encoded {@linkcode AddEventListenerOptions} flags
28+
* @returns An {@linkcode AddEventListenerOptions} object or `undefined` if encoded value is 0
2929
*/
3030
export const decode = (
3131
encoded: number,

browser/dom/cache.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
*
33
* This function searches through the cache storage in reverse chronological order
44
* to find the most recent cached response for a given request.
5-
* Implementation inspired by Scrapbox's ServiceWorker and Cache usage pattern.
5+
*
6+
* > [!Note]
7+
* > Implementation inspired by Scrapbox's ServiceWorker and Cache usage pattern.
68
*
79
* @param request The request to find a cached response for
810
* @param options Cache query options (e.g., to ignore search params)
@@ -46,7 +48,8 @@ export const generateCacheName = (date: Date): string =>
4648
* 1. `"prefetch"` cache - temporary storage, cleared after first use
4749
* 2. `"api-yyyy-MM-dd"` cache - date-based persistent storage
4850
*
49-
* Note: Throws an exception if the network connection is slow
51+
* > [!Note]
52+
* > Throws an exception if the network connection is slow
5053
*
5154
* @param urls List of API URLs to prefetch
5255
*/

browser/dom/caret.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import { textInput } from "./dom.ts";
22

3-
/** Position information within the editor */
3+
/** Position information within the editor
4+
*
5+
* @see {@linkcode Range} for selection range information
6+
*/
47
export interface Position {
58
/** Line number (1-based) */ line: number;
69
/** Character offset within the line (0-based) */ char: number;
710
}
811

912
/** Represents a text selection range in the editor
1013
*
11-
* When no text is selected, start and end positions are the same (cursor position)
14+
* When no text is selected, {@linkcode start} and {@linkcode end} positions are the same (cursor position)
15+
*
16+
* @see {@linkcode Position} for position type details
1217
*/
1318
export interface Range {
1419
/** Starting position of the selection */ start: Position;
1520
/** Ending position of the selection */ end: Position;
1621
}
1722

18-
/** Cursor information contained within the React Component that builds #text-input */
23+
/** Cursor information contained within the React Component that builds `#text-input` */
1924
export interface CaretInfo {
2025
/** Current cursor position */ position: Position;
2126
/** Currently selected text */ selectedText: string;
@@ -35,7 +40,8 @@ interface ReactFiber {
3540
/** Retrieves the current cursor position and text selection information
3641
*
3742
* @return Information about cursor position and text selection
38-
* @throws {Error} When #text-input element or React Component's internal properties are not found
43+
* @throws {Error} When `#text-input` element or React Component's internal properties are not found
44+
* @see {@linkcode CaretInfo} for return type details
3945
*/
4046
export const caret = (): CaretInfo => {
4147
const textarea = textInput();

browser/dom/cursor.d.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export interface SetPositionOptions {
1616
source?: "mouse";
1717
}
1818

19-
/** Class for managing cursor operations in the Scrapbox editor */
19+
/** Class for managing cursor operations in the Scrapbox editor
20+
*
21+
* @see {@linkcode Position} for cursor position type details
22+
* @see {@linkcode Page} for page data type details
23+
*/
2024
export declare class Cursor extends BaseStore<
2125
{ source: "mouse" | undefined } | "focusTextInput" | "scroll" | undefined
2226
> {
@@ -45,19 +49,19 @@ export declare class Cursor extends BaseStore<
4549
/** Hide the editor's popup menu */
4650
hidePopupMenu(): void;
4751

48-
/** Focus the cursor on #text-input and make it visible
52+
/** Focus the cursor on `#text-input` and make it visible
4953
*
5054
* This action triggers the `event: "focusTextInput"` event
5155
*/
5256
focus(): void;
5357

54-
/** Check if #text-input has focus
58+
/** Check if `#text-input` has focus
5559
*
5660
* Returns the same value as `this.focusTextarea`
5761
*/
5862
get hasFocus(): boolean;
5963

60-
/** Remove focus from #text-input without changing cursor visibility */
64+
/** Remove focus from `#text-input` without changing cursor visibility */
6165
blur(): void;
6266

6367
/** Adjust cursor position to stay within valid line and column boundaries */
@@ -71,13 +75,13 @@ export declare class Cursor extends BaseStore<
7175

7276
/** Make the cursor visible
7377
*
74-
* Does not change the focus state of #text-input
78+
* Does not change the focus state of `#text-input`
7579
*/
7680
show(): void;
7781

7882
/** Hide the cursor
7983
*
80-
* On touch devices, this also removes focus from #text-input
84+
* On touch devices, this also removes focus from `#text-input`
8185
*/
8286
hide(): void;
8387

0 commit comments

Comments
 (0)