Releases: jwdevantier/gcgen
Releases · jwdevantier/gcgen
Emitter bugfix
Full Changelog: v0.1.1...v0.1.2
Fixed a corner-case bug in the emitter code causing an additional newline to be made.
Added a nix development environment.
new snippet syntax
* rewrite snippet parser to use different snippet open- and close
syntax. This enables support for using snippets in languages w/o
line comments, i.e. the comment spans multiple lines until
explicitly ended.
Examples are HTML ('<!-- ... -->'), CSS and classic C ('/* ... */').
The old parser would attempt submitting the remainder of the line to
the JSON parser for parsing, causing an error. Given explicit open-
and end tags, the parser will disregard anything following the close
tag.
* minor adjustments to remove warnings from mypy
* mark package as using types - this enables code consuming this library
to benefit from the type annotations.
Rework Emitter -> Section
- Split
Emitter
class.Emitter
now takes aSection
and some buffer, writing the output of theSection
into the buffer. Section
retains theEmitter
class write API, butemitln_r
/emitln_d
are deprecated in favor ofemitln(...).indent()
/emitln(...).dedent()
.- All output methods in
Section
return theSection
itself - it is a fluent API permitting something likeemitln("foo").indent()
instead ofemitln_r("foo")
which is arguably clearer to read. Section.add_section()
now takes a section as an argument -Sections
can thus be created and returned as a value to be used inside another Section unlike before.Section.ensure_padding_lines(n)
has gotten several bugfixes.- If called at the start of output, it is ignored.
- If called at the very end of output, it is ignored.
- Padding is intended to be analogous to padding in a HTML-sense, providing spacing BETWEEN contents, not creating a margin surrounding the snippet.
- Finally, multiple padding calls merge, meaning the highest padding requirement takes effect. Explicitly added newlines count toward the padding requirements.
v0.0.7
- emitter -
ensure_padding_lines(num_lines: int)
-- use to guarantee at least n empty lines of spacing between the next line and the prior line (if any). Is a no-op if called with the emitter's buffer being empty (no content written out yet). This method is useful when wanting to ensure a certain amount of spacing between paragraphs/block of code. gcgen.api.tree.py
-NodeVisitor
andNodeTransformer
classes and associatedon_visit
andon_transform
decorators. Collectively, the tree module provides utility code to traverse/visit and transform/rewrite nested object structures (~trees). This is very useful when reading in a model which needs validation (NodeVisitor
's), some transformation into a more codegen-friendly format (NodeTransformer
's) and finally when writing out the model to code (NodeVisitor
). This approach is inspired by multi-pass compilers.
v0.0.6
- fixed bug where a snippet ending in the middle of a line would cause the end tag to be written on that same line, causing the next parse of the file to fail.
<project_root>
directory (as identified by the first directory up which contains agcgen_project.ini
file or, failing that the first directory up which has a.git
folder) is now added to the front ofsys.path
. This means imports of code relative is done relative to the project directory.
v0.0.5
- snippets may now take a single argument which has to be a valid JSON value
- default open/close tags are
<<?
and?>>
instead of[[start
andend]]
-- many editors balance brackets, so the former default was unwieldy.
v0.0.4
missing file
0.0.3
tweak default log levels
v0.0.2
fix project url, add gh repo link to docs
first release
Initial release.
Still some rough edges, particularly as regards to pretty-printing errors on the terminal.