-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow parse and transform to be ran independently #116
base: 1.0.x
Are you sure you want to change the base?
Allow parse and transform to be ran independently #116
Conversation
For phpDocumentor we want to be able to build a TOC for the API documentation and the output of one or more runs of this RST parser and inject that into the Twig templates. In the existing setup, this causes a chicken and egg problem since the TOC is only available after parsing, but we want to add more to the TOC based on the output of other modules. The solution to this scenario is to enable executing the parse and render phase individually. This will allow us to gather the TOC earlier in the application, combine it with other TOC elements, and then later render the output using this updated TOC.
2c1a53b
to
fea2858
Compare
fea2858
to
0856820
Compare
In my previous commit I believed that the meta's could be cached after parsing had completed but the unit tests quickly proved me wrong. During the rendering phase will the dependencies be resolved and persisted in the meta's collection. This means that when we try to persist the cache too soon, that this information is lost. It might be worth investigating if there is a way to resolve this dependencies before rendering; but that is beyond scope of this change.
0856820
to
b82dd67
Compare
Should the newly public API be documented at https://github.com/doctrine/rst-parser/blob/0.1.x/docs/en/builder.rst ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about the docs. It's current state shows how to build rst files in a simple way. Maybe there's place for a advanced section below that shows use cases where the other methods can be explained and why someone might want to use them.
@@ -220,8 +219,10 @@ private function parse(string $directory, string $targetDirectory, ParseQueue $p | |||
$parseQueueProcessor->process($parseQueue); | |||
} | |||
|
|||
private function render(string $directory, string $targetDirectory): void | |||
public function render(string $directory, string $targetDirectory): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Render became public and should get its own tests.
For phpDocumentor we want to be able to build a TOC for the API
documentation and the output of one or more runs of this RST parser and
inject that into the Twig templates.
In the existing setup, this causes a chicken and egg problem since the
TOC is only available after parsing, but we want to add more to the TOC
based on the output of other modules.
The solution to this scenario is to enable executing the parse and
render phase individually. This will allow us to gather the TOC earlier
in the application, combine it with other TOC elements, and then later
render the output using this updated TOC.