update docs, and some related comments and generated codes

This commit is contained in:
Jerry
2023-01-30 15:23:11 +08:00
parent ea17b0293c
commit ebb27a5852
17 changed files with 422 additions and 44 deletions

View File

@@ -62,15 +62,35 @@ class TextGenerateCommand extends Command
return static::FAILURE;
}
$json = json_decode($api, true);
$line = '# 更新日志' . "\r\n\r\n> 本页面由框架自动生成\r\n\r\n";
$line = '# 更新日志' . "\r\n\r\n> 本页面由框架命令 `./zhamao generate:text update-log-md` 自动生成\r\n\r\n";
foreach ($json as $v) {
$version = $v['tag_name'];
if (str_starts_with($version, '2.')) {
continue;
}
$doc_count = 0;
$time = '> 更新时间:' . date('Y-m-d', strtotime($v['published_at']));
$line .= '## v' . $v['tag_name'] . "\r\n\r\n" . $time . "\r\n\r\n" . trim(str_replace("## What's Changed", '', $v['body'])) . "\r\n\r\n";
$line .= '## v' . $v['tag_name'] . "\r\n\r\n" . $time . "\r\n\r\n";
$v['body'] = trim(str_replace("## What's Changed", '', $v['body']));
$bodies = explode("\r\n", $v['body']);
foreach ($bodies as $ks => $vs) {
if (str_contains($vs, '文档')) {
++$doc_count;
if ($doc_count === 1) {
$bodies[$ks] = '* 本次更新包含文档更新内容 {cnt} 个';
}
}
}
$v['body'] = implode("\r\n", $bodies);
if ($doc_count > 0) {
$v['body'] = str_replace('{cnt}', strval($doc_count), $v['body']);
}
$line .= $v['body'] . "\r\n\r\n";
}
// 将双空行转换为单空行
$line = str_replace("\r\n\r\n\r\n", "\r\n\r\n", $line);
// 转换文本换行符格式为 LF
$line = str_replace("\r\n", "\n", $line);
// 将所有的链接转换为可点击的链接,例如 https://example.com -> <https://example.com>
@@ -82,6 +102,13 @@ class TextGenerateCommand extends Command
// 将 mention 转换为可点击的链接,例如 @sunxyw -> [@sunxyw](https://github.com/sunxyw)
$line = preg_replace('/(?<=^|\s)@([\w.]+)(?<!\.)/', '[@$1](https://github.com/$1)', $line);
// 将 Full Changelog 转换为“源码变更记录”
$line = str_replace('Full Changelog', '源码变更记录', $line);
if (isset($doc_count) && $doc_count > 0) {
$line = str_replace('{cnt}', strval($doc_count), $line);
}
file_put_contents(FRAMEWORK_ROOT_DIR . '/docs/update/v3.md', $line);
return static::SUCCESS;
}

View File

@@ -32,7 +32,7 @@ class ServerStartCommand extends ServerCommand
new InputOption('log-level', null, InputOption::VALUE_REQUIRED, '调整消息等级到debug (log-level=4)'),
new InputOption('daemon', null, null, '以守护进程的方式运行框架'),
new InputOption('worker-num', null, InputOption::VALUE_REQUIRED, '启动框架时运行的 Worker 进程数量'),
new InputOption('watch', null, null, '监听 src/ 目录的文件变化并热更新'),
new InputOption('watch', null, null, '监听 plugins/ 目录下各个插件的文件变化并热更新(还不能用)'),
new InputOption('env', null, InputOption::VALUE_REQUIRED, '设置环境类型 (production, development, staging)'),
new InputOption('disable-safe-exit', null, null, '关闭安全退出关闭后按CtrlC时直接杀死进程'),
new InputOption('no-state-check', null, null, '关闭启动前框架运行状态检查'),
@@ -44,19 +44,11 @@ class ServerStartCommand extends ServerCommand
/**
* @throws ZMKnownException
* @throws InitException
* @throws \Exception
* @noinspection PhpComposerExtensionStubsInspection
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
// 这段用于config的环境解析但显然不是很好的方式应该改成一个独立的方法不应该在这里检查但暂时搁置TODO
/* if (($opt = $input->getOption('env')) !== null) {
if (!in_array($opt, ['production', 'staging', 'development', ''])) {
$output->writeln('<error> "--env" option only accept production, development, staging and [empty] ! </error>');
return 1;
}
}*/
// 如果是支持多进程模式的,那么就检查框架进程的状态
if (ProcessManager::isSupportedMultiProcess()) {
$state = ProcessStateManager::getProcessState(ZM_PROCESS_MASTER);

View File

@@ -31,9 +31,6 @@ trait HttpTrait
return $obj;
}
/**
* {@inheritDoc}
*/
public function withResponse(ResponseInterface $response)
{
$this->getHttpRequestEvent()->withResponse($response);

View File

@@ -226,6 +226,7 @@ class Framework
$this->printMotd();
}
// 注册添加容器依赖的事件
ContainerBindingListener::listenForEvents();
// 添加框架需要监听的顶层事件监听器