1
0
mirror of https://github.com/danog/phpdoc.git synced 2024-11-30 04:29:12 +01:00

Add separate signature anchor method

This commit is contained in:
Daniil Gentili 2023-06-13 21:08:55 +02:00
parent 1c410ad894
commit 6130ea30c5
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -122,13 +122,24 @@ class MethodDoc extends GenericDoc
* @return string * @return string
*/ */
public function getSignatureLink(): string public function getSignatureLink(): string
{
$sig = $this->getSignature();
$sigLink = $this->getSignatureAnchor();
return "[`$sig`](#$sigLink)";
}
/**
* Get method signature link.
*
* @return string
*/
public function getSignatureAnchor(): string
{ {
$sig = $this->getSignature(); $sig = $this->getSignature();
$sigLink = strtolower($sig); $sigLink = strtolower($sig);
$sigLink = preg_replace('/[^\w ]+/', ' ', $sigLink); $sigLink = preg_replace('/[^\w ]+/', ' ', $sigLink);
$sigLink = preg_replace('/ +/', ' ', $sigLink); $sigLink = preg_replace('/ +/', ' ', $sigLink);
$sigLink = str_replace(' ', '-', $sigLink); $sigLink = str_replace(' ', '-', $sigLink);
return "[`$sig`](#$sigLink)"; return $sigLink;
} }
/** /**
* Generate markdown for method. * Generate markdown for method.