-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render source code using python functions instead of Jinja templates
- Type checker can help out when updating the functions - The output formatting is much more readable now
- Loading branch information
Showing
21 changed files
with
1,217 additions
and
945 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
recursive-include robotpy_build/pybind11/include *.h | ||
recursive-include robotpy_build/autowrap *.j2 | ||
recursive-include robotpy_build/include *.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import io | ||
import contextlib | ||
import inspect | ||
|
||
|
||
class RenderBuffer: | ||
def __init__(self) -> None: | ||
self._buffer = io.StringIO() | ||
|
||
self._indent = "" | ||
self._indentlen = 0 | ||
|
||
def getvalue(self) -> str: | ||
return self._buffer.getvalue() | ||
|
||
def rel_indent(self, spaces: int): | ||
self._indentlen += spaces | ||
self._indent = " " * self._indentlen | ||
|
||
@contextlib.contextmanager | ||
def indent(self, spaces: int = 2): | ||
self._indentlen += spaces | ||
self._indent = " " * self._indentlen | ||
try: | ||
yield | ||
finally: | ||
self._indentlen -= spaces | ||
self._indent = " " * self._indentlen | ||
|
||
def writeln(self, s: str = ""): | ||
if not s: | ||
self._buffer.write("\n") | ||
else: | ||
for line in s.splitlines(False): | ||
if line: | ||
self._buffer.write(f"{self._indent}{line}\n") | ||
else: | ||
self._buffer.write("\n") | ||
|
||
def write_trim(self, s: str): | ||
for line in inspect.cleandoc(s).splitlines(False): | ||
if line: | ||
self._buffer.write(f"{self._indent}{line}\n") | ||
else: | ||
self._buffer.write("\n") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.