Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: docs パッケージのソースコードにドキュメントを追加 #1109

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/docs/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ディレクトリ構成

- `atoms/`: 単体では特定の意味を表せないコンポーネント
- `molecules/`: 単体で意味を持ちページ内に自由に配置できるコンポーネント
- `organisms/`: 単体でページ内の特定の区分を構成できるコンポーネント
- `pages/`: MDX によるページの定義
3 changes: 3 additions & 0 deletions packages/docs/src/atoms/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export interface BadgeProps {
children: ReactNode;
}

/**
* 文字を入れて使う丸角のバッジ
*/
export const Badge = ({ children }: BadgeProps): JSX.Element => {
return <span className={style.badge}>{children}</span>;
};
18 changes: 18 additions & 0 deletions packages/docs/src/molecules/command-arg-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ import { ReactNode } from 'react';
import style from './command-arg-list.module.css';
import { VersionBadge } from './version-badge';

/**
* コマンド引数の定義
*/
export interface CommandArg {
/**
* 引数名
*/
name: string;
/**
* 説明に用いる要素
*/
about: ReactNode;
/**
* その引数がはじめて利用可能になったバージョン
*/
versionAvailableFrom?: string;
/**
* その引数が未指定だったときの既定値
*/
defaultValue?: ReactNode;
}

Expand Down Expand Up @@ -35,6 +50,9 @@ const CommandArgListItem = ({
</>
);

/**
* コマンド引数リスト
*/
export const CommandArgList = ({
args
}: {
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/src/molecules/command-format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export interface CommandFormatProps {
children: string;
}

/**
* コマンドの入力形式を表す等幅フォントのテキスト
*/
export const CommandFormat = ({
children
}: CommandFormatProps): JSX.Element => (
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/src/molecules/feature-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export interface FeatureProps {
children: React.ReactNode;
}

/**
* 特定の feature の有効化が必要であることを表す水色のバッジ
*/
export const FeatureBadge = ({ children }: FeatureProps): JSX.Element => {
return (
<span className={style.feature}>
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/src/molecules/version-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export interface VersionProps {
children: React.ReactNode;
}

/**
* OreOreBot2 の特定のバージョンを表す緑色のバッジ
*/
export const VersionBadge = ({ children }: VersionProps): JSX.Element => {
return (
<span className={style.version}>
Expand Down
22 changes: 22 additions & 0 deletions packages/docs/src/organisms/command-args.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@ import { CommandArg, CommandArgList } from '../molecules/command-arg-list';
import { CommandFormat } from '../molecules/command-format';
import { VersionBadge } from '../molecules/version-badge';

/**
* コマンドを説明するための情報の定義
*/
export interface CommandArgsProps {
/**
* コマンドがはじめて利用可能になったバージョン
*/
versionAvailableFrom: string;
/**
* コマンド名
*/
commandName: string;
/**
* コマンドの引数の定義
*/
args?: readonly CommandArg[];
}

/**
* コマンドを入力する時の形式の文字列を構築します。
*
* @param commandName - コマンド名
* @param args - 引数の定義
* @returns コマンドの入力形式
*/
export const buildCommandFormat = (
commandName: string,
args?: readonly CommandArg[]
Expand All @@ -28,6 +47,9 @@ export const buildCommandFormat = (
return formatted;
};

/**
* コマンドとその引数の説明の章節
*/
export const CommandArgs = ({
versionAvailableFrom,
commandName,
Expand Down