DocsCommand

Class
extends BaseCommand
Final: Yes

Generates the package API documentation through phpDocumentor.

Description

The command prepares a temporary phpDocumentor configuration from the current package metadata, then delegates execution to the shared process queue so logging and grouped output stay consistent with the rest of the command surface.

Attributes
#[AsCommand]
$name : 'docs'
$description : 'Generates API documentation.'
$help : 'This command generates API documentation using phpDocumentor.'

Table of Contents

Interfaces

LoggerAwareCommandInterface

Defines the logger contract consumed by reusable command result helpers.

Properties

Methods

__construct()

Creates a new DocsCommand instance.

 : mixed
addJsonOption()

Adds the standard JSON output options to the current command.

 : static
configure()

Configures the command options used to generate API documentation.

 : void
execute()

Generates the HTML API documentation for the configured source tree.

 : int
isJsonOutput()

Determines whether JSON output was requested.

 : bool
isPrettyJsonOutput()

Determines whether pretty JSON output was requested.

 : bool
createPhpDocumentorConfig()

Creates a temporary phpDocumentor configuration for the current project.

 : string
failure()

Logs a failed command result and returns the failure exit code.

 : int
notice()

Logs an informational command message at notice level.

 : void
success()

Logs a successful command result and returns the success exit code.

 : int
Properties

$logger

Private Read-only
private LoggerInterface $logger

$renderer

Private Read-only
private Environment $renderer
Methods

__construct()

Public

Creates a new DocsCommand instance.

public __construct(ProcessBuilderInterface  $processBuilder, ProcessQueueInterface  $processQueue, Environment  $renderer, FilesystemInterface  $filesystem, ComposerJsonInterface  $composer, LoggerInterface  $logger) : mixed
Parameters
$processBuilder : ProcessBuilderInterface

Description

the process builder for executing phpDocumentor

$processQueue : ProcessQueueInterface

Description

the process queue for managing execution

$renderer : Environment
$filesystem : FilesystemInterface

Description

the filesystem for handling file operations

$composer : ComposerJsonInterface

Description

the composer.json handler for accessing project metadata

$logger : LoggerInterface

Description

the output-aware logger

addJsonOption()

Protected

Adds the standard JSON output options to the current command.

protected addJsonOption() : static
Return values
static

configure()

Protected

Configures the command options used to generate API documentation.

protected configure() : void

execute()

Protected

Generates the HTML API documentation for the configured source tree.

protected execute(InputInterface  $input, OutputInterface  $output) : int
Parameters
$input : InputInterface

Description

the input details for the command

$output : OutputInterface

Description

the output mechanism for logging

Return values
int

Description

the final execution status code

isJsonOutput()

Protected

Determines whether JSON output was requested.

protected isJsonOutput(InputInterface  $input) : bool

Description

The pretty-json flag SHALL imply JSON output.

Parameters
$input : InputInterface
Return values
bool

isPrettyJsonOutput()

Protected

Determines whether pretty JSON output was requested.

protected isPrettyJsonOutput(InputInterface  $input) : bool
Parameters
$input : InputInterface
Return values
bool

createPhpDocumentorConfig()

Private

Creates a temporary phpDocumentor configuration for the current project.

private createPhpDocumentorConfig( string  $source, string  $target, string  $template, string  $cacheDir) : string
Parameters
$source : string

Description

the source directory for the generated documentation

$target : string

Description

the output directory for the generated documentation

$template : string

Description

the phpDocumentor template name or path

$cacheDir : string

Description

the cache directory for phpDocumentor

Return values
string

Description

the absolute path to the generated configuration

failure()

Private

Logs a failed command result and returns the failure exit code.

private failure( string  $message, InputInterface  $input[, array<string, mixed>  $context = []][, string|null  $file = null][, int|null  $line = null]) : int
Parameters
$message : string

Description

the failure message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

$file : string|null = null

Description

the related file path when known

$line : int|null = null

Description

the related line when known

Return values
int

notice()

Private

Logs an informational command message at notice level.

private notice( string  $message, InputInterface  $input[, array<string, mixed>  $context = []]) : void
Parameters
$message : string

Description

the notice message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

success()

Private

Logs a successful command result and returns the success exit code.

private success( string  $message, InputInterface  $input[, array<string, mixed>  $context = []][, string  $logLevel = LogLevel::INFO]) : int
Parameters
$message : string

Description

the success message

$input : InputInterface

Description

the originating command input

$context : array<string, mixed> = []

Description

optional extra log context

$logLevel : string = LogLevel::INFO

Description

the PSR-3 log level used for the successful result

Return values
int