phpDocumentor / ReflectionDocBlock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description formatter

WinterSilence opened this issue · comments

commented

Now, we can't use tag Formatter for format description of inline tags .
Example:
we have DocBlock:

/**
 * @param string $a *parameter* description, {@see self::methodName() *method* description}
 */

and want render @param with Markdown formatter:

$paramTag->render($markdownFormatter);

expected result:
param string $a <em>parameter</em> description, {@see self::methodName() <em>method</em> description}
actual result:
param string $a <em>parameter</em> description, {@see self::methodName() *method* description}

I don't know what your markdown formatter looks like, but it sounds to me like you have an issue in there.

The render functions are quite limited, so even in phpDocumentor itself we are using a different way to render the descriptions.

You might want to check this part of our code: https://github.com/phpDocumentor/phpDocumentor/blob/master/src/phpDocumentor/Transformer/Writer/Twig/Extension.php#L388

I hope this will help you a step forward.

commented

@jaapio

I don't know what your markdown formatter looks like

me too, it's only for clear example. focus on "we can't set any formatter for Description"

You can do this, using the render function in

public function render(?Formatter $formatter = null): string

I admit that you will have to write some more code than just a flew lines. So I would be open for suggestions to improve this. You should never use the __toString if you want to have a custom output format. This is just in there to be able to reconstruct exactly what came in, a php docblock.

commented

@jaapio

I admit that you will have to write some more code than just a flew lines.

more? need write solutions for ~20 tags, only for format descriptions

If you have a question I'm happy to answer it. But right now I think I provided all information I can in a short limited time range.

Please provide more information about what you are trying to achieve, if you need more help. Based on the information I have right now I don't think there is an issue.

It might be wise to have a look at what other people did using phpDocumentor as an application. There are templates available on github which might do exactly what you are trying to achieve. That will save you a lot of time if you are trying to get api documentation out of your applications' code.

commented

@jaapio

It might be wise to have a look at what other people did using phpDocumentor as an application. There are templates available on github which might do exactly what you are trying to achieve.

this is the first thing i did

You can do this, using the render function in

it's dead loop because

return $formatter->format($this);

Finally I'm extend Description/DescriptionFactory.