Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc fixes #78

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ngast/lib/src/expression/micro/scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class NgMicroScanner {
return _scanLetAssignment();
case _NgMicroScannerState.scanLetIdentifier:
return _scanLetIdentifier();
default:
throw _unexpected();
}
}

Expand Down
2 changes: 1 addition & 1 deletion ngast/lib/src/lexer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'token/tokens.dart';
/// Separates an Angular template into a series of lexical tokens.
///
/// ## Example use
/// ```dart
/// ```
/// const NgLexer().tokenize('<div>Hello World!</div>');
/// ```
class NgLexer {
Expand Down
2 changes: 1 addition & 1 deletion ngast/lib/src/visitors/whitespace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'recursive.dart';
/// Applies whitespace reduction to implement (`preserveWhitespace: false`).
///
/// Use [visitAllRoot] to process root nodes:
/// ```dart
/// ```
/// var nodes = parse(template, sourceUrl: url);
/// nodes = const MinimizeWhitespaceVisitor().visitAllRoot(nodes);
/// ```
Expand Down
4 changes: 0 additions & 4 deletions ngast/test/random_generator_test/random_tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ NgSimpleTokenType generateRandomSimple(State state) {
case State.text:
var i = rng.nextInt(textMap.length);
return textMap[i];
default:
return NgSimpleTokenType.unexpectedChar;
}
}

Expand Down Expand Up @@ -144,8 +142,6 @@ String generateHtmlString() {
sb.write('lorem ipsum');
}
break;
default:
sb.write('');
}
}
return sb.toString();
Expand Down
4 changes: 2 additions & 2 deletions ngcompiler/lib/v1/src/angular_compiler/analyzer/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ String? getTypeName(DartType type) {
///
/// For example for the following code:
/// ```
/// const foo = const <String>[];
/// const bar = const ['A string'];
/// const foo = <String>[];
/// const bar = ['A string'];
/// ```
///
/// ... both `foo` and `bar` should return the [DartType] for `String`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'tokens.dart';
/// Support for reading and parsing a class or function's "dependencies".
///
/// For example, the following class and its constructor:
/// ```dart
/// ```
/// class FooService {
/// FooService(BarService barService, [@Optional() @Inject(someToken) baz]);
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ abstract class InjectorVisitor {
/// Implement providing a new instance of [type], calling [constructor].
///
/// Any [dependencies] are expected to invoke local methods as appropriate:
/// ```dart
/// ```
/// refer('inject').call([refer('Dep1')])
/// ```
void visitProvideClass(
Expand All @@ -461,7 +461,7 @@ abstract class InjectorVisitor {
/// Implement providing [token] by calling [function].
///
/// Any [dependencies] are expected to invoke local methods as appropriate:
/// ```dart
/// ```
/// refer('inject').call([refer('Dep1')])
/// ```
void visitProvideFactory(
Expand Down
6 changes: 3 additions & 3 deletions ngcompiler/lib/v1/src/compiler/ir/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ class HtmlBinding implements BindingTarget {
}

class ClassBinding implements BindingTarget {
/// Name of the class binding, i.e. foo in [class.foo]='bar'.
/// Name of the class binding, i.e. foo in `[class.foo]='bar'`.
///
/// If name is null, then we treat this as a [className]='"foo"' or
/// [attr.class]='foo'.
/// If name is null, then we treat this as a `[className]='"foo"'` or
/// `[attr.class]='foo'`.
final String? name;

@override
Expand Down
4 changes: 0 additions & 4 deletions ngcompiler/lib/v1/src/compiler/output/dart_emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,6 @@ class _DartEmitterVisitor extends AbstractEmitterVisitor
return '.addAll';
case o.BuiltinMethod.subscribeObservable:
return 'listen';
default:
throw StateError('Unknown builtin method: $method');
}
}

Expand Down Expand Up @@ -621,8 +619,6 @@ class _DartEmitterVisitor extends AbstractEmitterVisitor
case o.BuiltinTypeName.voidName:
typeStr = 'void';
break;
default:
throw StateError('Unsupported builtin type ${type.name}');
}
if (type.modifiers.contains(o.TypeModifier.nullableModifier)) {
final suffix = emitNullSafeSyntax ? '?' : '/*?*/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,7 @@ String _getEventName(ast.EventAst event) =>

/// Visitor which filters elements that are not supported in angular templates.
class _ElementFilter extends ast.RecursiveTemplateAstVisitor<void> {
static const _securityUrl =
'https://webdev.dartlang.org/angular/guide/security';
static const _securityUrl = 'https://angulardart.xyz/guide/security';

@override
ast.ElementAst? visitElement(ast.ElementAst astNode, [_]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class _AstToExpressionVisitor
if (_metadata.template!.preserveWhitespace! ||
value.contains('\u00A0') ||
value.contains(ngSpace) ||
!value.contains('\n')) return replaceNgSpace(value);
!value.contains('\n')) {
return replaceNgSpace(value);
}
return replaceNgSpace(value.replaceAll('\n', '').trimLeft());
}

Expand All @@ -161,7 +163,9 @@ class _AstToExpressionVisitor
if (_metadata.template!.preserveWhitespace! ||
value.contains('\u00A0') ||
value.contains(ngSpace) ||
!value.contains('\n')) return replaceNgSpace(value);
!value.contains('\n')) {
return replaceNgSpace(value);
}
return replaceNgSpace(value.replaceAll('\n', '').trimRight());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ abstract class ProviderSource {
/// Whether a dynamic `injectorGet(...)` is required to resolve this provider.
///
/// For example:
/// ```dart
/// // DependencyService is dynamically required to resolve MyService.
/// _MyService = MyService(injectorGet(DependencyService));
/// ```
/// // DependencyService is dynamically required to resolve MyService.
/// _MyService = MyService(injectorGet(DependencyService));
/// ```
bool get hasDynamicDependencies => false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ o.Expression _sanitizedValue(
case TemplateSecurityContext.resourceUrl:
method = SafeHtmlAdapters.sanitizeResourceUrl;
break;
default:
throw ArgumentError('internal error, unexpected '
'TemplateSecurityContext $securityContext.');
}
return o.importExpr(method).callFn([renderValue]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,6 @@ o.Constructor? _createViewConstructor(CompileView view) {
// Host views have no constructor parameters, thus don't require an
// explicit constructor.
return null;
default:
throw StateError('Unsupported $ViewType: ${view.viewType}');
}
}

Expand Down Expand Up @@ -687,8 +685,6 @@ o.Expression _createParentClassExpr(CompileView view) {
return o.importExpr(Views.embeddedView, typeParams: typeArgs);
case ViewType.host:
return o.importExpr(Views.hostView, typeParams: typeArgs);
default:
throw StateError('Unsupported $ViewType: ${view.viewType}');
}
}

Expand Down Expand Up @@ -907,8 +903,6 @@ o.Statement? _generateInitStatement(CompileView view) {
// Host views should have exactly one root node.
view.rootNodesOrViewContainers.single,
]).toStmt();
default:
throw StateError('Unsupported $ViewType: ${view.viewType}');
}
}

Expand Down
6 changes: 3 additions & 3 deletions ngdart/lib/angular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
/// * [AngularDart guide][]
/// * [AngularDart cheat sheet][cheatsheet]
///
/// [AngularDart]: https://webdev.dartlang.org/angular
/// [AngularDart guide]: https://webdev.dartlang.org/angular/guide
/// [cheatsheet]: https://webdev.dartlang.org/angular/cheatsheet
/// [AngularDart]: https://angulardart.xyz
/// [AngularDart guide]: https://angulardart.xyz/guide
/// [cheatsheet]: https://angulardart.xyz/cheatsheet

library angular;

Expand Down
4 changes: 2 additions & 2 deletions ngdart/lib/experimental.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export 'src/meta.dart' show changeDetectionLink;
/// Create a root application [Injector].
///
/// Requires [userInjector] to provide app-level services or overrides:
/// ```dart
/// main() {
/// ```
/// void main() {
/// var injector = rootInjector((parent) {
/// return Injector.map({ /* ... */ }, parent);
/// });
Expand Down
13 changes: 7 additions & 6 deletions ngdart/lib/src/bootstrap/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ Injector _identityInjector(Injector parent) => parent;

/// Starts a new AngularDart application with [componentFactory] as the root.
///
/// ```dart
/// ```
/// // Assume this file is "main.dart".
/// import 'package:ngdart/angular.dart';
///
/// import 'main.template.dart' as ng;
///
/// @Component(
Expand All @@ -123,8 +124,10 @@ Injector _identityInjector(Injector parent) => parent;
/// Optionally may supply a [createInjector] function in order to provide
/// services to the root of the application:
///
/// ```
/// // Assume this file is "main.dart".
/// import 'package:ngdart/angular.dart';
///
/// import 'main.template.dart' as ng;
///
/// @Component(
Expand All @@ -143,14 +146,12 @@ Injector _identityInjector(Injector parent) => parent;
/// }
/// }
///
/// @GenerateInjector([ClassProvider(HelloService)])
/// final InjectorFactory helloInjector = ng.helloInjector$Injector;
///
/// void main() {
/// runApp(ng.HelloWorldNgFactory, createInjector: helloInjector);
/// }
///
/// @GenerateInjector(const [
/// const ClassProvider(HelloService),
/// ])
/// final InjectorFactory helloInjector = ng.helloInjector$Injector;
/// ```
///
/// See [InjectorFactory] for more examples.
Expand Down
14 changes: 7 additions & 7 deletions ngdart/lib/src/common/directives/ng_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import 'package:ngdart/src/utilities.dart';
///
/// - [String] - all the CSS classes listed in a string (space delimited) are
/// added
/// - [List] - all the CSS classes (List elements) are added
/// - [Object] - each key corresponds to a CSS class name while values are
/// - [List] - all the CSS classes (List elements) are added
/// - [Map] - each key corresponds to a CSS class name while values are
/// interpreted as expressions evaluating to [bool]. If a given expression
/// evaluates to [true] a corresponding CSS class is added - otherwise it is
/// evaluates to `true` a corresponding CSS class is added - otherwise it is
/// removed.
///
/// While the [NgClass] directive can interpret expressions evaluating to
/// [String], [Array] or [Object], the [Object]-based version is the most often
/// [String], [List] or [Map], the [Map]-based version is the most often
/// used and has an advantage of keeping all the CSS class names in a template.
///
/// ### Examples
Expand All @@ -31,7 +31,7 @@ import 'package:ngdart/src/utilities.dart';
/// ```
///
/// <?code-excerpt "docs/template-syntax/lib/app_component.dart (setClasses)"?>
/// ```dart
/// ```
/// Map<String, bool> currentClasses = <String, bool>{};
/// void setCurrentClasses() {
/// currentClasses = <String, bool>{
Expand All @@ -46,8 +46,8 @@ import 'package:ngdart/src/utilities.dart';
/// For details, see the [`ngClass` discussion in the Template Syntax][guide]
/// page.
///
/// [ex]: https://angulardart.dev/examples/template-syntax#ngClass
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngClass
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngClass
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngClass
@Directive(
selector: '[ngClass]',
)
Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/src/common/directives/ng_for.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import '../../core/linker.dart';
/// For details, see the [`ngFor` discussion in the Template Syntax][guide]
/// page.
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngFor
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngFor
@Directive(
selector: '[ngFor][ngForOf]',
)
Expand Down
1 change: 1 addition & 0 deletions ngdart/lib/src/common/directives/ng_for_identity.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:meta/meta.dart';
import 'package:ngdart/src/common/directives/ng_for.dart';
import 'package:ngdart/src/core/linker/template_ref.dart';
import 'package:ngdart/src/core/linker/view_container_ref.dart';
import 'package:ngdart/src/meta.dart';
Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/src/common/directives/ng_if.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import 'package:ngdart/src/runtime/check_binding.dart';
/// </template>
/// ```
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngIf
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngIf
@Directive(
selector: '[ngIf]',
)
Expand Down
15 changes: 4 additions & 11 deletions ngdart/lib/src/common/directives/ng_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../../core/change_detection/differs/default_keyvalue_differ.dart';
/// The `NgStyle` directive changes an element's style based on the bound style
/// expression:
///
/// <div [ngStyle]="styleExp"></div>
/// <div [ngStyle]="styleField"></div>
///
/// _styleExp_ must evaluate to a `Map<String, String>`. Element style properties
/// are set based on the map entries: each _key_:_value_ pair identifies a
Expand All @@ -31,7 +31,7 @@ import '../../core/change_detection/differs/default_keyvalue_differ.dart';
/// ```
///
/// <?code-excerpt "docs/template-syntax/lib/app_component.dart (setStyles)"?>
/// ```dart
/// ```
/// Map<String, String> currentStyles = <String, String>{};
/// void setCurrentStyles() {
/// currentStyles = <String, String>{
Expand All @@ -45,15 +45,8 @@ import '../../core/change_detection/differs/default_keyvalue_differ.dart';
/// In this example, user changes to the `<input>` elements result in updates
/// to the corresponding style properties of the first paragraph.
///
/// A [Map] literal can be used as a style expression:
///
/// <div [ngStyle]="{'font-style': 'italic'}"></div>
///
/// A better practice, however, is to bind to a component field or method, as
/// in the binding to `setStyle()` above.
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngStyle
/// [ex]: https://angulardart.dev/examples/template-syntax#ngStyle
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngStyle
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngStyle
@Directive(
selector: '[ngStyle]',
)
Expand Down
4 changes: 2 additions & 2 deletions ngdart/lib/src/common/directives/ng_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class SwitchView {
/// Try the [live example][ex].
/// For details, see the [Structural Directives section on `ngSwitch`][guide].
///
/// [ex]: https://angulardart.dev/examples/template-syntax#ngSwitch
/// [guide]: https://webdev.dartlang.org/angular/guide/structural-directives.html#ngSwitch
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngSwitch
/// [guide]: https://angulardart.xyz/guide/structural-directives.html#ngSwitch
///
@Directive(
selector: '[ngSwitch]',
Expand Down
4 changes: 2 additions & 2 deletions ngdart/lib/src/common/directives/ng_template_outlet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:ngdart/src/meta.dart';
///
/// ### Examples
///
/// ```dart
/// ```
/// @Component(
/// selector: 'example',
/// template: '''
Expand All @@ -28,7 +28,7 @@ import 'package:ngdart/src/meta.dart';
/// [ngTemplateOutletContext]="iconContext">
/// </template>
/// ''',
/// directives: const [NgTemplateOutlet],
/// directives: [NgTemplateOutlet],
/// )
/// class ExampleComponent {
/// final textContext = 'Hello world!';
Expand Down
Loading
Loading