From e088fcf40b299d58cf0f2d0cca2c6b4100e4703a Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Wed, 1 Mar 2023 14:27:44 -0300 Subject: [PATCH 01/12] Test to verify if a command is documented Signed-off-by: Vitor Mattos --- docs/index.md | 1 + docs/occ.md | 2 + tests/php/Command/DocumentationTest.php | 52 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 docs/occ.md create mode 100644 tests/php/Command/DocumentationTest.php diff --git a/docs/index.md b/docs/index.md index 4312cfb3f75..bd433aa5972 100644 --- a/docs/index.md +++ b/docs/index.md @@ -32,3 +32,4 @@ ## Other * [Chat commands](commands.md) +* [Occ commands](occ.md) diff --git a/docs/occ.md b/docs/occ.md new file mode 100644 index 00000000000..d9ab4d74b52 --- /dev/null +++ b/docs/occ.md @@ -0,0 +1,2 @@ +# Occ commands + diff --git a/tests/php/Command/DocumentationTest.php b/tests/php/Command/DocumentationTest.php new file mode 100644 index 00000000000..462d2375762 --- /dev/null +++ b/tests/php/Command/DocumentationTest.php @@ -0,0 +1,52 @@ + + * + * @author Vitor Mattos + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace OCA\Talk\Tests\php\Command; + +use OCP\App\IAppManager; +use Test\TestCase; + +final class DocumentationTest extends TestCase { + public function testCommandIsDocumented(): void { + /** @var IAppManager */ + $appManager = \OC::$server->get(IAppManager::class); + $info = $appManager->getAppInfo('spreed'); + foreach ($info['commands'] as $commandNamespace) { + $path = str_replace('OCA\Talk', '', $commandNamespace); + $path = str_replace('\\', '/', $path); + $path = __DIR__ . '/../../../lib' . $path . '.php'; + $this->assertFileExists($path, 'The class of the follow namespase is not implemented: ' . $commandNamespace); + $code = file_get_contents($path); + preg_match("/->setName\('(?[\w:\-_]+)'\)/", $code, $matches); + if (!array_key_exists('command', $matches)) { + preg_match("/\tname: '(?[\w:\-_]+)',?\n/", $code, $matches); + } + $this->assertArrayHasKey('command', $matches, 'A command need to have a name.'); + $this->commandIsDocummented($matches['command']); + } + } + + public function commandIsDocummented(string $command): void { + $docs = file_get_contents(__DIR__ . '/../../../docs/occ.md'); + self::assertStringContainsString($command, $docs, 'Asserting that command ' . $command . ' is documented'); + } +} From 0b5268ebdc46deefc15d8cc043fdd5244795d030 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Wed, 1 Mar 2023 21:40:01 -0300 Subject: [PATCH 02/12] Document commands * created developer command to document commands Signed-off-by: Vitor Mattos --- appinfo/info.xml | 1 + docs/occ.md | 1001 ++++++++++++++++++++++- lib/Command/Developer/UpdateDocs.php | 168 ++++ tests/php/Command/DocumentationTest.php | 6 +- tests/psalm-baseline.xml | 111 ++- 5 files changed, 1229 insertions(+), 58 deletions(-) create mode 100644 lib/Command/Developer/UpdateDocs.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 7999b080f4d..ab7aa29279e 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -85,6 +85,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m OCA\Talk\Command\Command\Delete OCA\Talk\Command\Command\ListCommand OCA\Talk\Command\Command\Update + OCA\Talk\Command\Developer\UpdateDocs OCA\Talk\Command\Monitor\Calls OCA\Talk\Command\Monitor\HasActiveCalls OCA\Talk\Command\Monitor\Room diff --git a/docs/occ.md b/docs/occ.md index d9ab4d74b52..07379b86540 100644 --- a/docs/occ.md +++ b/docs/occ.md @@ -1,2 +1,1001 @@ -# Occ commands +## talk:command:add + +Add a new command + +### Usage + +* `talk:command:add