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
This commit is contained in:
Máté Kocsis 2024-11-30 22:48:21 +01:00
parent be69262137
commit b06f2bc67c
No known key found for this signature in database
GPG key ID: FD055E41728BF310

View file

@ -2610,7 +2610,7 @@ class ConstInfo extends VariableLike
{
$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 @@ class PropertyInfo extends VariableLike
{
$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 @@ if ($generateMethodSynopses) {
}
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";
}
}