Skip to content

Commit

Permalink
Added to README.md, changed name to compile_args from compile-args
Browse files Browse the repository at this point in the history
  • Loading branch information
gspencergoog committed Mar 17, 2021
1 parent dca9403 commit be4599a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ dartdoc:
command: ["bin/drill.dart"]
setup_command: ["bin/setup.dart"]
description: "Puts holes in things."
compile_args: ["-no-sound-null-safety"]
echo:
macos: ['/bin/sh', '-c', 'echo']
setup_macos: ['/bin/sh', '-c', 'setup.sh']
Expand Down Expand Up @@ -328,6 +329,9 @@ The `description` is just a short description of the tool for use as help text.
Only tools which are configured in the `dartdoc_options.yaml` file are able to
be invoked.

The `compile_args` tag is used to pass options to the dart compiler when the
first run of the tool is being snapshotted.

To use the tools in comment documentation, use the `{@tool <name> [<options>
...] [$INPUT]}` directive to invoke the tool:

Expand Down
13 changes: 7 additions & 6 deletions lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const int _kIntVal = 0;
const double _kDoubleVal = 0.0;
const bool _kBoolVal = true;

const String _kCompileArgsTagName = 'compile_args';

int get _usageLineLength => stdout.hasTerminal ? stdout.terminalColumns : null;

typedef ConvertYamlToType<T> = T Function(YamlMap, String, ResourceProvider);
Expand Down Expand Up @@ -160,7 +162,7 @@ class ToolDefinition {
if (compileArgs != null && compileArgs.isNotEmpty) {
throw DartdocOptionError(
'Compile arguments may only be specified for Dart tools, but '
'compile-args of $compileArgs were specified for '
'$_kCompileArgsTagName of $compileArgs were specified for '
'$command.');
}
return ToolDefinition(command, setupCommand, description);
Expand Down Expand Up @@ -393,19 +395,18 @@ class ToolConfiguration {
setupCommand = findCommand('setup_');

List<String> findArgs() {
const tagName = 'compile-args';
List<String> args;
if (toolMap.containsKey(tagName)) {
var compileArgs = toolMap[tagName];
if (toolMap.containsKey(_kCompileArgsTagName)) {
var compileArgs = toolMap[_kCompileArgsTagName];
if (compileArgs is String) {
args = [toolMap[tagName].toString()];
args = [toolMap[_kCompileArgsTagName].toString()];
} else if (compileArgs is YamlList) {
args =
compileArgs.map<String>((node) => node.toString()).toList();
} else {
throw DartdocOptionError(
'Tool compile arguments must be a list of strings. The tool '
'$name has a $tagName entry that is a '
'$name has a $_kCompileArgsTagName entry that is a '
'${compileArgs.runtimeType}');
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/documentation_comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mixin DocumentationComment
/// # Path is relative to project root.
/// command: ["bin/prefix.dart"]
/// description: "Prefixes the given input with '##'."
/// compile-args: ["--no-sound-null-safety"]
/// compile_args: ["--no-sound-null-safety"]
/// date:
/// command: ["/bin/date"]
/// description: "Prints the date"
Expand Down
4 changes: 2 additions & 2 deletions test/tool_runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {
drill:
command: ["bin/drill.dart"]
description: "Puts holes in things."
compile-args: ["--no-sound-null-safety"]
compile_args: ["--no-sound-null-safety"]
snapshot_drill:
command: ["${snapshotFile.replaceAll(r'\', r'\\')}"]
description: "Puts holes in things, but faster."
Expand Down Expand Up @@ -119,7 +119,7 @@ echo:
expect(result, contains('--file=<INPUT_FILE>'));
expect(result, contains('## `TEST INPUT`'));
expect(result, contains('Script location is in dartdoc tree.'));
// This shouldn't be in the args passed to the tool.
// Compile args shouldn't be in the args passed to the tool.
expect(result, isNot(contains('--no-sound-null-safety')));
expect(setupFile.existsSync(), isFalse);
result = await runner.run(
Expand Down

0 comments on commit be4599a

Please sign in to comment.