Skip to content

Releases: jwdevantier/gcgen

Emitter bugfix

25 Jul 09:03
Compare
Choose a tag to compare

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

08 Feb 21:47
Compare
Choose a tag to compare
* 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

19 Aug 21:01
Compare
Choose a tag to compare
  • Split Emitter class. Emitter now takes a Section and some buffer, writing the output of the Section into the buffer.
  • Section retains the Emitter class write API, but emitln_r/emitln_d are deprecated in favor of emitln(...).indent()/emitln(...).dedent().
  • All output methods in Section return the Section itself - it is a fluent API permitting something like emitln("foo").indent() instead of emitln_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

22 Jul 21:48
Compare
Choose a tag to compare
  • 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 and NodeTransformer classes and associated on_visit and on_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

16 Jul 19:13
Compare
Choose a tag to compare
  • 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 a gcgen_project.ini file or, failing that the first directory up which has a .git folder) is now added to the front of sys.path. This means imports of code relative is done relative to the project directory.

v0.0.5

06 Jul 22:13
Compare
Choose a tag to compare
  • snippets may now take a single argument which has to be a valid JSON value
  • default open/close tags are <<? and ?>> instead of [[start and end]] -- many editors balance brackets, so the former default was unwieldy.

v0.0.4

06 Jul 13:02
Compare
Choose a tag to compare
missing file

0.0.3

10 Jun 19:55
Compare
Choose a tag to compare
tweak default log levels

v0.0.2

06 Jun 20:58
Compare
Choose a tag to compare
fix project url, add gh repo link to docs

first release

06 Jun 20:48
Compare
Choose a tag to compare

Initial release.

Still some rough edges, particularly as regards to pretty-printing errors on the terminal.