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

Deprecate some _public_ top-level variables. #2307

Merged
merged 2 commits into from
Aug 18, 2020
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
17 changes: 13 additions & 4 deletions lib/src/io_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,20 @@ Iterable<String> _doList(
/// * dart.dartdoc => dart_dartdoc.html
/// * dart:core => dart_core.html
String getFileNameFor(String name) =>
'${name.replaceAll(libraryNameRegexp, '-')}.html';
'${name.replaceAll(_libraryNameRegExp, '-')}.html';

final libraryNameRegexp = RegExp('[.:]');
final partOfRegexp = RegExp('part of ');
final newLinePartOfRegexp = RegExp('\npart of ');
final _libraryNameRegExp = RegExp('[.:]');
@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
RegExp get libraryNameRegexp => _libraryNameRegExp;

@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
final RegExp partOfRegexp = RegExp('part of ');

@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
final RegExp newLinePartOfRegexp = RegExp('\npart of ');

/// Best used with Future<void>.
class MultiFutureTracker<T> {
Expand Down
8 changes: 6 additions & 2 deletions lib/src/model/categorization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

import 'package:dartdoc/src/model/model.dart';

final categoryRegexp = RegExp(
final RegExp _categoryRegExp = RegExp(
r'[ ]*{@(api|category|subCategory|image|samples) (.+?)}[ ]*\n?',
multiLine: true);

@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
RegExp get categoryRegexp => _categoryRegExp;

/// Mixin implementing dartdoc categorization for ModelElements.
abstract class Categorization implements ModelElement {
@override
Expand All @@ -22,7 +26,7 @@ abstract class Categorization implements ModelElement {
var _subCategorySet = <String>{};
_hasCategorization = false;

rawDocs = rawDocs.replaceAllMapped(categoryRegexp, (match) {
rawDocs = rawDocs.replaceAllMapped(_categoryRegExp, (match) {
_hasCategorization = true;
switch (match[1]) {
case 'category':
Expand Down
16 changes: 11 additions & 5 deletions lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ int byFeatureOrdering(String a, String b) {

/// This doc may need to be processed in case it has a template or html
/// fragment.
final needsPrecacheRegExp = RegExp(r'{@(template|tool|inject-html)');
final RegExp needsPrecacheRegExp = RegExp(r'{@(template|tool|inject-html)');

final htmlInjectRegExp = RegExp(r'<dartdoc-html>([a-f0-9]+)</dartdoc-html>');
final _htmlInjectRegExp = RegExp(r'<dartdoc-html>([a-f0-9]+)</dartdoc-html>');
@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
RegExp get htmlInjectRegExp => _htmlInjectRegExp;

final macroRegExp = RegExp(r'{@macro\s+([^}]+)}');
final _macroRegExp = RegExp(r'{@macro\s+([^}]+)}');
@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
RegExp get macroRegExp => _macroRegExp;

// TODO(jcollins-g): Implement resolution per ECMA-408 4th edition, page 39 #22.
/// Resolves this very rare case incorrectly by picking the closest element in
Expand Down Expand Up @@ -1198,7 +1204,7 @@ abstract class ModelElement extends Canonicalization
String _injectHtmlFragments(String rawDocs) {
if (!config.injectHtml) return rawDocs;

return rawDocs.replaceAllMapped(htmlInjectRegExp, (match) {
return rawDocs.replaceAllMapped(_htmlInjectRegExp, (match) {
var fragment = packageGraph.getHtmlFragment(match[1]);
if (fragment == null) {
warn(PackageWarning.unknownHtmlFragment, message: match[1]);
Expand Down Expand Up @@ -1234,7 +1240,7 @@ abstract class ModelElement extends Canonicalization
/// More comments
///
String _injectMacros(String rawDocs) {
return rawDocs.replaceAllMapped(macroRegExp, (match) {
return rawDocs.replaceAllMapped(_macroRegExp, (match) {
var macro = packageGraph.getMacro(match[1]);
if (macro == null) {
warn(PackageWarning.unknownMacro, message: match[1]);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/package_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ class PubPackageBuilder implements PackageBuilder {
// Only add the file if it does not contain 'part of'
var contents = File(lib).readAsStringSync();

if (contents.contains(newLinePartOfRegexp) ||
contents.startsWith(partOfRegexp)) {
if (contents.startsWith('part of ') ||
contents.contains('\npart of ')) {
// NOOP: it's a part file
} else {
yield lib;
Expand Down
7 changes: 5 additions & 2 deletions lib/src/source_linker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import 'package:dartdoc/src/model/model.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;

final uriTemplateRegexp = RegExp(r'(%[frl]%)');
final _uriTemplateRegExp = RegExp(r'(%[frl]%)');
@Deprecated('Public variable intended to be private; will be removed as early '
'as Dartdoc 1.0.0')
RegExp get uriTemplateRegexp => _uriTemplateRegExp;

abstract class SourceLinkerOptionContext implements DartdocOptionContextBase {
List<String> get linkToSourceExcludes =>
Expand Down Expand Up @@ -105,7 +108,7 @@ class SourceLinker {
.any((String exclude) => path.isWithin(exclude, sourceFileName))) {
return '';
}
return uriTemplate.replaceAllMapped(uriTemplateRegexp, (match) {
return uriTemplate.replaceAllMapped(_uriTemplateRegExp, (match) {
switch (match[1]) {
case '%f%':
var urlContext = path.Context(style: path.Style.url);
Expand Down
5 changes: 3 additions & 2 deletions lib/src/tool_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ class ToolRunner {
// or $VAR form.
var envWithInput = {
'INPUT': tmpFile.absolute.path,
'TOOL_COMMAND': toolDefinition.command[0]
}..addAll(environment);
'TOOL_COMMAND': toolDefinition.command[0],
...environment,
};
if (toolDefinition is DartToolDefinition) {
// Put the original command path into the environment, because when it
// runs as a snapshot, Platform.script (inside the tool script) refers to
Expand Down
2 changes: 1 addition & 1 deletion lib/src/warnings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class PackageWarningOptions {
}

class PackageWarningCounter {
final countedWarnings = <Element, Set<Tuple2<PackageWarning, String>>>{};
final Map<Element, Set<Tuple2<PackageWarning, String>>> countedWarnings = {};
final _items = <Jsonable>[];
final _displayedWarningCounts = <PackageWarning, int>{};
final PackageGraph packageGraph;
Expand Down