move formatting from JS to PHP
[mdref/mdref] / mdref / Generator / SeeAlso.php
1 <?php
2
3 namespace mdref\Generator;
4 use phpDocumentor\Reflection\DocBlock;
5
6
7 class SeeAlso extends Scrap {
8 public function __toString() : string {
9 return parent::toString(__FILE__, __COMPILER_HALT_OFFSET__);
10 }
11 }
12
13 /** @var $doc DocBlock */
14 /** @var $patch callable as function(string, \Reflector) */
15
16 __HALT_COMPILER();
17 <?php
18 if (($sees = $doc?->getTagsByName("see"))) :
19 ?>See also <?php
20 foreach ($sees as $i => $see) :
21 /** @var $see DocBlock\Tags\See */
22 if (($desc = $see->getDescription())) :
23 ?>[<?= $see->getDescription() ?>](<?= $see->getReference() ?>)<?php
24 else :
25 ?><?= $see->getReference() ?><?php
26 endif;
27 if ($i < count($sees)) :
28 if ($i === count($sees) - 1) :
29 ?>.<?php
30 else :
31 ?>, <?php
32 endif;
33 if ($i === count($sees) - 2) :
34 ?>and <?php
35 endif;
36 endif;
37 endforeach;
38 endif;
39