Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/shared_c.cache

Large diffs are not rendered by default.

1,384 changes: 1,384 additions & 0 deletions docs/tech/classes/ConfigurationCommand.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/tech/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Directory layout ( only documented files shown ):
│ │ │ ├── <a href='/docs/tech/classes/AddMissingDocBlocksCommand.md'>AddMissingDocBlocksCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
│ │ │ ├── <a href='/docs/tech/classes/AdditionalCommandCollection.md'>AdditionalCommandCollection.php</a>
│ │ │ ├── <a href='/docs/tech/classes/BaseCommand.md'>BaseCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
│ │ │ ├── <a href='/docs/tech/classes/ConfigurationCommand.md'>ConfigurationCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
│ │ │ ├── <a href='/docs/tech/classes/FillInReadmeMdTemplateCommand.md'>FillInReadmeMdTemplateCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
│ │ │ ├── <a href='/docs/tech/classes/GenerateCommand.md'>GenerateCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
│ │ │ └── <a href='/docs/tech/classes/GenerateProjectTemplatesStructureCommand.md'>GenerateProjectTemplatesStructureCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
Expand Down Expand Up @@ -248,4 +249,4 @@ Directory layout ( only documented files shown ):

<div id='page_committer_info'>
<hr>
<b>Last page committer:</b> fshcherbanich &lt;filipp.shcherbanich@team.bumble.com&gt;<br><b>Last modified date:</b> Sat Sep 2 21:01:47 2023 +0300<br><b>Page content update date:</b> Mon Oct 16 2023<br>Made with <a href='https://github.com/bumble-tech/bumble-doc-gen/blob/master/docs/README.md'>Bumble Documentation Generator</a></div>
<b>Last page committer:</b> fshcherbanich &lt;filipp.shcherbanich@team.bumble.com&gt;<br><b>Last modified date:</b> Sat Sep 2 21:01:47 2023 +0300<br><b>Page content update date:</b> Wed Oct 25 2023<br>Made with <a href='https://github.com/bumble-tech/bumble-doc-gen/blob/master/docs/README.md'>Bumble Documentation Generator</a></div>
2 changes: 2 additions & 0 deletions src/Console/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace BumbleDocGen\Console;

use BumbleDocGen\Console\Command\AddMissingDocBlocksCommand;
use BumbleDocGen\Console\Command\ConfigurationCommand;
use BumbleDocGen\Console\Command\FillInReadmeMdTemplateCommand;
use BumbleDocGen\Console\Command\GenerateCommand;
use BumbleDocGen\Console\Command\GenerateProjectTemplatesStructureCommand;
Expand Down Expand Up @@ -36,6 +37,7 @@ public function __construct()
$this->add(new FillInReadmeMdTemplateCommand());
$this->add(new AddMissingDocBlocksCommand());
$this->add(new GenerateProjectTemplatesStructureCommand());
$this->add(new ConfigurationCommand());
$this->setExtraCommands();
}

Expand Down
37 changes: 37 additions & 0 deletions src/Console/Command/ConfigurationCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace BumbleDocGen\Console\Command;

use BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException;
use DI\DependencyException;
use DI\NotFoundException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class ConfigurationCommand extends BaseCommand
{
protected function configure(): void
{
$this
->setName('configuration')
->setDescription('Display list of configured plugins, programming language handlers, etc')
->addArgument('key', InputArgument::REQUIRED, 'Configuration key to display')
Comment thread
misantron marked this conversation as resolved.
Outdated
;
}

/**
* @throws NotFoundException
* @throws DependencyException
* @throws InvalidConfigurationParameterException
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$key = $input->getArgument('key');
$this->createDocGenInstance($input, $output)->getConfigurationKey($key);

return self::SUCCESS;
}
}
30 changes: 15 additions & 15 deletions src/Core/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getProjectRoot(): string
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$projectRoot = $this->parameterBag->validateAndGetDirectoryPathValue('project_root', false);
$projectRoot = $this->parameterBag->validateAndGetDirectoryPathValue(ConfigurationKey::PROJECT_ROOT, false);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $projectRoot);
return $projectRoot;
}
Expand All @@ -65,7 +65,7 @@ public function getSourceLocators(): SourceLocatorsCollection
} catch (ObjectNotFoundException) {
}
$sourceLocators = $this->parameterBag->validateAndGetClassListValue(
'source_locators',
ConfigurationKey::SOURCE_LOCATORS,
SourceLocatorInterface::class
);
$cachedSourceLocatorsCollection = SourceLocatorsCollection::create(...$sourceLocators);
Expand All @@ -82,7 +82,7 @@ public function getTemplatesDir(): string
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$templatesDir = $this->parameterBag->validateAndGetStringValue('templates_dir', false);
$templatesDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::TEMPLATES_DIR, false);
$parentDir = dirname($templatesDir);
if (!$parentDir || !is_dir($parentDir)) {
throw new InvalidConfigurationParameterException(
Comment thread
misantron marked this conversation as resolved.
Expand All @@ -107,7 +107,7 @@ public function getOutputDir(): string
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$outputDir = $this->parameterBag->validateAndGetStringValue('output_dir', false);
$outputDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::OUTPUT_DIR, false);
$parentDir = dirname($outputDir);
if (!$parentDir || !is_dir($parentDir)) {
throw new InvalidConfigurationParameterException(
Comment thread
misantron marked this conversation as resolved.
Expand Down Expand Up @@ -139,7 +139,7 @@ public function getOutputDirBaseUrl(): string
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$outputDirBaseUrl = $this->parameterBag->validateAndGetStringValue('output_dir_base_url', false);
$outputDirBaseUrl = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::OUTPUT_DIR_BASE_URL, false);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $outputDirBaseUrl);
return $outputDirBaseUrl;
}
Expand All @@ -156,7 +156,7 @@ public function getLanguageHandlersCollection(): LanguageHandlersCollection
} catch (ObjectNotFoundException) {
}
$languageHandlers = $this->parameterBag->validateAndGetClassListValue(
'language_handlers',
ConfigurationKey::LANGUAGE_HANDLERS,
LanguageHandlerInterface::class,
false
);
Expand All @@ -177,7 +177,7 @@ public function getPlugins(): PluginsCollection
} catch (ObjectNotFoundException) {
}
$pluginsList = $this->parameterBag->validateAndGetClassListValue(
'plugins',
ConfigurationKey::PLUGINS,
PluginInterface::class
);
$cachedPlugins = PluginsCollection::create(...$pluginsList);
Expand All @@ -195,7 +195,7 @@ public function getCacheDir(): ?string
} catch (ObjectNotFoundException) {
}

$cacheDir = $this->parameterBag->validateAndGetStringValue('cache_dir');
$cacheDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::CACHE_DIR);
$parentDir = dirname($cacheDir);
if (!is_dir($parentDir)) {
throw new InvalidConfigurationParameterException(
Comment thread
misantron marked this conversation as resolved.
Expand Down Expand Up @@ -224,7 +224,7 @@ public function getPageLinkProcessor(): PageLinkProcessorInterface
}
/** @var PageLinkProcessorInterface $pageLinkProcessor */
$pageLinkProcessor = $this->parameterBag->validateAndGetClassValue(
'page_link_processor',
ConfigurationKey::PAGE_LINK_PROCESSOR,
PageLinkProcessorInterface::class
);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $pageLinkProcessor);
Expand All @@ -240,7 +240,7 @@ public function getGitClientPath(): string
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$gitClientPath = $this->parameterBag->validateAndGetStringValue('git_client_path', false);
$gitClientPath = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::GIT_CLIENT_PATH, false);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $gitClientPath);
return $gitClientPath;
}
Expand All @@ -257,7 +257,7 @@ public function getTwigFunctions(): CustomFunctionsCollection
} catch (ObjectNotFoundException) {
}
$customFunctions = $this->parameterBag->validateAndGetClassListValue(
'twig_functions',
ConfigurationKey::TWIG_FUNCTIONS,
CustomFunctionInterface::class
);
$customFunctionsCollection = new CustomFunctionsCollection();
Expand All @@ -280,7 +280,7 @@ public function getTwigFilters(): CustomFiltersCollection
} catch (ObjectNotFoundException) {
}
$customFilters = $this->parameterBag->validateAndGetClassListValue(
'twig_filters',
ConfigurationKey::TWIG_FILTERS,
CustomFilterInterface::class
);
$customFiltersCollection = new CustomFiltersCollection();
Expand All @@ -300,7 +300,7 @@ public function useSharedCache(): bool
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue('use_shared_cache');
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue(ConfigurationKey::USE_SHARED_CACHE);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $useSharedCache);
return $useSharedCache;
}
Expand All @@ -314,7 +314,7 @@ public function isCheckFileInGitBeforeCreatingDocEnabled(): bool
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
} catch (ObjectNotFoundException) {
}
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue('check_file_in_git_before_creating_doc');
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue(ConfigurationKey::CHECK_FILE_IN_GIT_BEFORE_CREATING_DOC);
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $useSharedCache);
return $useSharedCache;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ public function getAdditionalConsoleCommands(): AdditionalCommandCollection
} catch (ObjectNotFoundException) {
}
$customFilters = $this->parameterBag->validateAndGetClassListValue(
'additional_console_commands',
ConfigurationKey::ADDITIONAL_CONSOLE_COMMANDS,
Command::class
);
$additionalCommandCollection = AdditionalCommandCollection::create(...$customFilters);
Expand Down
24 changes: 24 additions & 0 deletions src/Core/Configuration/ConfigurationKey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace BumbleDocGen\Core\Configuration;

final class ConfigurationKey
{
public const PROJECT_ROOT = 'project_root';
public const TEMPLATES_DIR = 'templates_dir';
public const OUTPUT_DIR = 'output_dir';
public const OUTPUT_DIR_BASE_URL = 'output_dir_base_url';
public const CACHE_DIR = 'cache_dir';
public const PAGE_LINK_PROCESSOR = 'page_link_processor';
public const GIT_CLIENT_PATH = 'git_client_path';
public const USE_SHARED_CACHE = 'use_shared_cache';
public const CHECK_FILE_IN_GIT_BEFORE_CREATING_DOC = 'check_file_in_git_before_creating_doc';
public const SOURCE_LOCATORS = 'source_locators';
public const LANGUAGE_HANDLERS = 'language_handlers';
public const PLUGINS = 'plugins';
public const TWIG_FUNCTIONS = 'twig_functions';
public const TWIG_FILTERS = 'twig_filters';
public const ADDITIONAL_CONSOLE_COMMANDS = 'additional_console_commands';
}
10 changes: 9 additions & 1 deletion src/Core/Plugin/PluginsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class PluginsCollection implements \IteratorAggregate
{
/** @var array<int, PluginInterface> */
/** @var array<string, PluginInterface> */
private array $plugins = [];

public function getIterator(): \Generator
Expand All @@ -31,4 +31,12 @@ public function get(string $key): ?PluginInterface
{
return $this->plugins[$key] ?? null;
}

/**
* @return array<int, string>
*/
public function keys(): array
{
return array_keys($this->plugins);
}
}
8 changes: 8 additions & 0 deletions src/Core/Renderer/Twig/Filter/CustomFiltersCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ public function get(string $key): ?CustomFilterInterface
{
return $this->customFilters[$key] ?? null;
}

/**
* @return array<int, string>
*/
public function keys(): array
{
return array_keys($this->customFilters);
}
}
8 changes: 8 additions & 0 deletions src/Core/Renderer/Twig/Function/CustomFunctionsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ public function has(string $key): bool
{
return !is_null($this->get($key));
}

/**
* @return array<int, string>
*/
public function keys(): array
{
return array_keys($this->customFunctions);
}
}
9 changes: 9 additions & 0 deletions src/Core/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ function is_associative_array(array $array): bool
return count(array_filter(array_keys($array), 'is_string')) > 0;
}
}

if (!function_exists('BumbleDocGen\Core\get_class_short')) {
function get_class_short(string $className): string
{
$classNameParts = explode('\\', $className);

return end($classNameParts);
}
}
Loading