Skip to content

Commit c47aacc

Browse files
authored
Merge pull request #23 from takker99/jsdoc
Add JSDoc
2 parents 436e1ca + 2ff0660 commit c47aacc

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export interface Page {
1818
image: string | null;
1919
/** the thumbnail text of a page.
2020
* the maximum number of lines is 5.
21-
*/ descriptions: string[];
21+
*/
22+
descriptions: string[];
2223
/** ページの最終更新日時 */ updated: number;
2324
/** Date last visitedに使われる最終アクセス日時 */ accessed: number;
2425
}
@@ -36,6 +37,7 @@ export type ProjectId = string;
3637
/** the formatted string
3738
*
3839
* format rule:
40+
*
3941
* - UPPER CASE -> upper_case
4042
*/
4143
export type StringLc = string;

layout.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/** Scrapboxのページの種類を表す文字列から`"page"`を除いたもの
2+
*
3+
* | String | Description |
4+
* | ------ | ----------- |
5+
* | list | トップページと全文検索結果ページ |
6+
* | stream | streamページ |
7+
* | error-page | 何らかのエラーが発生したときに遷移するページ |
8+
* | new-project-page | 新規project作成ページ |
9+
* | invitation-page | projectに参加するときに出てくるページ |
10+
* | invitation-page | projectに参加するときに出てくるページ |
11+
* | settings-* | ユーザー設定ページ |
12+
* | project-settings-* | projectの設定ページ |
13+
*/
114
export type PartialLayout =
215
| "launch"
316
| "error-page"
@@ -28,4 +41,5 @@ export type PartialLayout =
2841
| "project-settings-upload-page"
2942
| "project-settings-billing-page";
3043

44+
/** Scrapboxのページの種類を表す文字列 */
3145
export type Layout = "page" | PartialLayout;

pageMenu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export declare class PageMenu extends BaseStore {
2525
public initialize(): void;
2626
public reset(): void;
2727
public pageMenu(menuName?: string): PageMenu;
28+
/** Add a new Page Menu button
29+
*
30+
* @param init information used for a Page Menu button
31+
*/
2832
public addMenu(init: AddMenuInit): void;
2933
/** Add a menu item to a particular Page Menu button
3034
*
@@ -33,6 +37,7 @@ export declare class PageMenu extends BaseStore {
3337
public addItem(item: Item): void;
3438
/** Add a separator to a particular Page Menu button */
3539
public addSeparator(): void;
40+
/** remove all custom items from a particular Page Menu button */
3641
public removeAllItems(): void;
3742

3843
public menuName: string;

userscript.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,71 @@ import type { EventEmitter } from "./deps/events.ts";
1111
export type { EventEmitter, Layout, ParsedLine, PartialLayout, StringLc };
1212
export * from "./pageMenu.ts";
1313

14+
/** Type definition of `window.scrapbox` */
1415
export type Scrapbox =
1516
& EventEmitter
1617
& {
1718
PageMenu: {
19+
/** get a particular Page Menu
20+
*
21+
* @param menuName Page Menu name to get. If it is set to "default" or undefined, return the default page Menu
22+
*/
1823
(menuName?: string): PageMenu;
24+
/** Add a new Page Menu button
25+
*
26+
* @param init information used for a Page Menu button
27+
*/
1928
addMenu: (init: AddMenuInit) => void;
20-
/** Add a menu item to a particular Page Menu button
29+
/** Add a menu item to the default Page Menu button
2130
*
2231
* @param item information used for a menu item
2332
*/
2433
addItem: (item: Item) => void;
25-
/** Add a separator to a particular Page Menu button */
34+
/** Add a separator to the default Page Menu button */
2635
addSeparater: () => void;
36+
/** remove all custom items from the default Page Menu button */
2737
removeAllItems: () => void;
2838
};
2939
PopupMenu: {
40+
/** Add a popup button
41+
*
42+
* @param button button settings
43+
*/
3044
addButton: (button: {
45+
/** ボタンのタイトル
46+
*
47+
* 関数を設定して、選択範囲が変わるたびにタイトルを変更させる事もできる
48+
*/
3149
title: string | ((text: string) => (string | undefined));
50+
/** ボタンをクリックしたときに実行する処理
51+
*
52+
* @return ここで返した文字列で選択範囲を置換し、popupを閉じる。`undefined`を返した場合は何もしない。popupも閉じない
53+
*/
3254
onClick: (text: string) => (string | undefined);
3355
}) => void;
3456
};
3557
TimeStamp: TimeStamp;
3658
Project: {
59+
/** get the current project name */
3760
get name(): string;
61+
/** get the dictionary used for comupletion */
3862
get pages(): PageBrief[];
3963
};
4064
}
4165
& (
4266
{
67+
/** the current page layout */
4368
Layout: "page";
4469
Page: {
70+
/** get the current page lines data */
4571
get lines(): ParsedLine[];
72+
/** get the current page title */
4673
get title(): string;
74+
/** get the current page id */
4775
get id(): string;
4876
};
4977
} | {
78+
/** the current page layout */
5079
Layout: PartialLayout;
5180
Page: {
5281
get lines(): null;
@@ -56,12 +85,13 @@ export type Scrapbox =
5685
}
5786
);
5887

88+
/** 入力補完に使われる辞書 */
5989
export interface PageBrief {
6090
/** true when the page has contents */ exists: boolean;
6191
/** whether the page contains any image */ hasIcon?: boolean;
6292
/** the page id */ id: string;
6393
/** the page title */ title: string;
64-
titleLc: StringLc;
94+
/** lower case style of the page title */ titleLc: StringLc;
6595
/** updated time */ updated: number;
6696
}
6797

0 commit comments

Comments
 (0)