-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Generate database documentation via typo3 command (#1486)
Co-authored-by: Sebastian Meyer <[email protected]>
- Loading branch information
1 parent
da8c199
commit 16796f5
Showing
12 changed files
with
255 additions
and
150 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
Build/Documentation/dbdocs/public/typo3conf/LocalConfiguration.php
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
Build/Documentation/dbdocs/public/typo3conf/PackageStates.php
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Kitodo. Key to digital objects e.V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo and TYPO3 projects. | ||
* | ||
* @license GNU General Public License version 3 or later. | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Kitodo\Dlf\Command; | ||
|
||
use Kitodo\Dlf\Common\AbstractDocument; | ||
use Kitodo\Dlf\Common\Indexer; | ||
use Kitodo\Dlf\Command\DbDocs\Generator; | ||
use Kitodo\Dlf\Domain\Model\Document; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\MathUtility; | ||
|
||
/** | ||
* CLI Command for generating the reStructuredText file containing documentation | ||
* about the database schema. | ||
* | ||
* @package TYPO3 | ||
* @subpackage dlf | ||
* | ||
* @access public | ||
*/ | ||
class DbDocsCommand extends Command | ||
{ | ||
|
||
protected Generator $generator; | ||
|
||
public function __construct(Generator $generator) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->generator = $generator; | ||
} | ||
|
||
/** | ||
* Configure the command by defining the name, options and arguments | ||
* | ||
* @access public | ||
* | ||
* @return void | ||
*/ | ||
public function configure(): void | ||
{ | ||
$this | ||
->setDescription('Generate database rst file.') | ||
->setHelp('') | ||
->addArgument('outputPath', InputArgument::OPTIONAL, 'the path to the output rst file'); | ||
} | ||
|
||
/** | ||
* Executes the command to generate the documentation. | ||
* | ||
* @access protected | ||
* | ||
* @param InputInterface $input The input parameters | ||
* @param OutputInterface $output The Symfony interface for outputs on console | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$io->title($this->getDescription()); | ||
|
||
$outputPath = "kitodo-presentation/Documentation/Developers/Database.rst"; | ||
if ($input->getArgument('outputPath')) { | ||
$outputPath = $input->getArgument('outputPath'); | ||
} | ||
|
||
$tables = $this->generator->collectTables(); | ||
$page = $this->generator->generatePage($tables); | ||
|
||
GeneralUtility::writeFile($outputPath, $page->render()); | ||
|
||
$io->write("Database documentation written to output file:\n" . $outputPath . "\n"); | ||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.