renderable 0.1.13

Renderable #

An element-model-based Dart code generator. Renderable's AnalyzerConverter can convert SourceGen code to Renderable code by calling one method.

RoadMap #

  • [x] File
  • [x] Import
  • [x] Class
  • [x] Function
  • [ ] Statement
    • [x] raw statement
    • [x] variable declaration
    • [x] assignment
    • [x] compound assignment
    • [x] basic math (+, -, *, /, %)
    • [ ] if/else/switch/case condition statement
    • [ ] for/while loop statement
    • [ ] type test
    • [ ] relational operator
    • [ ] logic operator
    • [ ] bitwise and shift operators
    • [ ] other
  • [x] Value
  • [ ] Miscellaneous
    • [ ] typedef
    • [ ] part / part of
  • [ ] Demo
    • [x] class basic info
    • [x] class field
    • [x] class method
    • [ ] class getter
    • [ ] class setter
    • [ ] function
    • [x] statement
    • [x] value
    • [ ] subclass
    • [ ] misc

Quick Start #

Simple Demo #

let's create a simple class named 'HelloWorld'.

import 'package:renderable/renderable.dart';

void main() {
  FileElement(
    filePath: 'helloWorld.dart',
    renders: [
      ClassElement(
        name: 'HelloWorld',
      ),
    ],
  ).writeToFile();
}

It will generate:

// file: helloWorld.dart

class HelloWorld {
  
}

explains:

  1. FileElement will create a file element which can generate a file using renders and imports to filePath.
  2. ClassElement will create a class element model which can generate a class with the given name.

1.0.0 #

  • Initial version, created by Stagehand

example/renderable_example.dart

import 'dart:io';

import 'package:renderable/renderable.dart';
import 'package:renderable/src/element/file_element.dart';

main() {
  FileElement(
    filePath: 'example/generated/renderable_example.generated.dart',
    renders: [
      ClassElement(
        name: 'RenderableExampleInterface1',
        isAbstract: true,
      ),
      ClassElement(
        name: 'RenderableExampleInterface2',
        isAbstract: true,
      ),
      ClassElement(
        name: 'RenderableExampleInterface3',
        isAbstract: true,
      ),
      ClassElement(
        name: 'RenderableExampleBase',
      ),
      ClassElement(
        name: 'RenderableExample',
        supertype: InterfaceType(name: 'RenderableExampleBase'),
        interfaces: [
          InterfaceType(name: 'RenderableExampleInterface1'),
          InterfaceType(name: 'RenderableExampleInterface2'),
          InterfaceType(name: 'RenderableExampleInterface3'),
        ],
        fields: [
          FieldElement(
            name: 'basicField',
          ),
          FieldElement(
            isFinal: true,
            name: 'fieldWithModifier1',
            type: InterfaceType(name: 'int'),
            value: RawElement(raw: '1'),
          ),
        ],
      ),
    ],
  ).writeToFile();
  print('render complete');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  renderable: ^0.1.13

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:renderable/renderable.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
88
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

We analyzed this package on Sep 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: other

Primary library: package:renderable/renderable.dart with components: io, mirrors.

Health suggestions

Fix lib/src/statement/assignment_statement.dart. (-1 points)

Analysis of lib/src/statement/assignment_statement.dart reported 2 hints:

line 3 col 8: Unused import: 'package:renderable/src/element/variable_element.dart'.

line 4 col 8: Unused import: 'package:renderable/src/type/dart_type.dart'.

Fix lib/src/statement/raw_statement.dart. (-1 points)

Analysis of lib/src/statement/raw_statement.dart reported 2 hints:

line 1 col 8: Unused import: 'package:renderable/src/contract/renderable.dart'.

line 3 col 8: Unused import: 'package:meta/meta.dart'.

Fix lib/src/value/bool_value.dart. (-1 points)

Analysis of lib/src/value/bool_value.dart reported 2 hints:

line 1 col 8: Unused import: 'package:meta/meta.dart'.

line 2 col 8: Unused import: 'package:renderable/src/contract/renderable.dart'.

Fix additional 28 files with analysis or formatting issues. (-9.50 points)

Additional issues in the following files:

  • lib/src/value/double_value.dart (2 hints)
  • lib/src/value/num_value.dart (2 hints)
  • lib/src/value/raw_value.dart (2 hints)
  • lib/src/value/string_value.dart (2 hints)
  • lib/src/element/method_element.dart (1 hint)
  • lib/src/element/property_accessor_element.dart (1 hint)
  • lib/src/misc/function_body.dart (1 hint)
  • lib/src/statement/division_statement.dart (1 hint)
  • lib/src/statement/multiplication_statement.dart (1 hint)
  • lib/src/statement/subtraction_statement.dart (1 hint)
  • lib/src/type/function_type.dart (1 hint)
  • lib/src/value/int_value.dart (1 hint)
  • lib/src/value/list_value.dart (1 hint)
  • lib/src/value/map_value.dart (1 hint)
  • lib/src/value/null_value.dart (1 hint)
  • lib/src/constant/compound_assignment_operator.dart (Run dartfmt to format lib/src/constant/compound_assignment_operator.dart.)
  • lib/src/converter/analyzer_element_converter.dart (Run dartfmt to format lib/src/converter/analyzer_element_converter.dart.)
  • lib/src/converter/analyzer_type_converter.dart (Run dartfmt to format lib/src/converter/analyzer_type_converter.dart.)
  • lib/src/element/class_element.dart (Run dartfmt to format lib/src/element/class_element.dart.)
  • lib/src/element/field_element.dart (Run dartfmt to format lib/src/element/field_element.dart.)
  • lib/src/element/function_element.dart (Run dartfmt to format lib/src/element/function_element.dart.)
  • lib/src/element/import_element.dart (Run dartfmt to format lib/src/element/import_element.dart.)
  • lib/src/element/parameter_element.dart (Run dartfmt to format lib/src/element/parameter_element.dart.)
  • lib/src/statement/variable_declaration_statement.dart (Run dartfmt to format lib/src/statement/variable_declaration_statement.dart.)
  • lib/src/template/class_element_template.dart (Run dartfmt to format lib/src/template/class_element_template.dart.)
  • lib/src/type/interface_type.dart (Run dartfmt to format lib/src/type/interface_type.dart.)
  • lib/src/util/parameter_element_util.dart (Run dartfmt to format lib/src/util/parameter_element_util.dart.)
  • lib/src/util/template_util.dart (Run dartfmt to format lib/src/util/template_util.dart.)

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: analyzer, mustache4dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer any 0.37.1+1 0.38.3
mustache4dart any 3.0.0-dev.1.0
Transitive dependencies
args 1.5.2
async 2.3.0
build 1.1.6 1.2.0
build_config 0.4.1+1
build_daemon 2.1.0
build_resolvers 1.0.8
build_runner 1.6.9 1.7.1
build_runner_core 3.1.1 4.1.0
built_collection 4.2.2
built_value 6.7.1
charcode 1.1.2
checked_yaml 1.0.2
code_builder 3.2.0
collection 1.14.12
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
dart_style 1.2.10
fixnum 0.10.9
front_end 0.1.21+1 0.1.25
glob 1.1.7
graphs 0.2.0
html 0.14.0+2
http 0.12.0+2
http_multi_server 2.1.0
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_annotation 3.0.0
kernel 0.3.21+1 0.3.25
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
package_config 1.1.0
package_resolver 1.0.10
path 1.6.4
pedantic 1.8.0+1
pool 1.4.0
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.0.5
reflectable 2.1.0
shelf 0.7.5
shelf_web_socket 0.2.3
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 0.0.19
string_scanner 1.0.5
term_glyph 1.1.0
timing 0.1.1+2
typed_data 1.1.6
watcher 0.9.7+12
web_socket_channel 1.0.15
yaml 2.2.0
Dev dependencies
test ^1.0.0