#!/usr/bin/env php
<?php

runGenerator('api-minimal');
runGenerator('api-full');

function runGenerator($type)
{
	$projectRoot = realpath(__DIR__ . '/../');

	$apigenOutputDir = "$projectRoot/docs/$type";
	$apigenExecutable = "$projectRoot/vendor/bin/apigen";

	$apigenArgs = [
		'generate',
		"--source $projectRoot/src",
		"--destination $apigenOutputDir",
		"--template-theme bootstrap",
		"--quiet",
	];

	if ($type === 'api-minimal')
	{
		$apigenArgs = array_merge($apigenArgs, [
			"--skip-doc-path '$projectRoot/src/Helpers/*'",
			"--skip-doc-path '$projectRoot/src/Mappers/*'",
			"--skip-doc-path '$projectRoot/src/Nodes/*'",
			"--skip-doc-path '$projectRoot/src/Visitors/*'",
		]);
	}

	$apigenArgs = implode(' ', $apigenArgs);

	if (file_exists($apigenOutputDir))
	{
		echo `rm -R $apigenOutputDir`;
	}

	echo `$apigenExecutable $apigenArgs`;
}