feat(api-docs): 확장 API 레퍼런스 발견성 — README 목차 규약 + 동적 스캔 인덱스

확장 API 문서가 인덱스·목차 어디에도 노출되지 않아 처음 온 개발자/AI 가
발견할 수 없던 간극을 해소했다. 코어에 확장명을 하드코딩하지 않고(동적 로딩 원칙),
파일 시스템 패턴 스캔 + 확장 소유 목차 규약으로 발견성을 확보한다.

- ApiDocScaffolder::readmeIndex — 각 대상의 docs/api/README.md 목차(도메인 파일·
 엔드포인트 수)를 @generated 블록으로 생성(멱등, 사람 개요 보존). 커맨드가 대상별
 README 를 방출(readmeFile 경로 헬퍼). 코어 + 9 확장 = 10개 목차 생성.
- generate-docs-index.cjs scanExtensionApiReadmes — {modules,plugins}/_bundled/*/
 docs/api/README.md 를 패턴 스캔(확장명 하드코딩 0)해 ·AGENTS.md 에
 "확장 API 레퍼런스" 표로 자동 편입. 확장 추가/삭제 시 재생성만으로 반영.
- api-documentation.md 에 README 목차 규약 + 발견 경로 명문화. coverage.json 에
 api-doc-readme-index(manual-only) 등록. 루트 README API 레퍼런스 링크 갱신.

테스트: readmeIndex 목차 생성·멱등 2건 + 스캐너 편입·하드코딩부재 2건(node --test).
This commit is contained in:
HeuJung committed 2026-07-08 18:22:35 +09:00
1 parent 56a78e1d55
commit 168f439be3
15 files changed
+401

No files matched your search

+43
View File
@@ -128,11 +128,26 @@ class ApiDocgenCommand extends Command
$checkFindings = [];
$examplesOnly = (bool) $this->option('examples-only');
// 대상(코어/확장)별 README 목차 항목 누적: readmeKey => ['label' => ..., 'entries' => [...]]
$readmeIndex = [];
foreach ($grouped as $file => $items) {
$sections = [];
$sectionKeys = [];
$exampleBlocks = [];
// 목차용 도메인 파일 항목 (소유별). 예시-only/check 모드에서도 목차는 최신화한다.
$owner = $items[0]['owner'];
$readmeKey = $this->readmeFile($owner);
$readmeIndex[$readmeKey]['label'] = $owner['type'] === 'core'
? '코어'
: ($owner['type'] === 'module' ? '모듈' : '플러그인')." `{$owner['id']}`";
$readmeIndex[$readmeKey]['entries'][] = [
'domain' => $items[0]['domain_group'],
'file' => basename($file),
'count' => count($items),
];
foreach ($items as $route) {
$request = $introspector->introspect($route['controller'], $route['controller_method']);
[$schema, $probeMeta] = $this->probeEndpoint($probe, $inferrer, $route, $probed, $sampleMap, $request);
@@ -210,6 +225,17 @@ class ApiDocgenCommand extends Command
$probe->cleanup();
// 대상별 API 문서 목차(README.md) 생성/갱신 — 확장 API 레퍼런스 발견성의 규약 진입점.
// check/dry-run 은 파일을 쓰지 않으므로 제외. examples-only 는 목차도 최신화한다.
if (! $this->option('check')) {
foreach ($readmeIndex as $readmePath => $meta) {
$existing = File::exists($readmePath) ? File::get($readmePath) : null;
$content = $scaffolder->readmeIndex($meta['label'], $meta['entries'], $existing);
File::ensureDirectoryExists(dirname($readmePath));
File::put($readmePath, $content);
}
}
if ($this->option('check')) {
if ($checkFindings !== []) {
$this->warn('실측 제외/문서 누락 '.count($checkFindings).'건:');
@@ -790,6 +816,23 @@ class ApiDocgenCommand extends Command
return base_path("{$base}/_bundled/{$owner['id']}/docs/api/{$domain}.md");
}
/**
* 소유 대상의 API 문서 목차(README.md) 경로를 반환합니다.
*
* @param array{type: string, id: string|null} $owner 소유 메타
* @return string README.md 절대 경로
*/
private function readmeFile(array $owner): string
{
if ($owner['type'] === 'core') {
return base_path('docs/backend/api/README.md');
}
$base = $owner['type'] === 'module' ? 'modules' : 'plugins';
return base_path("{$base}/_bundled/{$owner['id']}/docs/api/README.md");
}
/**
* 문서 헤더(제목 + TL;DR)를 생성합니다.
*