Skip to content
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

Open
wants to merge 2 commits into
base: 1.0.x
Choose a base branch
from

Conversation

mvriel
Copy link
Contributor

@mvriel mvriel commented Jan 26, 2020

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.

@mvriel mvriel requested a review from jwage January 26, 2020 16:17
@greg0ire greg0ire changed the base branch from master to 1.0 November 21, 2020 13:32
@greg0ire greg0ire changed the base branch from 1.0 to 1.0.x November 21, 2020 15:03
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.
@greg0ire greg0ire force-pushed the allow-parsing-and-rendering-to-be-ran-seperately branch 2 times, most recently from 2c1a53b to fea2858 Compare December 5, 2020 22:30
@greg0ire greg0ire added the Enhancement New feature or request label Dec 5, 2020
@greg0ire greg0ire force-pushed the allow-parsing-and-rendering-to-be-ran-seperately branch from fea2858 to 0856820 Compare December 5, 2020 22:45
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.
@greg0ire greg0ire force-pushed the allow-parsing-and-rendering-to-be-ran-seperately branch from 0856820 to b82dd67 Compare December 5, 2020 22:49
@greg0ire
Copy link
Member

greg0ire commented Dec 5, 2020

Should the newly public API be documented at https://github.com/doctrine/rst-parser/blob/0.1.x/docs/en/builder.rst ?

Copy link
Member

@SenseException SenseException left a 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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants