WikiCommand

Class
extends Command
Final: Yes

Handles the generation of API documentation for the project.

Description

This class MUST NOT be extended and SHALL utilize phpDocumentor to accomplish its task.

Attributes
#[AsCommand]
$name : 'github:wiki'
$description : 'Generates API documentation in Markdown format.'
$aliases : ['.github/wiki', 'wiki']

Table of Contents

Constants

 = 'vendor/saggre/phpdocumentor-markdown/themes/markdown'

Properties

Methods

__construct()

Creates a new WikiCommand instance.

 : mixed
addCacheDirOption()

Adds the standard cache directory option to the current command.

 : static
addCacheOption()

Adds the standard cache control option to the current command.

 : static
addJsonOption()

Adds the standard JSON output options to the current command.

 : static
configure()

Configures the command instance.

 : void
execute()

Executes the generation of the documentation files in Markdown format.

 : int
isCacheEnabled()

Resolves whether cache writes SHOULD be enabled for the current invocation.

 : bool
isJsonOutput()

Determines whether JSON output was requested.

 : bool
isPrettyJsonOutput()

Determines whether pretty JSON output was requested.

 : bool
resolveCacheArgument()

Returns the explicit cache flag that SHOULD be forwarded to nested commands.

 : string|null
resolveCacheDirArgument()

Resolves a nested cache directory for a child command.

 : string|null
failure()

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

 : int
getGitRepositoryUrl()

Resolves the current repository remote origin URL.

 : string
hasExplicitCacheDirArgument()

Determines whether the current invocation explicitly passed `--cache-dir`.

 : bool
initializeWikiSubmodule()

Adds the repository wiki as a Git submodule when the target path is missing.

 : int
isDefaultWikiTarget()

Detects whether a target option still points at the default wiki target path.

 : bool
isImplicitJsonOutputEnabled()

Determines whether structured JSON output SHOULD be enabled implicitly.

 : bool
isNoCacheRequested()

Determines whether cache writes were explicitly disabled for the current invocation.

 : bool
isOptionEnabled()

Determines whether a boolean input option was enabled.

 : bool
log()

Logs a non-terminal command message unless structured JSON output is active.

 : void
normalizeProjectRelativePath()

Normalizes a project-relative path for resilient default-option comparisons.

 : string
success()

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

 : int
Constants

Constants

DEFAULT_TEMPLATE

Private
private string DEFAULT_TEMPLATE = 'vendor/saggre/phpdocumentor-markdown/themes/markdown'

Description

the default phpDocumentor Markdown template path relative to the consumer project

Properties
Methods

__construct()

Public

Creates a new WikiCommand instance.

public __construct(ProcessBuilderInterface  $processBuilder, ProcessQueueInterface  $processQueue, ComposerJsonInterface  $composer, FilesystemInterface  $filesystem, GitClientInterface  $gitClient, ProjectCapabilitiesResolverInterface  $projectCapabilitiesResolver) : mixed
Parameters
$processBuilder : ProcessBuilderInterface
$processQueue : ProcessQueueInterface
$composer : ComposerJsonInterface

Description

the composer.json accessor

$filesystem : FilesystemInterface

Description

the filesystem used to inspect the wiki target

$gitClient : GitClientInterface
$projectCapabilitiesResolver : ProjectCapabilitiesResolverInterface

Description

the project capability resolver

addCacheDirOption()

Protected

Adds the standard cache directory option to the current command.

protected addCacheDirOption( string  $description, string  $default) : static
Parameters
$description : string

Description

the cache directory option description

$default : string

Description

the command-specific default cache directory

Return values
static

addCacheOption()

Protected

Adds the standard cache control option to the current command.

protected addCacheOption( string  $description) : static
Parameters
$description : string

Description

the cache option description

Return values
static

addJsonOption()

Protected

Adds the standard JSON output options to the current command.

protected addJsonOption() : static
Return values
static

configure()

Protected

Configures the command instance.

protected configure() : void

Description

The method MUST set up the name and description. It MAY accept an optional --target option pointing to an alternative configuration target path.

execute()

Protected

Executes the generation of the documentation files in Markdown format.

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

Description

This method MUST compile arguments based on PSR-4 namespaces to feed into phpDocumentor. It SHOULD provide feedback on generation progress, and SHALL return self::SUCCESS on success.

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

isCacheEnabled()

Protected

Resolves whether cache writes SHOULD be enabled for the current invocation.

protected isCacheEnabled(InputInterface  $input[, bool  $default = true]) : bool
Parameters
$input : InputInterface

Description

the current command input

$default : bool = true

Description

the command-specific default cache behavior when the option is omitted

Return values
bool

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

resolveCacheArgument()

Protected

Returns the explicit cache flag that SHOULD be forwarded to nested commands.

protected resolveCacheArgument(InputInterface  $input) : string|null
Parameters
$input : InputInterface

Description

the current command input

Return values
string|null

resolveCacheDirArgument()

Protected

Resolves a nested cache directory for a child command.

protected resolveCacheDirArgument(InputInterface  $input[, string  $path = '']) : string|null
Parameters
$input : InputInterface

Description

the current command input

$path : string = ''

Description

the child cache path relative to the current command cache root

Return values
string|null

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

getGitRepositoryUrl()

Private

Resolves the current repository remote origin URL.

private getGitRepositoryUrl() : string
Return values
string

Description

the Git remote origin URL

hasExplicitCacheDirArgument()

Private

Determines whether the current invocation explicitly passed `--cache-dir`.

private hasExplicitCacheDirArgument(InputInterface  $input) : bool
Parameters
$input : InputInterface

Description

the current command input

Return values
bool

initializeWikiSubmodule()

Private

Adds the repository wiki as a Git submodule when the target path is missing.

private initializeWikiSubmodule(InputInterface  $input, string  $target, OutputInterface  $output) : int
Parameters
$input : InputInterface
$target : string

Description

the configured wiki target path

$output : OutputInterface

Description

the output used for process feedback

Return values
int

Description

the command status code

isDefaultWikiTarget()

Private

Detects whether a target option still points at the default wiki target path.

private isDefaultWikiTarget( string  $target) : bool
Parameters
$target : string

Description

the wiki target option received from the CLI

Return values
bool

Description

true when the provided path is equivalent to the default wiki target

isImplicitJsonOutputEnabled()

Private

Determines whether structured JSON output SHOULD be enabled implicitly.

private isImplicitJsonOutputEnabled() : bool

Description

Commands MAY opt into runtime-environment-aware behavior by exposing a $runtimeEnvironment property. Commands that do not expose it SHALL fall back to the shared runtime-environment service from the DevTools container.

Return values
bool

isNoCacheRequested()

Private

Determines whether cache writes were explicitly disabled for the current invocation.

private isNoCacheRequested(InputInterface  $input) : bool

Description

The Composer application already provides a global --no-cache flag, so commands SHALL reuse that switch instead of redefining a local negated variant.

Parameters
$input : InputInterface

Description

the current command input

Return values
bool

isOptionEnabled()

Private

Determines whether a boolean input option was enabled.

private isOptionEnabled(InputInterface  $input, string  $option) : bool
Parameters
$input : InputInterface
$option : string
Return values
bool

log()

Private

Logs a non-terminal command message unless structured JSON output is active.

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

Description

the progress 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 message

normalizeProjectRelativePath()

Private

Normalizes a project-relative path for resilient default-option comparisons.

private normalizeProjectRelativePath( string  $path) : string
Parameters
$path : string

Description

the project-relative path to normalize

Return values
string

Description

the normalized project-relative path

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