From b06f2bc67c3e47dfb686a8ef4e1e7a3447b9cd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sat, 30 Nov 2024 22:48:21 +0100 Subject: [PATCH] Improve documentation generation - Really trim leading and trailing hyphens (single hyphens were not trimmed before) - Create the necesary directories for even namespaced methods when generating methodsynopsis --- build/gen_stub.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 800262f27e51..b105ed4efd8d 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2610,7 +2610,7 @@ protected function getFieldSynopsisDefaultLinkend(): string { $className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString()); - return "$className.constants." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName())); + return "$className.constants." . strtolower(str_replace("_", "-", trim($this->name->getDeclarationName(), "_"))); } protected function getFieldSynopsisName(): string @@ -3052,7 +3052,7 @@ protected function getFieldSynopsisDefaultLinkend(): string { $className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString()); - return "$className.props." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName())); + return "$className.props." . strtolower(str_replace("_", "-", trim($this->name->getDeclarationName(), "_"))); } protected function getFieldSynopsisName(): string @@ -6424,8 +6424,14 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc } foreach ($methodSynopses as $filename => $content) { - if (!file_exists("$manualTarget/$filename")) { - if (file_put_contents("$manualTarget/$filename", $content)) { + $path = "$manualTarget/$filename"; + + if (!file_exists($path)) { + if (!file_exists(dirname($path))) { + mkdir(dirname($path)); + } + + if (file_put_contents($path, $content)) { echo "Saved $filename\n"; } }