Skip to content

Remove the unnecessary Privacy mixin #3794

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

Merged
merged 2 commits into from
Jun 21, 2024
Merged
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: 1 addition & 1 deletion lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'package:meta/meta.dart';

/// Base class representing a type in Dartdoc. It wraps a [DartType], and
/// may link to a [ModelElement].
abstract class ElementType with CommentReferable, Nameable implements Privacy {
abstract class ElementType with CommentReferable, Nameable {
final DartType type;
@override
final PackageGraph packageGraph;
Expand Down
1 change: 0 additions & 1 deletion lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16301,7 +16301,6 @@ const _invisibleGetters = {
'allHrefs',
'allImplementersAdded',
'allInheritableElements',
'allLibraries',
'allLibrariesAdded',
'analysisContext',
'breadcrumbName',
Expand Down
1 change: 0 additions & 1 deletion lib/src/model/annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ final class Annotation extends Attribute {
'non-callable element used as annotation?: ${_annotation.element}')
};

@override
bool get isPublic {
final modelType = _modelType;
if (!modelType.isPublic) {
Expand Down
6 changes: 1 addition & 5 deletions lib/src/model/attribute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:collection/collection.dart';
import 'package:dartdoc/src/model/privacy.dart';
import 'package:meta/meta.dart';

int byAttributeOrdering(Attribute a, Attribute b) {
Expand All @@ -16,7 +15,7 @@ int byAttributeOrdering(Attribute a, Attribute b) {
///
/// These include both explicit annotations in code (e.g. `deprecated`) as well
/// as others added by the documentation system (e.g. 'no setter').
abstract class Attribute implements Privacy {
abstract class Attribute {
// A name, only used for sorting.
@visibleForOverriding
final String name;
Expand Down Expand Up @@ -57,9 +56,6 @@ abstract class Attribute implements Privacy {
final class _BuiltInAttribute extends Attribute {
const _BuiltInAttribute(super.name, super.sortGroup);

@override
bool get isPublic => false;

@override
String get linkedName => name;

Expand Down
7 changes: 6 additions & 1 deletion lib/src/model/documentation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ class Documentation {
// situation where one public getter might set both fields, but might only
// set one. We have this awkward check to make sure we set both fields if
// we'll need both fields.
assert(_element.isCanonical);
assert(
_element.isCanonical,
"generating docs for non-canonical element: '$_element' "
"('${_element.runtimeType}', ${_element.hashCode}), representing "
"'${_element.element}'",
);
return _asHtml;
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export 'package.dart';
export 'package_builder.dart';
export 'package_graph.dart';
export 'parameter.dart';
export 'privacy.dart';
export 'source_code_mixin.dart';
export 'top_level_container.dart';
export 'top_level_variable.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class ModelElement
Indexable,
FeatureSet,
DocumentationComment
implements Comparable<ModelElement>, Documentable, Privacy {
implements Comparable<ModelElement>, Documentable {
// TODO(jcollins-g): This really wants a "member that has a type" class.
final Member? _originalMember;
final Library _library;
Expand Down
14 changes: 11 additions & 3 deletions lib/src/model/nameable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import 'package:dartdoc/src/model/container.dart';
import 'package:dartdoc/src/model/library.dart';
import 'package:dartdoc/src/model/model_element.dart';
import 'package:dartdoc/src/model/package_graph.dart';
import 'package:dartdoc/src/model/privacy.dart';

/// Something that has a name.
mixin Nameable implements Privacy {
mixin Nameable {
String get name;

/// A qualified name, mostly for use in the web search functionality, and for
Expand All @@ -27,7 +26,16 @@ mixin Nameable implements Privacy {
/// The name to use in breadcrumbs in the rendered documentation.
String get breadcrumbName => name;

@override
/// Whether this is "package-public."
///
/// A "package-public" element satisfies the following requirements:
/// * is not documented with the `@nodoc` directive,
/// * for a library, is found in a package's top-level 'lib' directory, and
/// not found in it's 'lib/src' directory,
/// * for a library member, is in a _public_ library's exported namespace, and
/// is not privately named, nor an unnamed extension,
/// * for a container (class, enum, extension, extension type, mixin) member,
/// is in a _public_ container, and is not privately named.
bool get isPublic => name.isNotEmpty && !name.startsWith('_');

@override
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const String htmlBasePlaceholder = r'%%__HTMLBASE_dartdoc_internal__%%';
/// A [LibraryContainer] that contains [Library] objects related to a particular
/// package.
class Package extends LibraryContainer
with Nameable, Locatable, Warnable, CommentReferable
implements Privacy {
with Nameable, Locatable, Warnable, CommentReferable {
@override
final String name;

Expand Down
18 changes: 0 additions & 18 deletions lib/src/model/privacy.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/src/model_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ extension IterableOfDocumentableExtension<E extends Documentable>
Iterable<E> get whereDocumented => where((e) => e.isDocumented).wherePublic;
}

extension IterableOfNameableExtension<E extends Privacy> on Iterable<E> {
extension IterableOfNameableExtension<E extends Nameable> on Iterable<E> {
Iterable<E> get wherePublic => where((e) => e.isPublic);
}