nunavut icon indicating copy to clipboard operation
nunavut copied to clipboard

Nunavut 4.0 proposal

Open thirtytwobits opened this issue 6 months ago • 0 comments

Nunavut was never designed as a library. It started as a CLI, separate from libcanard, to integrate with makefiles and later cmake. It grew organically from its origin as a quick-and-dirty wrapper around jinja and the internals have gone through torturous evolutions as new languages were added and features requested. With 3.0 nunavut will start acting more like gcc in handling lists of files instead of directories and in managing dependencies between dsdl files. To get there it took on more debt supporting an incompatible "legacy" mode that is no longer aligned with the newer CLI or generate_all helper function.

This issue is a proposal for significant changes to the library's internals with Nunavut 4.0 to make it more usable as a python library as well as a CLI. To do this 4.0 will remove all deprecated paths in the core and will refactor the various generator types to be the primary API instead of the generate_all function, with it's burdening argument list. By moving to a builder pattern for a single generator object (instead of separate support and code generators) the CLI will use the same pattern and code to construct objects as any direct consumer. For example:

# CLI
NewGeneratorBuilder(**args).create().generate_all()

# API
NewGeneratorBuilder()
    .set_target_files(dsdl_files)
    .set_output_folder(outdir)
    .set_target_language('c')
    .create()
    .generate_all()

Simplification - De-creeping features

If this proposal is agreed upon then the following features will be marked as deprecated in 3.0 and removed in 4.0 in order to simplify Nunavut.

Non-Jinja file processing

All post processing features will be removed where users will be encouraged to use a more unix-like model of pipelining nnvg outputs through other utilities instead of asking nnvg to do it for them. Specifically the following CLI options will be removed:

  1. --trim-blocks
  2. --lstrip-blocks
  3. --pp-max-emptylines
  4. --pp-trim-trailing-whitespace
  5. --pp-run-program
  6. --pp-run-program-arg

To this end, the "listing" options like --list-outputs may be modified slightly to support shell pipelines like nnvg --list-outputs | xargs awk 'awk stuff blarg'

Un-targeted code generation

Un-targeted generation support (i.e. no target language specified) will be removed as this was never used and introduces a lot of additional edge cases that requires conditional checks and tests. While the ln global will remain, all templates will require a target_language to be set and not doing so will be an error checked as a precondition by generators.

thirtytwobits avatar Jul 25 '24 04:07 thirtytwobits