Skip to content

Commit

Permalink
Tidy some comments (#3741)
Browse files Browse the repository at this point in the history
Tidy some comments:

* Move the `Locatable.documentationFrom` comment from an override to the
  highest declaration.
* Make a few comments more idiomatic.
  • Loading branch information
srawlins committed Apr 3, 2024
1 parent 2559a77 commit 12988e0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
21 changes: 11 additions & 10 deletions lib/src/model/documentation_comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ mixin DocumentationComment

List<DocumentationComment>? _documentationFrom;

/// The [ModelElement](s) from which we will get documentation.
///
/// Can be more than one if this is a [Field] composing documentation from
/// multiple [Accessor]s.
///
/// This will walk up the inheritance hierarchy to find docs, if the current
/// class doesn't have docs for this element.
@override
List<DocumentationComment> get documentationFrom =>
_documentationFrom ??= () {
Expand Down Expand Up @@ -72,11 +65,19 @@ mixin DocumentationComment
/// like `///`, `//`, `/*`, `*/`.
String get documentationComment => element.documentationComment ?? '';

/// True if [this] has a synthetic/inherited or local documentation
/// comment. False otherwise.
/// Whether `this` has a synthetic/inherited or local documentation comment,
/// and false otherwise.
bool get hasDocumentationComment => element.documentationComment != null;

/// Returns true if the raw documentation comment has a 'nodoc' indication.
/// Whether the raw documentation comment is considered to be 'nodoc', an
/// attribute indicating that any documentation should not be included in
/// dartdoc's generated output.
///
/// An element is considered to be 'nodoc' if any of the following are true:
/// * a global 'nodoc' configuration has been set for this element (this
/// feature is deprecated),
/// * the element has no documentation comment,
/// * the documentation comment contains the `@nodoc` dartdoc directive.
late final bool hasNodoc = () {
if (packageGraph.configSetsNodocFor(element.source!.fullName)) {
return true;
Expand Down
7 changes: 6 additions & 1 deletion lib/src/model/inheritable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ mixin Inheritable on ContainerMember {

Inheritable? get overriddenElement;

/// True if this [Inheritable] is overriding a superclass.
/// Whether this [Inheritable] is overriding a member from a superclass.
///
/// This is distinct from [isInherited]. An inheritable member which is an
/// override is explicitly written in its container. An inheritable member
/// which is implicitly included in a container is "inherited", and not an
/// override.
late final bool isOverride = () {
// The canonical version of the enclosing element -- not
// [canonicalEnclosingElement], as that is the element enclosing the
Expand Down
8 changes: 8 additions & 0 deletions lib/src/model/locatable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/element.dart' show Element;
import 'package:dartdoc/src/model/model.dart';

/// Something that can be located for warning purposes.
mixin Locatable {
/// The [Locatable](s) from which we will get documentation.
///
/// Can be more than one if this is a [Field] composing documentation from
/// multiple [Accessor]s.
///
/// This will walk up the inheritance hierarchy to find docs, if the current
/// class doesn't have docs for this element.
List<Locatable> get documentationFrom;

/// True if documentationFrom contains only one item, [this].
Expand Down
8 changes: 6 additions & 2 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,12 @@ class PackageGraph with CommentReferable, Nameable {
/// Glob lookups can be expensive. Cache per filename.
final _configSetsNodocFor = HashMap<String, bool>();

/// Given an element's location, look up the nodoc configuration data and
/// determine whether to unconditionally treat the element as "nodoc".
/// Given an element's [fullName], look up the nodoc configuration data and
/// determine whether to unconditionally treat the element as "nodoc", an
/// attribute indicating that documentation should not be included in
/// dartdoc's generated output.
///
/// This configuration setting is deprecated.
bool configSetsNodocFor(String fullName) {
return _configSetsNodocFor.putIfAbsent(fullName, () {
var file = resourceProvider.getFile(fullName);
Expand Down

0 comments on commit 12988e0

Please sign in to comment.