dart-archive / custom-element-apigen

Tool to generate Dart APIs for polymer custom elements written in Javascript
BSD 3-Clause "New" or "Revised" License
13 stars 13 forks source link

Generate dart classes for all elements to silence analyzer warnings #49

Closed johnpryan closed 8 years ago

johnpryan commented 8 years ago

The design for Dart to HTML imports results in users using a doc comment to silence library x is unused warnings:

import 'package:polymer_elements/paper_button.dart'

/// [PaperButton]

polymer_elements has certain elements (iron_flex_layout for instance) that don't have a Dart class. So there is no clean way to silence analyzer warnings:

import 'package:polymer_elements/iron_flex_layout.dart'

/// [IronFlexLayout]

It would be helpful to generate a dummy class to get around this:

// DO NOT EDIT: auto-generated with `pub run custom_element_apigen:update`

/// Dart API for the polymer element `iron_flex_layout`.
@HtmlImport('iron_flex_layout_nodart.html')
library polymer_elements.lib.src.iron_flex_layout.iron_flex_layout;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'package:web_components/web_components.dart';
import 'package:polymer_interop/polymer_interop.dart';

// generated
class IronFlexLayout {}
jakemac53 commented 8 years ago

Actually, there is a better way now of silencing these warnings. You should be able to just add: // ignore: UNUSED_IMPORT before the import statement.

johnpryan commented 8 years ago

This works really nicely. Thanks for the quick response

It looks like you can also add the comment on the same line:

import 'package:polymer_elements/iron_flex_layout.dart'; // ignore: UNUSED_IMPORT