parseFromComments method
This parses the code snippets from the documentation comments in the given
elements
, and sets the resulting samples as the samples
member of
each element in the supplied iterable.
Implementation
void parseFromComments(
Iterable<SourceElement> elements, {
bool silent = true,
}) {
int dartpadCount = 0;
int sampleCount = 0;
int snippetCount = 0;
for (final SourceElement element in elements) {
if (element.comment.isEmpty) {
continue;
}
parseComment(element);
for (final CodeSample sample in element.samples) {
switch (sample.runtimeType) {
case ApplicationSample:
sampleCount++;
break;
case DartpadSample:
dartpadCount++;
break;
case SnippetSample:
snippetCount++;
break;
}
}
}
if (!silent) {
print('Found:\n'
' $snippetCount snippet code blocks,\n'
' $sampleCount non-dartpad sample code sections, and\n'
' $dartpadCount dartpad sections.\n');
}
}