我们目前使用ApiGen来记录我们的PHP类。在文档注释中,有许多内联@link语句,如下所示:
{@link AbstractValidatableItem}运行ApiGen时,该语句扩展到如下链接(请忽略href):
\NSLevel1\NSLevel2\NSLevel3\AbstractValidatableItem
通过许多内联链接,这将创建一个几乎不可读的文本。因此,我希望有一个具有简单类、接口或方法名称的链接:
AbstractValidatableItem
有什么方法可以在不修补ApiGen的情况下完成此操作吗?我已经试过了
{@link AbstractValidatableItem AbstractValidatableItem}但这似乎破坏了对链接的解析。
发布于 2015-08-13 13:06:09
这不是我喜欢的解决方案,但我设法快速修补了ApiGen以解决问题:
--- apigen/apigen/src/Templating/Filters/Helpers/ElementLinkFactory.php.orig Do Aug 13 14:51:13 2015
+++ apigen/apigen/src/Templating/Filters/Helpers/ElementLinkFactory.php Do Aug 13 14:51:33 2015
@@ -39,6 +39,7 @@ class ElementLinkFactory
$this->linkBuilder = $linkBuilder;
}
+ private $FULLY_QUALIFIED_NAMES=false;
/**
* @return string
@@ -75,7 +76,7 @@ class ElementLinkFactory
{
return $this->linkBuilder->build(
$this->elementUrlFactory->createForClass($reflectionClass),
- $reflectionClass->getName(),
+ $this->FULLY_QUALIFIED_NAMES ? $reflectionClass->getName() : $reflectionClass->getShortName(),
TRUE,
$classes
);
@@ -89,7 +90,7 @@ class ElementLinkFactory
{
return $this->linkBuilder->build(
$this->elementUrlFactory->createForMethod($reflectionMethod),
- $reflectionMethod->getDeclaringClassName() . '::' . $reflectionMethod->getName() . '()',
+ ( $this->FULLY_QUALIFIED_NAMES ? $reflectionMethod->getDeclaringClass()->getName() : $reflectionMethod->getDeclaringClass()->getShortName() ) . '::' . ( $this->FULLY_QUALIFIED_NAMES ? $reflectionMethod->getName() : $reflectionMethod->getShortName()) . '()',
FALSE,
$classes
);该修补程序使其在解析类上使用getShortName()而不是getName()。
https://stackoverflow.com/questions/31984680
复制相似问题