ApiGen 透過命令列參數或 apigen.neon 配置檔控制生成行為。下表彙整所有可用選項,便於快速查閱。
| 選項 | 縮寫 | 說明 | 預設值/備註 |
|---|---|---|---|
--source | -s | 原始碼目錄 (可多值,必填) | 無 |
--destination | -d | 文件輸出目錄 (必填) | 無 |
--access-levels | 文件化的可見性層級 | "public","protected" (可多值) | |
--base-url | 文件站點根路徑 | 空 | |
--config | 自定義 Neon 配置檔路徑 | 空 | |
--google-cse-id | Google 自訂搜尋引擎 ID (搜尋框用) | 空 | |
--google-analytics | Google Analytics 追蹤碼 | 空 | |
--debug | 啟用除錯模式 | 關閉 | |
--deprecated | 包含 @deprecated 標記內容 | 關閉 | |
--download | 提供 ZIP 打包下載連結 | 關閉 | |
--extensions | 解析的副檔名列表 | "php" (可多值) | |
--exclude | 排除解析的路徑模式 (可多值) | 空 | |
--groups | 側邊欄分組策略 | "auto" | |
--charset | 原始碼字元編碼 (可多值) | UTF-8 | |
--main | 主要專案名稱前綴 | 空 | |
--internal | 包含 @internal 標記 | 關閉 | |
--php | 生成 PHP 內建類別文件 | 關閉 | |
--skip-doc-path | 類別樹顯示但不生成詳細文件的路徑 (可多值) | 空 | |
--no-source-code | 不高亮原始碼標記 | 關閉 | |
--template-theme | 模板主題名稱 | "default" | |
--template-config | 模板配置檔 | 空 | |
--title | 文件標題 | 專案目錄名 | |
--todo | 包含 @todo 標記生成任務清單 | 關閉 | |
--tree | 生成類別/介面/Traits/例外的樹狀目錄 | 關閉 | |
--help | -h | 顯示說明 | - |
--quiet | -q | 靜默模式,無輸出 | - |
--version | -V | 顯示版本號 | - |
# 基礎生成
apigen generate -s src -d docs/api --title "My API"
# 生產級配置
apigen generate \
-s src -d docs/api \
--access-levels public protected private \
--exclude "*/tests/*" "*/vendor/*" \
--extensions php php8 \
--template-theme bootstrap \
--title "Official API Docs" \
--google-analytics UA-XXXXX-Y \
--tree --todo --deprecated \
--charset UTF-8
source: [src, lib]
destination: docs/api
accessLevels: [public, protected]
exclude: ['*/tests/*', '*/vendor/*']
extensions: [php]
templateTheme: default
title: "Project API"
tree: true
todo: true
執行 apigen generate --config apigen.neon 即可套用。