mirror of
https://github.com/danog/phpdoc.git
synced 2024-11-26 12:04:47 +01:00
Fixes
This commit is contained in:
parent
57c168c5d0
commit
f6361bfc87
@ -34,6 +34,7 @@ Create docblock builder.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$namespace`: `string` Namespace (defaults to package namespace)
|
||||
|
||||
|
||||
@ -44,6 +45,7 @@ Set authors.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$authors`: `\phpDocumentor\Reflection\DocBlock\Tags\Author[]` Authors
|
||||
|
||||
|
||||
@ -59,6 +61,7 @@ Set scan mode.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$mode`: `int` Scan mode.
|
||||
|
||||
|
||||
@ -69,6 +72,7 @@ Set filter to ignore certain classes.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$ignore`: `callable`
|
||||
Full type:
|
||||
```
|
||||
@ -83,6 +87,7 @@ Set output directory.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$output`: `string` Output directory
|
||||
|
||||
|
||||
@ -93,6 +98,7 @@ Set project name.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$name`: `string` Name
|
||||
|
||||
|
||||
@ -103,6 +109,7 @@ Set project description.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$description`: `string` Project description
|
||||
|
||||
|
||||
@ -113,6 +120,7 @@ Set project image.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$image`: `string` Project image
|
||||
|
||||
|
||||
@ -123,6 +131,7 @@ Add Jekyll front matter.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$key`: `string` Key
|
||||
* `$value`: `string` Value
|
||||
|
||||
@ -134,6 +143,7 @@ Add Jekyll index front matter.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
* `$key`: `string` Key
|
||||
* `$value`: `string` Value
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
title: danog/phpdoc
|
||||
description: Simple markdown PHPDOC documentation generator with psalm type annotation support.
|
||||
description: "Simple markdown PHPDOC documentation generator with psalm type annotation support."
|
||||
title: "danog/phpdoc"
|
||||
|
||||
---
|
||||
# `danog/phpdoc`
|
||||
|
||||
|
@ -45,7 +45,8 @@
|
||||
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --dry-run",
|
||||
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff",
|
||||
"psalm": "psalm",
|
||||
"docs": "@phpdoc"
|
||||
"docs": "@phpdoc",
|
||||
"phpdoc": "bin/phpdoc API"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
|
@ -114,7 +114,7 @@ class ClassDoc extends GenericDoc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(): string
|
||||
public function format(?string $namespace = null): string
|
||||
{
|
||||
$init = parent::format();
|
||||
if ($this->constants) {
|
||||
@ -136,7 +136,7 @@ class ClassDoc extends GenericDoc
|
||||
$init .= "\n";
|
||||
$init .= "## Methods:\n";
|
||||
foreach ($this->methods as $method) {
|
||||
$init .= $method->format();
|
||||
$init .= $method->format($namespace ?? $this->namespace);
|
||||
$init .= "\n";
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ class FunctionDoc extends MethodDoc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(): string
|
||||
public function format(?string $namespace = null): string
|
||||
{
|
||||
$formatted = parent::format();
|
||||
$formatted = parent::format($namespace);
|
||||
$formatted .= "---\n";
|
||||
$formatted .= "Generated by [danog/phpdoc](https://phpdoc.daniil.it)\n";
|
||||
return $formatted;
|
||||
|
@ -107,8 +107,10 @@ abstract class GenericDoc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function seeAlso(): string
|
||||
public function seeAlso(string $namespace): string
|
||||
{
|
||||
$namespace = \explode('\\', $namespace);
|
||||
|
||||
$empty = [];
|
||||
$seeAlso = '';
|
||||
foreach ($this->seeAlso as $see) {
|
||||
@ -122,28 +124,16 @@ abstract class GenericDoc
|
||||
$seeAlso .= "* `$ref`\n";
|
||||
continue;
|
||||
}
|
||||
$from = \explode('\\', $this->resolvedClassName.".md");
|
||||
|
||||
\array_shift($to);
|
||||
\array_unshift($to, ...\array_fill(0, \count($namespace), '..'));
|
||||
$relPath = $to;
|
||||
foreach ($from as $depth => $dir) {
|
||||
// find first non-matching dir
|
||||
if ($dir === $to[$depth]) {
|
||||
// ignore this directory
|
||||
\array_shift($relPath);
|
||||
} else {
|
||||
// get number of remaining dirs to $from
|
||||
$remaining = \count($from) - $depth;
|
||||
if ($remaining > 1) {
|
||||
// add traversals up to first matching dir
|
||||
$padLength = (\count($relPath) + $remaining - 1) * -1;
|
||||
$relPath = \array_pad($relPath, $padLength, '..');
|
||||
break;
|
||||
}
|
||||
$relPath[0] = './'.$relPath[0];
|
||||
}
|
||||
}
|
||||
$path = \implode('/', $relPath);
|
||||
|
||||
if ($path === '../../../danog/MadelineProto/EventHandler.md') {
|
||||
\var_dump($namespace);
|
||||
}
|
||||
|
||||
if (!$desc = $see->getDescription()) {
|
||||
if ($desc = $this->builder->getTitle($ref)) {
|
||||
$desc = "`$ref`: $desc";
|
||||
@ -168,13 +158,13 @@ abstract class GenericDoc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(): string
|
||||
public function format(?string $namespace = null): string
|
||||
{
|
||||
$authors = '';
|
||||
foreach ($this->authors as $author) {
|
||||
$authors .= "> Author: $author \n";
|
||||
}
|
||||
$seeAlso = $this->seeAlso();
|
||||
$seeAlso = $this->seeAlso($namespace ?? $this->namespace);
|
||||
$frontMatter = $this->builder->getFrontMatter(
|
||||
[
|
||||
'title' => "{$this->name}: {$this->title}",
|
||||
|
@ -113,7 +113,7 @@ class MethodDoc extends GenericDoc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(): string
|
||||
public function format(?string $namespace = null): string
|
||||
{
|
||||
$sig = '### `'.$this->getSignature()."`";
|
||||
$sig .= "\n\n";
|
||||
@ -143,7 +143,7 @@ class MethodDoc extends GenericDoc
|
||||
if (isset($this->psalmReturn)) {
|
||||
$sig .= "\nFully typed return value:\n```\n".$this->psalmReturn."\n```";
|
||||
}
|
||||
$sig .= $this->seeAlso();
|
||||
$sig .= $this->seeAlso($namespace ?? $this->namespace);
|
||||
$sig .= "\n";
|
||||
return $sig;
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ Simple markdown PHPDOC documentation generator with psalm type annotation suppor
|
||||
|
||||
|
||||
---
|
||||
Generated by [danog/phpdoc](https://phpdoc.daniil.it).
|
||||
Generated by [danog/phpdoc](https://phpdoc.daniil.it).
|
||||
|
Loading…
Reference in New Issue
Block a user