Skip to content

Remove the deprecated nodoc option. #4025

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 5 commits into from
May 27, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 9.0.0-wip
* Remove deprecated `missingCodeBlockLanguage` warning.
* Remove the deprecated `templates-dir` option.
* Remove the deprecated `nodoc` option.

## 8.3.4
* The URL for category pages now uses _category name_ instead of
Expand Down
9 changes: 0 additions & 9 deletions lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,6 @@ class DartdocOptionContext extends DartdocOptionContextBase
// ignore: unused_element
String get _linkToHosted => optionSet['linkTo']['hosted'].valueAt(context);

List<String> get nodoc => optionSet['nodoc'].valueAt(context);

String get output => optionSet['output'].valueAt(context);

PackageMeta get packageMeta => optionSet['packageMeta'].valueAt(context);
Expand Down Expand Up @@ -1501,13 +1499,6 @@ List<DartdocOption> createDartdocOptions(
help: 'Allow links to be generated for packages outside this one.',
negatable: true),
]),
// Deprecated. Use of this option is reported.
// TODO(srawlins): Remove.
DartdocOptionFileOnly<List<String>>('nodoc', [], resourceProvider,
optionIs: OptionKind.glob,
help: '(deprecated) Dart symbols declared in these files will be '
'treated as though they have the @nodoc directive added to their '
'documentation comment.'),
DartdocOptionArgOnly<String>('output',
resourceProvider.pathContext.join('doc', 'api'), resourceProvider,
optionIs: OptionKind.dir, help: 'Path to the output directory.'),
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 @@ -25772,7 +25772,6 @@ const _invisibleGetters = {
'linkToUrl',
'maxFileCount',
'maxTotalSize',
'nodoc',
'optionSet',
'output',
'packageMeta',
Expand Down
6 changes: 0 additions & 6 deletions lib/src/model/documentation_comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,9 @@ mixin DocumentationComment
/// 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.library2!.firstFragment.source.fullName)) {
return true;
}
if (!hasDocumentationComment) {
return false;
}
Expand Down
32 changes: 0 additions & 32 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -905,38 +905,6 @@ class PackageGraph with CommentReferable, Nameable {
return allElements;
}

/// Cache of 'nodoc' configurations.
///
/// Glob lookups can be expensive, so cache per filename.
final _configSetsNodocFor = HashMap<String, bool>();

/// 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);
// Direct lookup instead of generating a custom context will save some
// cycles. We can't use the element's [DartdocOptionContext] because that
// might not be where the element was defined, which is what's important
// for nodoc's semantics. Looking up the defining element just to pull
// a context is again, slow.
var globs = (config.optionSet['nodoc'].valueAt(file.parent) as List)
.cast<String>();
if (globs.isNotEmpty) {
packageGraph.defaultPackage.warn(
PackageWarning.deprecated,
message:
"The '--nodoc' option is deprecated, and will soon be removed.",
);
}
return utils.matchGlobs(globs, fullName);
});
}

/// Returns a macro by [name], or `null` if no macro is found.
String? getMacro(String name) {
assert(_localDocumentationBuilt);
Expand Down
16 changes: 0 additions & 16 deletions test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1158,22 +1158,6 @@ void main() async {
});
});

group('Comment processing', () {
test('can virtually add nodoc via options file', () {
var NodocMeLibrary =
packageGraph.defaultPackage.allLibraries.named('nodocme');
expect(NodocMeLibrary.hasNodoc, isTrue);
var NodocMeImplementation =
fakeLibrary.classes.named('NodocMeImplementation');
expect(NodocMeImplementation.hasNodoc, isTrue);
expect(NodocMeImplementation.isPublic, isFalse);
var MeNeitherEvenWithoutADocComment =
fakeLibrary.classes.named('MeNeitherEvenWithoutADocComment');
expect(MeNeitherEvenWithoutADocComment.hasNodoc, isTrue);
expect(MeNeitherEvenWithoutADocComment.isPublic, isFalse);
});
});

group('doc references', () {
late final String docsAsHtml;

Expand Down
1 change: 0 additions & 1 deletion testing/test_package/dartdoc_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dartdoc:
Unreal:
markdown: "Unreal.md"
Real Libraries:
nodoc: ["lib/src/nodoc*.dart"]
tools:
drill:
command: ["bin/drill.dart"]
Expand Down
3 changes: 0 additions & 3 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ import 'mylibpub.dart' as renamedLib2;
import 'two_exports.dart' show BaseClass;
export 'src/notadotdartfile';

// Verify that even though reexported, objects don't show in documentation.
export 'package:test_package/src/nodocme.dart';

// ignore: uri_does_not_exist
export 'package:test_package_imported/categoryExporting.dart'
show IAmAClassWithCategories;
Expand Down
11 changes: 0 additions & 11 deletions testing/test_package/lib/src/nodocme.dart

This file was deleted.