Skip to content

Commit

Permalink
Improve documentation generation
Browse files Browse the repository at this point in the history
- Really trim leading and trailing hyphens (single hyphens were not trimmed before)
- Create the necesary directories for even namespaced methods when generating methodsynopsis
  • Loading branch information
kocsismate committed Nov 30, 2024
1 parent be69262 commit b06f2bc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
}
}
Expand Down

0 comments on commit b06f2bc

Please sign in to comment.