Skip to content

Commit c7f2f71

Browse files
authored
Merge pull request #326 from bearsunday/apidoc-manual
docs: update apidoc manual for init command
2 parents 48df543 + f44c3f8 commit c7f2f71

File tree

2 files changed

+110
-6
lines changed

2 files changed

+110
-6
lines changed

manuals/1.0/en/apidoc.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,56 @@ Your application is the documentation.
2323

2424
```bash
2525
composer require bear/api-doc --dev
26-
cp vendor/bear/api-doc/apidoc.xml.dist apidoc.xml
26+
./vendor/bin/apidoc init
27+
```
28+
29+
The `init` command generates `apidoc.xml` from your `composer.json`. Edit it to customize.
30+
31+
```xml
32+
<apidoc>
33+
<appName>MyVendor\MyProject</appName> <!-- Application namespace -->
34+
<scheme>app</scheme> <!-- app or page -->
35+
<docDir>docs/api</docDir>
36+
<format>html</format> <!-- html, html,openapi, etc. -->
37+
</apidoc>
38+
```
39+
40+
The `format` accepts comma-separated values: `html`, `md`, `openapi`.
41+
42+
## Usage
43+
44+
Generate documentation from the command line.
45+
46+
```bash
47+
./vendor/bin/apidoc -capidoc.xml
48+
```
49+
50+
### OpenAPI HTML Generation
51+
52+
When `openapi` format is specified, `openapi.json` is generated. Use Redocly CLI to convert it to HTML.
53+
54+
```bash
55+
npm install -g @redocly/cli
56+
redocly build-docs docs/api/openapi/openapi.json -o docs/api/openapi/index.html
57+
```
58+
59+
### Composer Scripts
60+
61+
Add scripts to `composer.json` for convenience.
62+
63+
```json
64+
{
65+
"scripts": {
66+
"docs": "./vendor/bin/apidoc"
67+
},
68+
"scripts-descriptions": {
69+
"docs": "Generate API documentation"
70+
}
71+
}
72+
```
73+
74+
```bash
75+
composer docs
2776
```
2877

2978
## GitHub Actions
@@ -98,7 +147,7 @@ docs/
98147

99148
## Profile
100149

101-
[ALPS](http://alps.io/) profile defines your API vocabulary. Centralized definitions prevent inconsistencies and aid shared understanding.
150+
ALPS profile defines your API vocabulary. Centralized definitions prevent inconsistencies and aid shared understanding.
102151

103152
```json
104153
{
@@ -118,4 +167,7 @@ Code is the single source of truth. Documentation generated from your applicatio
118167

119168
## Reference
120169

121-
- [ALPS](https://www.app-state-diagram.com/manuals/1.0/en/)
170+
- [BEAR.ApiDoc](https://github.com/bearsunday/BEAR.ApiDoc) - API documentation generator
171+
- [ALPS](https://www.app-state-diagram.com/manuals/1.0/en/) - Application-Level Profile Semantics
172+
- [JSON Schema](https://json-schema.org/) - Data validation and documentation
173+
- [Redocly CLI](https://redocly.com/docs/cli/installation/) - OpenAPI to HTML conversion

manuals/1.0/ja/apidoc.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,56 @@ permalink: /manuals/1.0/ja/apidoc.html
2323

2424
```bash
2525
composer require bear/api-doc --dev
26-
cp vendor/bear/api-doc/apidoc.xml.dist apidoc.xml
26+
./vendor/bin/apidoc init
27+
```
28+
29+
`init`コマンドは`composer.json`から`apidoc.xml`を生成します。必要に応じて編集してください。
30+
31+
```xml
32+
<apidoc>
33+
<appName>MyVendor\MyProject</appName> <!-- アプリケーションの名前空間 -->
34+
<scheme>app</scheme> <!-- app または page -->
35+
<docDir>docs/api</docDir>
36+
<format>html</format> <!-- html, html,openapi など -->
37+
</apidoc>
38+
```
39+
40+
`format`には`html``md``openapi`をカンマ区切りで指定できます。
41+
42+
## 使い方
43+
44+
コマンドラインからドキュメントを生成します。
45+
46+
```bash
47+
./vendor/bin/apidoc -capidoc.xml
48+
```
49+
50+
### OpenAPI HTML生成
51+
52+
`openapi`形式を指定すると`openapi.json`が生成されます。これをHTMLに変換するにはRedocly CLIを使用します。
53+
54+
```bash
55+
npm install -g @redocly/cli
56+
redocly build-docs docs/api/openapi/openapi.json -o docs/api/openapi/index.html
57+
```
58+
59+
### Composerスクリプト
60+
61+
`composer.json`にスクリプトを追加すると便利です。
62+
63+
```json
64+
{
65+
"scripts": {
66+
"docs": "./vendor/bin/apidoc"
67+
},
68+
"scripts-descriptions": {
69+
"docs": "Generate API documentation"
70+
}
71+
}
72+
```
73+
74+
```bash
75+
composer docs
2776
```
2877

2978
## GitHub Actions
@@ -98,7 +147,7 @@ docs/
98147

99148
## プロファイル
100149

101-
[ALPS](http://alps.io/)プロファイルはAPIの語彙を定義します。定義を集中させることで表記揺れを防ぎ、理解共有を助けます。
150+
ALPSプロファイルはAPIの語彙を定義します。定義を集中させることで表記揺れを防ぎ、理解共有を助けます。
102151

103152
```json
104153
{
@@ -118,4 +167,7 @@ docs/
118167

119168
## リファレンス
120169

121-
- [ALPS](https://www.app-state-diagram.com/manuals/1.0/ja/)
170+
- [BEAR.ApiDoc](https://github.com/bearsunday/BEAR.ApiDoc) - APIドキュメント生成ツール
171+
- [ALPS](https://www.app-state-diagram.com/manuals/1.0/ja/) - Application-Level Profile Semantics
172+
- [JSON Schema](https://json-schema.org/) - データ検証とドキュメンテーション
173+
- [Redocly CLI](https://redocly.com/docs/cli/installation/) - OpenAPIからHTMLへの変換

0 commit comments

Comments
 (0)