Skip to content

Commit f8eda02

Browse files
committed
Review changes and associated docs updates
1 parent 17eb492 commit f8eda02

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

lib/src/dartdoc_options.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class DartdocFileMissing extends DartdocOptionError {
5656
DartdocFileMissing(String details) : super(details);
5757
}
5858

59+
/// Defines the attributes of a category in the options file, corresponding to
60+
/// the 'categories' keyword in the options file, and populated by the
61+
/// [CategoryConfiguration] class.
5962
class CategoryDefinition {
6063
/// Internal name of the category.
6164
final String name;
@@ -73,6 +76,8 @@ class CategoryDefinition {
7376
String get displayName => _displayName ?? name;
7477
}
7578

79+
/// A configuration class that can interpret category definitions from a YAML
80+
/// map.
7681
class CategoryConfiguration {
7782
/// A map of [CategoryDefinition.name] to [CategoryDefinition] objects.
7883
final Map<String, CategoryDefinition> categoryDefinitions;
@@ -110,8 +115,16 @@ class CategoryConfiguration {
110115
}
111116
}
112117

118+
/// Defines the attributes of a tool in the options file, corresponding to
119+
/// the 'tools' keyword in the options file, and populated by the
120+
/// [ToolConfiguration] class.
113121
class ToolDefinition {
122+
/// A list containing the command and options to be run for this tool. The
123+
/// first argument in the command is the tool executable. Must not be an empty
124+
/// list, or be null.
114125
final List<String> command;
126+
127+
/// A description of the defined tool. Must not be null.
115128
final String description;
116129

117130
ToolDefinition(this.command, this.description)
@@ -123,6 +136,7 @@ class ToolDefinition {
123136
String toString() => '$runtimeType: "${command.join(' ')}" ($description)';
124137
}
125138

139+
/// A configuration class that can interpret [ToolDefinition]s from a YAML map.
126140
class ToolConfiguration {
127141
final Map<String, ToolDefinition> tools;
128142

test/model_test.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,21 @@ void main() {
9292
packageGraph.allLocalModelElements.forEach((m) => m.documentation);
9393
});
9494
test("can invoke a tool", () {
95-
expect(invokeTool.documentation, contains('## `Yes it is!`'));
95+
expect(
96+
invokeTool.documentation,
97+
contains(
98+
'''Args: [--file=<INPUT_FILE>, --special= |\\[]!@#\\"\'\$%^&*()_+]'''));
99+
expect(invokeTool.documentation, contains('## `Yes it is a [Dog]!`'));
100+
});
101+
test("can invoke a tool and add a reference link", () {
102+
expect(invokeTool.documentation,
103+
contains('Yes it is a [Dog]! Is not a [ToolUser].'));
96104
});
97105
test(r"can invoke a tool with no $INPUT or args", () {
98106
expect(invokeToolNoInput.documentation, contains('Args: []'));
99107
expect(invokeToolNoInput.documentation,
100108
isNot(contains('This text should not appear in the output')));
109+
expect(invokeToolNoInput.documentation, isNot(contains('[Dog]')));
101110
});
102111
});
103112

testing/test_package/bin/drill.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
// Used by tests as an "external tool". Has no other useful purpose.
66

7+
// This is a sample "tool" used to test external tool integration into dartdoc.
8+
// It has no practical purpose other than that.
9+
710
import 'dart:io';
811
import 'package:args/args.dart';
912

@@ -32,6 +35,7 @@ void main(List<String> argList) {
3235
List<String> lines = file.readAsLinesSync();
3336
for (String line in lines) {
3437
print('## `${line}`');
38+
print('\n$line Is not a [ToolUser].\n');
3539
}
3640
} else {
3741
exit(1);

testing/test_package/lib/example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,15 @@ abstract class ToolUser {
586586
/// Invokes a tool.
587587
///
588588
/// {@tool drill --file="$INPUT" --special=" |\[]!@#\"'$%^&*()_+"}
589-
/// Yes it is!
589+
/// Yes it is a [Dog]!
590590
/// Ok, fine it isn't.
591591
/// {@end-tool}
592592
void invokeTool();
593593

594594
/// Invokes a tool without the $INPUT token or args.
595595
///
596596
/// {@tool drill}
597-
/// This text should not appear in the output.
597+
/// This text should not appear in the output, even if it references [Dog].
598598
/// {@end-tool}
599599
void invokeToolNoInput();
600-
}
600+
}

testing/test_package_docs/ex/ToolUser/invokeTool.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ <h1>invokeTool method</h1>
7373
<section class="desc markdown">
7474
<p>Invokes a tool.</p>
7575
<p>Args: <code>--file=&lt;INPUT_FILE&gt;, --special= |[</code>!@#"'$%^&amp;*()_+]</p>
76-
<h2 id="yes-it-is"><code>Yes it is!</code></h2>
76+
<h2 id="yes-it-is-a-dog"><code>Yes it is a [Dog]!</code></h2>
77+
<p>Yes it is a <a href="ex/Dog-class.html">Dog</a>! Is not a <a href="ex/ToolUser-class.html">ToolUser</a>.</p>
7778
<h2 id="ok-fine-it-isnt"><code>Ok, fine it isn't.</code></h2>
79+
<p>Ok, fine it isn't. Is not a <a href="ex/ToolUser-class.html">ToolUser</a>.</p>
7880
</section>
7981

8082

testing/test_package_docs_dev/ex/ToolUser/invokeTool.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ <h1>invokeTool method</h1>
7373
<section class="desc markdown">
7474
<p>Invokes a tool.</p>
7575
<p>Args: <code>--file=&lt;INPUT_FILE&gt;, --special= |[</code>!@#"'$%^&amp;*()_+]</p>
76-
<h2 id="yes-it-is"><code>Yes it is!</code></h2>
76+
<h2 id="yes-it-is-a-dog"><code>Yes it is a [Dog]!</code></h2>
77+
<p>Yes it is a <a href="ex/Dog-class.html">Dog</a>! Is not a <a href="ex/ToolUser-class.html">ToolUser</a>.</p>
7778
<h2 id="ok-fine-it-isnt"><code>Ok, fine it isn't.</code></h2>
79+
<p>Ok, fine it isn't. Is not a <a href="ex/ToolUser-class.html">ToolUser</a>.</p>
7880
</section>
7981

8082

0 commit comments

Comments
 (0)