addDescription( 'Build Configuration.md file from config-schema.yaml' ); $this->addOption( 'schema', 'Path to the config schema file relative to $IP. Default: ' . self::DEFAULT_INPUT_PATH, false, true ); $this->addOption( 'output', 'Path to output relative to $IP. Default: ' . self::DEFAULT_OUTPUT_PATH, false, true ); } public function execute() { $input = ( new FileSource( $this->getInputPath() ) )->load(); $result = "\n"; $result .= "\n"; $result .= "\n"; $result .= "This is a list of configuration variables that can be set in LocalSettings.php.\n\n"; // Table of contents $result .= "[TOC]\n\n"; // Details about each config variable foreach ( $input['config-schema'] as $configKey => $configSchema ) { $result .= "# $configKey {#$configKey}\n"; if ( array_key_exists( 'description', $configSchema ) ) { $result .= $configSchema['description']; } $result .= "\n\n"; } file_put_contents( $this->getOutputPath(), $result ); } private function getInputPath(): string { global $IP; $inputPath = $this->getOption( 'schema', self::DEFAULT_INPUT_PATH ); return $IP . DIRECTORY_SEPARATOR . $inputPath; } private function getOutputPath(): string { global $IP; $outputPath = $this->getOption( 'output', self::DEFAULT_OUTPUT_PATH ); if ( $outputPath === '-' || $outputPath === 'php://stdout' ) { return 'php://stdout'; } return $IP . DIRECTORY_SEPARATOR . $outputPath; } } $maintClass = GenerateConfigDoc::class; require_once RUN_MAINTENANCE_IF_MAIN;