Dogma Codegen

Code generation for the Dogma libraries

Build Status Coverage Status Pub Status Stories in Ready

Join the chat at https://gitter.im/dogma-dart/dogma-dart.github.io

Release Status

The Dogma Codegen library provides mechanisms to generate source code that interfaces with the Dogma libraries for creating data layers. Using the library is not mandatory, but its usage is recommended as it eliminates the boilerplate code that needs to be written using the libraries.

Dogma Codegen can be used directly to generate source code but it is also leveraged to parse different file formats describing models and full RESTful APIs. Before using Dogma Codegen directly consider using one of those libraries instead as even more code can be automatically generated.

| Library | Models | Unmodifiable Views | Convert | Mapper | Fluent Queries | |--|-|-|-|-|-| | Codegen | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | | JSON Schema | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | | Swagger | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |

Getting Started

Dogma Codegen should be installed as a developer dependency. Add the following to the project's pubspec.yaml.

dev_dependencies:
  dogma_codegen: ^0.0.1

It can also be installed using den by using the following command den install dogma_codegen --dev.

Package Conventions

Dogma Codegen is opinionated on the layout of the package. The following showcases the default structure.

+ lib
  + src
    + models
      foo.dart
      bar.dart
    + convert
      foo_convert.dart
      bar_convert.dart
  models.dart
  convert.dart

Building the Library

Dogma Codegen uses a build.dart file at the root of the package to generate source code. For packages following the above conventions a working build.dart looks like.

import 'dart:async';
import 'package:dogma_codegen/build.dart';

Future<Null> main(List<String> args) async {
  await build(args);
}

If the layout of the package is different then view the documentation on the build method and modify the values accordingly. It is however highly recommended to stick with the prescribed layout.

Full Rebuilds

The build.dart file can be invoked directly which will cause a full rebuild of the library.

Incremental Builds

Dogma Codegen supports incremental builds through the build_system library. Any change to the model files will be result in a rebuild when using build_system. See its documentation for the most up to date information on using it. Dogma Codegen will continue to follow the conventions of that library to ensure the built files are up to date with the model definitions.

Example Projects

Working examples of various third-party APIs are available collected at the Dogma Dart APIs Organization. These can be referenced for getting started with the Dogma libraries.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

dogma_codegen.analyzer
dogma_codegen.build

Contains the build function which orchestrates the build process for a library.

dogma_codegen.codegen
dogma_codegen.identifier

Functions for handling identifiers.

dogma_codegen.metadata
dogma_codegen.path

Functions for handling uri paths.

dogma_codegen.template

Functionality for working with mustache templates.