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

Refactor NRT rendering #287

Merged
merged 32 commits into from
Nov 28, 2022
Merged

Refactor NRT rendering #287

merged 32 commits into from
Nov 28, 2022

Conversation

josiah-wolf-oberholtzer
Copy link
Contributor

@josiah-wolf-oberholtzer josiah-wolf-oberholtzer commented Nov 24, 2022

Renderables (classes implementing __render__) should now use the signature:

class SupportsRender(Protocol):
    def __render__(
        self,
        output_file_path: Optional[PathLike] = None,
        render_directory_path: Optional[PathLike] = None,
        **kwargs,
    ) -> Union[
        Callable[[], Tuple[Callable[[], Coroutine[None, None, int]], Path]],
        Tuple[Callable[[], Coroutine[None, None, int]], Path],
    ]:
        ...

... returning a 2-tuple of:

  • a zero-argument callable that returns a coroutine returning an exit code
  • and the path to the anticipated output

... or a zero-argument callable that results in that 2-tuple (which makes rendering online buffers in Supriya's Sphinx documentation possible given that the buffer is offline by the time the HTML is rendered out).

While this is a kind of tricky-interface, it really simplifies the internals of Session-rendering. Sessions can now determine the expected output paths of all renderables in their dependency graph before anything is rendered, and can perform rendering asynchronously.

Sessions can now also be rendered with their output suppressed, e.g. sent to /dev/null (or NUL on Windows), which greatly simplifies doing offline analysis where the only desired output is from a manually-written buffer.

@josiah-wolf-oberholtzer josiah-wolf-oberholtzer marked this pull request as ready for review November 27, 2022 17:38
@josiah-wolf-oberholtzer josiah-wolf-oberholtzer merged commit 4836d31 into main Nov 28, 2022
@josiah-wolf-oberholtzer josiah-wolf-oberholtzer deleted the refactor-renderer branch November 28, 2022 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant