mirror of
https://github.com/danog/phpdoc.git
synced 2024-11-26 12:04:47 +01:00
More fixes
This commit is contained in:
parent
e3c13d54aa
commit
f8fe13f3eb
@ -3,6 +3,7 @@
|
||||
namespace danog\PhpDoc\PhpDoc;
|
||||
|
||||
use danog\PhpDoc\PhpDoc;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
@ -49,20 +50,20 @@ class ClassDoc extends GenericDoc
|
||||
$type = (string) $type;
|
||||
$name = $property->getName();
|
||||
$comment = '';
|
||||
foreach ($this->builder->parse($property->getDocComment() ?: '/** */')->getTags() as $tag) {
|
||||
foreach ($this->builder->parse($property->getDocComment() ?: '/** */')->children as $tag) {
|
||||
if ($tag instanceof PhpDocTagNode) {
|
||||
if ($tag->name === '@var') {
|
||||
$tag = $tag->value;
|
||||
\assert($tag instanceof VarTagValueNode);
|
||||
$type = (string) $tag->type;
|
||||
$comment = $tag->description;
|
||||
$comment .= $tag->description."\n";
|
||||
break;
|
||||
}
|
||||
if ($tag->name === 'internal') {
|
||||
} elseif ($tag->name === '@internal') {
|
||||
continue 2;
|
||||
}
|
||||
} elseif ($tag instanceof PhpDocTextNode) {
|
||||
$comment .= $tag->text."\n";
|
||||
}
|
||||
if (!$comment) {
|
||||
$comment = \trim($property->getDocComment() ?: '', "\n/* ");
|
||||
}
|
||||
$docReflection .= " * @property $type \$$name $comment\n";
|
||||
}
|
||||
@ -71,7 +72,7 @@ class ClassDoc extends GenericDoc
|
||||
|
||||
$tags = \array_merge($docReflection->getTags(), $doc->getTags());
|
||||
foreach ($tags as $tag) {
|
||||
if ($tag->name === 'property') {
|
||||
if ($tag->name === '@property') {
|
||||
$tag = $tag->value;
|
||||
\assert($tag instanceof PropertyTagValueNode);
|
||||
/** @psalm-suppress InvalidPropertyAssignmentValue */
|
||||
@ -140,7 +141,7 @@ class ClassDoc extends GenericDoc
|
||||
if ($this->properties) {
|
||||
$init .= "## Properties\n";
|
||||
foreach ($this->properties as $name => [$type, $description]) {
|
||||
$init .= "* `\$$name`: `$type` $description";
|
||||
$init .= "* `$name`: `$type` $description";
|
||||
$init .= "\n";
|
||||
}
|
||||
}
|
||||
|
@ -138,12 +138,7 @@ class MethodDoc extends GenericDoc
|
||||
*/
|
||||
public function getSignatureAnchor(): string
|
||||
{
|
||||
$sig = $this->getSignature();
|
||||
$sigLink = \strtolower($sig);
|
||||
$sigLink = \preg_replace('/[^\w ]+/', ' ', $sigLink);
|
||||
$sigLink = \preg_replace('/ +/', ' ', $sigLink);
|
||||
$sigLink = \str_replace(' ', '-', $sigLink);
|
||||
return \trim($sigLink, '-');
|
||||
return $this->name;
|
||||
}
|
||||
/**
|
||||
* Generate markdown for method.
|
||||
@ -152,7 +147,7 @@ class MethodDoc extends GenericDoc
|
||||
*/
|
||||
public function format(?string $namespace = null): string
|
||||
{
|
||||
$sig = '### `'.$this->getSignature()."`";
|
||||
$sig = '### <a name="'.$this->name.'"></a> `'.$this->getSignature()."`";
|
||||
$sig .= "\n\n";
|
||||
$sig .= $this->title;
|
||||
$sig .= "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user