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

Improve algorithmic codegen, return multiline string #167

Merged
merged 6 commits into from
Dec 13, 2022

Conversation

ZibingZhang
Copy link
Contributor

Overview

Algorithmic codegen now returns a multiline string instead of a very long single line string.

Details

We keep track of our indentation level as we traverse through the AST.

Example

old

\If{$x < y$} \State \Return $x$ \EndIf

new

If{$x < y$}
    \State \Return $x$
\EndIf

References

#57

Blocked by

None

@ZibingZhang ZibingZhang requested a review from odashi as a code owner December 12, 2022 23:31
src/latexify/codegen/algorithmic_codegen.py Outdated Show resolved Hide resolved
src/latexify/codegen/algorithmic_codegen.py Outdated Show resolved Hide resolved
src/latexify/codegen/algorithmic_codegen.py Outdated Show resolved Hide resolved
@@ -3,6 +3,8 @@
from __future__ import annotations

import ast
import contextlib
from typing import Generator
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use collections.abc rather than typing for generic types.

Suggested change
from typing import Generator
from collections.abc import Generator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious as to why not use typing

Copy link
Collaborator

@odashi odashi Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odashi
Copy link
Collaborator

odashi commented Dec 13, 2022

LGTM, merge this PR

@odashi odashi merged commit 2b7ad27 into google:main Dec 13, 2022
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.

2 participants