PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.2.0
Independent Analytics – WordPress Analytics Plugin v2.2.0
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / symfony / console / Descriptor / MarkdownDescriptor.php
independent-analytics / vendor / symfony / console / Descriptor Last commit date
ApplicationDescription.php 3 years ago Descriptor.php 3 years ago DescriptorInterface.php 2 years ago JsonDescriptor.php 3 years ago MarkdownDescriptor.php 3 years ago TextDescriptor.php 3 years ago XmlDescriptor.php 3 years ago
MarkdownDescriptor.php
156 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace IAWP_SCOPED\Symfony\Component\Console\Descriptor;
12
13 use IAWP_SCOPED\Symfony\Component\Console\Application;
14 use IAWP_SCOPED\Symfony\Component\Console\Command\Command;
15 use IAWP_SCOPED\Symfony\Component\Console\Helper\Helper;
16 use IAWP_SCOPED\Symfony\Component\Console\Input\InputArgument;
17 use IAWP_SCOPED\Symfony\Component\Console\Input\InputDefinition;
18 use IAWP_SCOPED\Symfony\Component\Console\Input\InputOption;
19 use IAWP_SCOPED\Symfony\Component\Console\Output\OutputInterface;
20 /**
21 * Markdown descriptor.
22 *
23 * @author Jean-François Simon <contact@jfsimon.fr>
24 *
25 * @internal
26 */
27 class MarkdownDescriptor extends Descriptor
28 {
29 /**
30 * {@inheritdoc}
31 */
32 public function describe(OutputInterface $output, object $object, array $options = [])
33 {
34 $decorated = $output->isDecorated();
35 $output->setDecorated(\false);
36 parent::describe($output, $object, $options);
37 $output->setDecorated($decorated);
38 }
39 /**
40 * {@inheritdoc}
41 */
42 protected function write(string $content, bool $decorated = \true)
43 {
44 parent::write($content, $decorated);
45 }
46 /**
47 * {@inheritdoc}
48 */
49 protected function describeInputArgument(InputArgument $argument, array $options = [])
50 {
51 $this->write('#### `' . ($argument->getName() ?: '<none>') . "`\n\n" . ($argument->getDescription() ? \preg_replace('/\\s*[\\r\\n]\\s*/', "\n", $argument->getDescription()) . "\n\n" : '') . '* Is required: ' . ($argument->isRequired() ? 'yes' : 'no') . "\n" . '* Is array: ' . ($argument->isArray() ? 'yes' : 'no') . "\n" . '* Default: `' . \str_replace("\n", '', \var_export($argument->getDefault(), \true)) . '`');
52 }
53 /**
54 * {@inheritdoc}
55 */
56 protected function describeInputOption(InputOption $option, array $options = [])
57 {
58 $name = '--' . $option->getName();
59 if ($option->isNegatable()) {
60 $name .= '|--no-' . $option->getName();
61 }
62 if ($option->getShortcut()) {
63 $name .= '|-' . \str_replace('|', '|-', $option->getShortcut()) . '';
64 }
65 $this->write('#### `' . $name . '`' . "\n\n" . ($option->getDescription() ? \preg_replace('/\\s*[\\r\\n]\\s*/', "\n", $option->getDescription()) . "\n\n" : '') . '* Accept value: ' . ($option->acceptValue() ? 'yes' : 'no') . "\n" . '* Is value required: ' . ($option->isValueRequired() ? 'yes' : 'no') . "\n" . '* Is multiple: ' . ($option->isArray() ? 'yes' : 'no') . "\n" . '* Is negatable: ' . ($option->isNegatable() ? 'yes' : 'no') . "\n" . '* Default: `' . \str_replace("\n", '', \var_export($option->getDefault(), \true)) . '`');
66 }
67 /**
68 * {@inheritdoc}
69 */
70 protected function describeInputDefinition(InputDefinition $definition, array $options = [])
71 {
72 if ($showArguments = \count($definition->getArguments()) > 0) {
73 $this->write('### Arguments');
74 foreach ($definition->getArguments() as $argument) {
75 $this->write("\n\n");
76 if (null !== ($describeInputArgument = $this->describeInputArgument($argument))) {
77 $this->write($describeInputArgument);
78 }
79 }
80 }
81 if (\count($definition->getOptions()) > 0) {
82 if ($showArguments) {
83 $this->write("\n\n");
84 }
85 $this->write('### Options');
86 foreach ($definition->getOptions() as $option) {
87 $this->write("\n\n");
88 if (null !== ($describeInputOption = $this->describeInputOption($option))) {
89 $this->write($describeInputOption);
90 }
91 }
92 }
93 }
94 /**
95 * {@inheritdoc}
96 */
97 protected function describeCommand(Command $command, array $options = [])
98 {
99 if ($options['short'] ?? \false) {
100 $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce($command->getAliases(), function ($carry, $usage) {
101 return $carry . '* `' . $usage . '`' . "\n";
102 }));
103 return;
104 }
105 $command->mergeApplicationDefinition(\false);
106 $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce(\array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
107 return $carry . '* `' . $usage . '`' . "\n";
108 }));
109 if ($help = $command->getProcessedHelp()) {
110 $this->write("\n");
111 $this->write($help);
112 }
113 $definition = $command->getDefinition();
114 if ($definition->getOptions() || $definition->getArguments()) {
115 $this->write("\n\n");
116 $this->describeInputDefinition($definition);
117 }
118 }
119 /**
120 * {@inheritdoc}
121 */
122 protected function describeApplication(Application $application, array $options = [])
123 {
124 $describedNamespace = $options['namespace'] ?? null;
125 $description = new ApplicationDescription($application, $describedNamespace);
126 $title = $this->getApplicationTitle($application);
127 $this->write($title . "\n" . \str_repeat('=', Helper::width($title)));
128 foreach ($description->getNamespaces() as $namespace) {
129 if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
130 $this->write("\n\n");
131 $this->write('**' . $namespace['id'] . ':**');
132 }
133 $this->write("\n\n");
134 $this->write(\implode("\n", \array_map(function ($commandName) use($description) {
135 return \sprintf('* [`%s`](#%s)', $commandName, \str_replace(':', '', $description->getCommand($commandName)->getName()));
136 }, $namespace['commands'])));
137 }
138 foreach ($description->getCommands() as $command) {
139 $this->write("\n\n");
140 if (null !== ($describeCommand = $this->describeCommand($command, $options))) {
141 $this->write($describeCommand);
142 }
143 }
144 }
145 private function getApplicationTitle(Application $application) : string
146 {
147 if ('UNKNOWN' !== $application->getName()) {
148 if ('UNKNOWN' !== $application->getVersion()) {
149 return \sprintf('%s %s', $application->getName(), $application->getVersion());
150 }
151 return $application->getName();
152 }
153 return 'Console Tool';
154 }
155 }
156