Skip to content

Commit 283955f

Browse files
authored
Merge pull request #54 from misantron/issue-48
Configuration console command
2 parents 95a5764 + 899ca2d commit 283955f

14 files changed

Lines changed: 1801 additions & 23 deletions

File tree

docs/shared_c.cache

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/tech/classes/ConfigurationCommand.md

Lines changed: 1384 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!-- {% raw %} -->
2+
<embed> <a href="/docs/README.md">BumbleDocGen</a> <b>/</b> <a href="/docs/tech/readme.md">Technical description of the project</a> <b>/</b> <a href="/docs/tech/map.md">Class map</a> <b>/</b> ConfigurationKey<hr> </embed>
3+
4+
<h1>
5+
<a href="https://github.com/bumble-tech/bumble-doc-gen/blob/master/src/Core/Configuration/ConfigurationKey.php#L7">ConfigurationKey</a> class:
6+
</h1>
7+
8+
9+
10+
11+
12+
```php
13+
namespace BumbleDocGen\Core\Configuration;
14+
15+
final class ConfigurationKey
16+
```
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
<h2>Methods:</h2>
27+
28+
<ol>
29+
<li>
30+
<a href="#mall">all</a>
31+
</li>
32+
</ol>
33+
34+
35+
<h2>Constants:</h2>
36+
<ul>
37+
<li><a name="qadditional-console-commands"
38+
href="#qadditional-console-commands">#</a>
39+
<code>ADDITIONAL_CONSOLE_COMMANDS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L23">source
40+
code</a> </li>
41+
<li><a name="qcache-dir"
42+
href="#qcache-dir">#</a>
43+
<code>CACHE_DIR</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L13">source
44+
code</a> </li>
45+
<li><a name="qcheck-file-in-git-before-creating-doc"
46+
href="#qcheck-file-in-git-before-creating-doc">#</a>
47+
<code>CHECK_FILE_IN_GIT_BEFORE_CREATING_DOC</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L17">source
48+
code</a> </li>
49+
<li><a name="qgit-client-path"
50+
href="#qgit-client-path">#</a>
51+
<code>GIT_CLIENT_PATH</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L15">source
52+
code</a> </li>
53+
<li><a name="qlanguage-handlers"
54+
href="#qlanguage-handlers">#</a>
55+
<code>LANGUAGE_HANDLERS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L19">source
56+
code</a> </li>
57+
<li><a name="qoutput-dir"
58+
href="#qoutput-dir">#</a>
59+
<code>OUTPUT_DIR</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L11">source
60+
code</a> </li>
61+
<li><a name="qoutput-dir-base-url"
62+
href="#qoutput-dir-base-url">#</a>
63+
<code>OUTPUT_DIR_BASE_URL</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L12">source
64+
code</a> </li>
65+
<li><a name="qpage-link-processor"
66+
href="#qpage-link-processor">#</a>
67+
<code>PAGE_LINK_PROCESSOR</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L14">source
68+
code</a> </li>
69+
<li><a name="qplugins"
70+
href="#qplugins">#</a>
71+
<code>PLUGINS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L20">source
72+
code</a> </li>
73+
<li><a name="qproject-root"
74+
href="#qproject-root">#</a>
75+
<code>PROJECT_ROOT</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L9">source
76+
code</a> </li>
77+
<li><a name="qsource-locators"
78+
href="#qsource-locators">#</a>
79+
<code>SOURCE_LOCATORS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L18">source
80+
code</a> </li>
81+
<li><a name="qtemplates-dir"
82+
href="#qtemplates-dir">#</a>
83+
<code>TEMPLATES_DIR</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L10">source
84+
code</a> </li>
85+
<li><a name="qtwig-filters"
86+
href="#qtwig-filters">#</a>
87+
<code>TWIG_FILTERS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L22">source
88+
code</a> </li>
89+
<li><a name="qtwig-functions"
90+
href="#qtwig-functions">#</a>
91+
<code>TWIG_FUNCTIONS</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L21">source
92+
code</a> </li>
93+
<li><a name="quse-shared-cache"
94+
href="#quse-shared-cache">#</a>
95+
<code>USE_SHARED_CACHE</code> <b>|</b> <a href="/src/Core/Configuration/ConfigurationKey.php#L16">source
96+
code</a> </li>
97+
</ul>
98+
99+
100+
101+
102+
103+
<h2>Method details:</h2>
104+
105+
<div class='method_description-block'>
106+
107+
<ul>
108+
<li><a name="mall" href="#mall">#</a>
109+
<b>all</b>
110+
<b>|</b> <a href="https://github.com/bumble-tech/bumble-doc-gen/blob/master/src/Core/Configuration/ConfigurationKey.php#L25">source code</a></li>
111+
</ul>
112+
113+
```php
114+
public static function all(): array;
115+
```
116+
117+
118+
119+
<b>Parameters:</b> not specified
120+
121+
<b>Return value:</b> <a href='https://www.php.net/manual/en/language.types.array.php'>array</a>
122+
123+
124+
</div>
125+
<hr>
126+
127+
<!-- {% endraw %} -->

docs/tech/map.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Directory layout ( only documented files shown ):
2121
│ │ ├──<b>Command</b>/
2222
│ │ │ ├── <a href='/docs/tech/classes/AdditionalCommandCollection.md'>AdditionalCommandCollection.php</a>
2323
│ │ │ ├── <a href='/docs/tech/classes/BaseCommand.md'>BaseCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
24+
│ │ │ ├── <a href='/docs/tech/classes/ConfigurationCommand.md'>ConfigurationCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
2425
│ │ │ └── <a href='/docs/tech/classes/GenerateCommand.md'>GenerateCommand.php</a> <i> — <samp>Base class for all commands.</samp></i>
2526
│ │ ├──<b>ProgressBar</b>/
2627
│ │ │ ├── <a href='/docs/tech/classes/ProgressBarFactory.md'>ProgressBarFactory.php</a>
@@ -47,6 +48,7 @@ Directory layout ( only documented files shown ):
4748
│ │ │ │ ├── <a href='/docs/tech/classes/ValueToClassTransformer.md'>ValueToClassTransformer.php</a> <i> — <samp>Standard text-to-class transformer</samp></i>
4849
│ │ │ │ └── <a href='/docs/tech/classes/ValueTransformerInterface.md'>ValueTransformerInterface.php</a> <i> — <samp>Interface defining classes that transform text configuration values into objects</samp></i>
4950
│ │ │ ├── <a href='/docs/tech/classes/Configuration.md'>Configuration.php</a> <i> — <samp>Configuration project documentation</samp></i>
51+
│ │ │ ├── <a href='/docs/tech/classes/ConfigurationKey.md'>ConfigurationKey.php</a>
5052
│ │ │ └── <a href='/docs/tech/classes/ConfigurationParameterBag.md'>ConfigurationParameterBag.php</a> <i> — <samp>Wrapper for getting raw configuration file data</samp></i>
5153
│ │ ├──<b>Logger</b>/
5254
│ │ │ └──<b>Handler</b>/
@@ -257,4 +259,4 @@ Directory layout ( only documented files shown ):
257259

258260
<div id='page_committer_info'>
259261
<hr>
260-
<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 Nov 06 2023<br>Made with <a href='https://github.com/bumble-tech/bumble-doc-gen/blob/master/docs/README.md'>Bumble Documentation Generator</a></div>
262+
<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> Tue Nov 14 2023<br>Made with <a href='https://github.com/bumble-tech/bumble-doc-gen/blob/master/docs/README.md'>Bumble Documentation Generator</a></div>

src/Console/App.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use BumbleDocGen\AI\Console\AddDocBlocksCommand;
88
use BumbleDocGen\AI\Console\GenerateReadMeTemplateCommand;
9+
use BumbleDocGen\Console\Command\ConfigurationCommand;
910
use BumbleDocGen\Console\Command\GenerateCommand;
1011
use BumbleDocGen\DocGeneratorFactory;
1112
use Symfony\Component\Console\Application;
@@ -34,6 +35,7 @@ public function __construct()
3435
$this->add(new GenerateCommand());
3536
$this->add(new GenerateReadMeTemplateCommand());
3637
$this->add(new AddDocBlocksCommand());
38+
$this->add(new ConfigurationCommand());
3739
$this->setExtraCommands();
3840
}
3941

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BumbleDocGen\Console\Command;
6+
7+
use BumbleDocGen\Core\Configuration\Exception\InvalidConfigurationParameterException;
8+
use DI\DependencyException;
9+
use DI\NotFoundException;
10+
use Symfony\Component\Console\Input\InputArgument;
11+
use Symfony\Component\Console\Input\InputInterface;
12+
use Symfony\Component\Console\Output\OutputInterface;
13+
14+
final class ConfigurationCommand extends BaseCommand
15+
{
16+
protected function configure(): void
17+
{
18+
$this
19+
->setName('configuration')
20+
->setDescription('Display list of configured plugins, programming language handlers, etc')
21+
->addArgument('key', InputArgument::OPTIONAL, 'Configuration key to display')
22+
;
23+
}
24+
25+
/**
26+
* @throws NotFoundException
27+
* @throws DependencyException
28+
* @throws InvalidConfigurationParameterException
29+
*/
30+
protected function execute(InputInterface $input, OutputInterface $output): int
31+
{
32+
$generator = $this->createDocGenInstance($input, $output);
33+
34+
$key = $input->getArgument('key');
35+
if ($key === null) {
36+
$generator->getConfigurationKeys();
37+
} else {
38+
$generator->getConfigurationKey($key);
39+
}
40+
41+
return self::SUCCESS;
42+
}
43+
}

src/Core/Configuration/Configuration.php

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getProjectRoot(): string
5353
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
5454
} catch (ObjectNotFoundException) {
5555
}
56-
$projectRoot = $this->parameterBag->validateAndGetDirectoryPathValue('project_root', false);
56+
$projectRoot = $this->parameterBag->validateAndGetDirectoryPathValue(ConfigurationKey::PROJECT_ROOT, false);
5757
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $projectRoot);
5858
return $projectRoot;
5959
}
@@ -70,7 +70,7 @@ public function getSourceLocators(): SourceLocatorsCollection
7070
} catch (ObjectNotFoundException) {
7171
}
7272
$sourceLocators = $this->parameterBag->validateAndGetClassListValue(
73-
'source_locators',
73+
ConfigurationKey::SOURCE_LOCATORS,
7474
SourceLocatorInterface::class
7575
);
7676
$cachedSourceLocatorsCollection = SourceLocatorsCollection::create(...$sourceLocators);
@@ -87,11 +87,14 @@ public function getTemplatesDir(): string
8787
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
8888
} catch (ObjectNotFoundException) {
8989
}
90-
$templatesDir = $this->parameterBag->validateAndGetStringValue('templates_dir', false);
90+
$templatesDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::TEMPLATES_DIR, false);
9191
$parentDir = dirname($templatesDir);
9292
if (!$parentDir || !is_dir($parentDir)) {
9393
throw new InvalidConfigurationParameterException(
94-
"`output_dir` cannot be created because parent directory `{$parentDir}` does not exist"
94+
sprintf(
95+
"`%s` cannot be created because parent directory `{$parentDir}` does not exist",
96+
ConfigurationKey::TEMPLATES_DIR
97+
)
9598
);
9699
}
97100
if (!file_exists($templatesDir)) {
@@ -112,17 +115,23 @@ public function getOutputDir(): string
112115
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
113116
} catch (ObjectNotFoundException) {
114117
}
115-
$outputDir = $this->parameterBag->validateAndGetStringValue('output_dir', false);
118+
$outputDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::OUTPUT_DIR, false);
116119
$parentDir = dirname($outputDir);
117120
if (!$parentDir || !is_dir($parentDir)) {
118121
throw new InvalidConfigurationParameterException(
119-
"`output_dir` cannot be created because parent directory `{$parentDir}` does not exist"
122+
sprintf(
123+
"`%s` cannot be created because parent directory `{$parentDir}` does not exist",
124+
ConfigurationKey::OUTPUT_DIR
125+
)
120126
);
121127
}
122128

123129
if (!is_writable($parentDir)) {
124130
throw new InvalidConfigurationParameterException(
125-
"`output_dir` cannot be created because parent directory `{$parentDir}` is not writable"
131+
sprintf(
132+
"`%s` cannot be created because parent directory `{$parentDir}` is not writable",
133+
ConfigurationKey::OUTPUT_DIR
134+
)
126135
);
127136
}
128137

@@ -144,7 +153,7 @@ public function getOutputDirBaseUrl(): string
144153
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
145154
} catch (ObjectNotFoundException) {
146155
}
147-
$outputDirBaseUrl = $this->parameterBag->validateAndGetStringValue('output_dir_base_url', false);
156+
$outputDirBaseUrl = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::OUTPUT_DIR_BASE_URL, false);
148157
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $outputDirBaseUrl);
149158
return $outputDirBaseUrl;
150159
}
@@ -161,7 +170,7 @@ public function getLanguageHandlersCollection(): LanguageHandlersCollection
161170
} catch (ObjectNotFoundException) {
162171
}
163172
$languageHandlers = $this->parameterBag->validateAndGetClassListValue(
164-
'language_handlers',
173+
ConfigurationKey::LANGUAGE_HANDLERS,
165174
LanguageHandlerInterface::class,
166175
false
167176
);
@@ -182,7 +191,7 @@ public function getPlugins(): PluginsCollection
182191
} catch (ObjectNotFoundException) {
183192
}
184193
$pluginsList = $this->parameterBag->validateAndGetClassListValue(
185-
'plugins',
194+
ConfigurationKey::PLUGINS,
186195
PluginInterface::class
187196
);
188197
$cachedPlugins = PluginsCollection::create(...$pluginsList);
@@ -200,11 +209,14 @@ public function getCacheDir(): ?string
200209
} catch (ObjectNotFoundException) {
201210
}
202211

203-
$cacheDir = $this->parameterBag->validateAndGetStringValue('cache_dir');
212+
$cacheDir = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::CACHE_DIR);
204213
$parentDir = dirname($cacheDir);
205214
if (!is_dir($parentDir)) {
206215
throw new InvalidConfigurationParameterException(
207-
"`cache_dir` cannot be created because parent directory `{$parentDir}` does not exist"
216+
sprintf(
217+
"`%s` cannot be created because parent directory `{$parentDir}` does not exist",
218+
ConfigurationKey::CACHE_DIR
219+
)
208220
);
209221
}
210222
if (!file_exists($cacheDir)) {
@@ -229,7 +241,7 @@ public function getPageLinkProcessor(): PageLinkProcessorInterface
229241
}
230242
/** @var PageLinkProcessorInterface $pageLinkProcessor */
231243
$pageLinkProcessor = $this->parameterBag->validateAndGetClassValue(
232-
'page_link_processor',
244+
ConfigurationKey::PAGE_LINK_PROCESSOR,
233245
PageLinkProcessorInterface::class
234246
);
235247
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $pageLinkProcessor);
@@ -245,7 +257,7 @@ public function getGitClientPath(): string
245257
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
246258
} catch (ObjectNotFoundException) {
247259
}
248-
$gitClientPath = $this->parameterBag->validateAndGetStringValue('git_client_path', false);
260+
$gitClientPath = $this->parameterBag->validateAndGetStringValue(ConfigurationKey::GIT_CLIENT_PATH, false);
249261
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $gitClientPath);
250262
return $gitClientPath;
251263
}
@@ -262,7 +274,7 @@ public function getTwigFunctions(): CustomFunctionsCollection
262274
} catch (ObjectNotFoundException) {
263275
}
264276
$customFunctions = $this->parameterBag->validateAndGetClassListValue(
265-
'twig_functions',
277+
ConfigurationKey::TWIG_FUNCTIONS,
266278
CustomFunctionInterface::class
267279
);
268280
$customFunctionsCollection = new CustomFunctionsCollection();
@@ -285,7 +297,7 @@ public function getTwigFilters(): CustomFiltersCollection
285297
} catch (ObjectNotFoundException) {
286298
}
287299
$customFilters = $this->parameterBag->validateAndGetClassListValue(
288-
'twig_filters',
300+
ConfigurationKey::TWIG_FILTERS,
289301
CustomFilterInterface::class
290302
);
291303
$customFiltersCollection = new CustomFiltersCollection();
@@ -305,7 +317,7 @@ public function useSharedCache(): bool
305317
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
306318
} catch (ObjectNotFoundException) {
307319
}
308-
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue('use_shared_cache');
320+
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue(ConfigurationKey::USE_SHARED_CACHE);
309321
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $useSharedCache);
310322
return $useSharedCache;
311323
}
@@ -319,7 +331,7 @@ public function isCheckFileInGitBeforeCreatingDocEnabled(): bool
319331
return $this->localObjectCache->getMethodCachedResult(__METHOD__, '');
320332
} catch (ObjectNotFoundException) {
321333
}
322-
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue('check_file_in_git_before_creating_doc');
334+
$useSharedCache = $this->parameterBag->validateAndGetBooleanValue(ConfigurationKey::CHECK_FILE_IN_GIT_BEFORE_CREATING_DOC);
323335
$this->localObjectCache->cacheMethodResult(__METHOD__, '', $useSharedCache);
324336
return $useSharedCache;
325337
}
@@ -353,7 +365,7 @@ public function getAdditionalConsoleCommands(): AdditionalCommandCollection
353365
} catch (ObjectNotFoundException) {
354366
}
355367
$customFilters = $this->parameterBag->validateAndGetClassListValue(
356-
'additional_console_commands',
368+
ConfigurationKey::ADDITIONAL_CONSOLE_COMMANDS,
357369
Command::class
358370
);
359371
$additionalCommandCollection = AdditionalCommandCollection::create(...$customFilters);

0 commit comments

Comments
 (0)