All Projects → UAVCAN → nunavut

UAVCAN / nunavut

Licence: other
Generate code from DSDL using PyDSDL and Jinja2

Programming Languages

python
139335 projects - #7 most used programming language
Jinja
831 projects
C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
CMake
9771 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nunavut

celerio
Celerio is a code generator tool for data-driven application.
Stars: ✭ 73 (+217.39%)
Mutual labels:  code-generator, code-generation
kube-code-generator
Kubernetes code generator docker image
Stars: ✭ 60 (+160.87%)
Mutual labels:  code-generator, code-generation
WebApiToTypeScript
A tool for code generating TypeScript endpoints for your ASP.NET Web API controllers
Stars: ✭ 26 (+13.04%)
Mutual labels:  code-generator, code-generation
GraphQL.Tools
GraphQL.Tools is a GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
Stars: ✭ 49 (+113.04%)
Mutual labels:  code-generator, code-generation
mr.boilerplate
Online app to generate Scala boilerplate
Stars: ✭ 32 (+39.13%)
Mutual labels:  code-generator, code-generation
yakut
Simple CLI tool for diagnostics and debugging of Cyphal networks
Stars: ✭ 29 (+26.09%)
Mutual labels:  uavcan, dsdl
django-code-generator
Generate code from your Django models for faster development
Stars: ✭ 35 (+52.17%)
Mutual labels:  code-generator, code-generation
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (+560.87%)
Mutual labels:  code-generator, code-generation
typed-astunparse
Python 3 AST unparser with type comments support.
Stars: ✭ 27 (+17.39%)
Mutual labels:  code-generator, code-generation
tiles
Programmatic code generation
Stars: ✭ 78 (+239.13%)
Mutual labels:  code-generator, code-generation
evon
Fast and versatile event dispatcher code generator for Golang
Stars: ✭ 15 (-34.78%)
Mutual labels:  code-generator, code-generation
copygen
Go generator to copy values from type to type and fields from struct to struct (copier without reflection). Generate any code based on types.
Stars: ✭ 121 (+426.09%)
Mutual labels:  code-generator, code-generation
Evolutility Ui Jquery
Model-driven Web UI for CRUD using REST or localStorage.
Stars: ✭ 164 (+613.04%)
Mutual labels:  code-generator, code-generation
regen
Easy C++ reflection and code generation
Stars: ✭ 29 (+26.09%)
Mutual labels:  code-generator, code-generation
Jennifer
Jennifer is a code generator for Go
Stars: ✭ 2,257 (+9713.04%)
Mutual labels:  code-generator, code-generation
oag
Idiomatic Go (Golang) client package generation from OpenAPI documents
Stars: ✭ 51 (+121.74%)
Mutual labels:  code-generator, code-generation
Dbcc
CAN DBC to C (and CSV, JSON and XML) compiler using the mpc parser combinator library
Stars: ✭ 142 (+517.39%)
Mutual labels:  code-generator, code-generation
Xcassetpacker
A command line tool for converting a folder of images into an .xcasset package for Xcode
Stars: ✭ 150 (+552.17%)
Mutual labels:  code-generator, code-generation
EasyEE-Auto
EasyEE 自动化代码生成器。EasyEE Automated code generator.
Stars: ✭ 39 (+69.57%)
Mutual labels:  code-generator, code-generation
Kodgen
C++17 parser and code generator
Stars: ✭ 19 (-17.39%)
Mutual labels:  code-generator, code-generation

Nunavut: DSDL transpiler

tox build (main) Build status
static analysis Sonarcloud Quality Gate Sonarcloud bugs
unit test code coverage Sonarcloud coverage
Python versions supported Supported Python Versions
latest released version PyPI Release Version
documentation Documentation Status
license MIT license
community/support OpenCyphal forum

Nunavut is a source-to-source compiler (transpiler) that automatically converts OpenCyphal DSDL definitions into source code in a specified target programming language. It is constructed as a template engine that exposes a PyDSDL abstract syntax tree to Jinja2 templates allowing authors to generate code, schemas, metadata, documentation, etc.

Nunavut DSDL transcompilation pipeline.

Nunavut ships with built-in support for some programming languages, and it can be used to generate code for other languages if custom templates (and some glue logic) are provided. Currently, the following languages are supported out of the box:

  • C11 (generates header-only libraries)
  • HTML (generates documentation pages) (experimental support)

The following languages are currently on the roadmap:

Nunavut is named after the Canadian territory. We chose the name because it is a beautiful word to say and read.

Installation

Nunavut depends on PyDSDL.

Install from PIP:

pip install -U nunavut

Examples

The examples do not replace the documentation, please do endeavor to read it.

Generate C headers using the command-line tool

This example assumes that the public regulated namespace directories reg and uavcan reside under public_regulated_data_types/. Nunavut is invoked to generate code for the former.

nnvg --target-language c --target-endianness=little --enable-serialization-asserts public_regulated_data_types/reg --lookup-dir public_regulated_data_types/uavcan

Generate HTML documentation pages using the command-line tool

See above assumptions. The below commands generate documentation for the reg namespace. Note that we have to generate documentation for the uavcan namespace as well, because there are types in reg that will link to uavcan documentation sections.

nnvg --experimental-languages --target-language html public_regulated_data_types/reg --lookup-dir public_regulated_data_types/uavcan
nnvg --experimental-languages --target-language html public_regulated_data_types/uavcan

Use custom templates

Partial example: generating a C struct

   /*
    * UAVCAN data structure definition
    *
    * Auto-generated, do not edit.
    *
    * Source file: {{T.source_file_path.as_posix()}}
    */

    #ifndef {{T.full_name | ln.c.macrofy}}
    #define {{T.full_name | ln.c.macrofy}}

    {%- for constant in T.constants %}
    #define {{ T | ln.c.macrofy }}_{{ constant.name | ln.c.macrofy }} {{ constant | constant_value }}
    {%- endfor %}

    typedef struct
    {
        /*
            Note that we're not handling union types properly in this simplified example.
            Unions take a bit more logic to generate correctly.
        */
        {%- for field in T.fields_except_padding %}
            {{ field.data_type | declaration }} {{ field | id }}
            {%- if field.data_type is ArrayType -%}
                [{{ field.data_type.capacity }}]
            {%- endif -%};
        {%- if field is VariableLengthArrayType %}
            {{ typename_unsigned_length }} {{ field | id }}_length;
        {%- endif -%}
        {%- endfor %}
...

    } {{ T | full_reference_name }};

    #endif // {{T.full_name | ln.c.macrofy}}

More examples

Where to find more examples to get started:

  1. See built-in templates under nunavut.lang.LANGUAGE.templates.
  2. API usage examples can be found in the Pycyphal library.

Bundled third-party software

Nunavut embeds the following third-party software libraries into its source (i.e. these are not dependencies and do not need to be installed):

  • Jinja2 by Armin Ronacher and contributors, BSD 3-clause license.
  • markupsafe by Armin Ronacher and contributors, BSD 3-clause license (needed for Jinja).

Documentation

The documentation for Nunavut is hosted on readthedocs.io:

Nunavut is part of the UAVCAN project:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].