snippets
library
Classes
-
ApplicationSample
-
A class to represent a plain application sample in the dartdoc comments,
marked by
{@tool sample ...}...{@end-tool}
.
-
CodeSample
-
A base class to represent a block of any kind of sample code, marked by
"{@tool (snippet|sample|dartdoc) ...}...{@end-tool}".
-
DartpadSample
-
A class to represent a Dartpad application sample in the dartdoc comments,
marked by
{@tool dartpad ...}...{@end-tool}
.
-
FlutterInformation
-
Contains information about the installed Flutter repo.
-
FlutterRepoSnippetConfiguration
-
A class to compute the configuration of the snippets input and output
locations based in the current location of the snippets main.dart.
-
SampleStats
-
-
SnippetConfiguration
-
-
SnippetDartdocParser
-
Parses CodeSamples from the source file given to one of the parsing routines.
-
SnippetGenerator
-
Generates the snippet HTML, as well as saving the output snippet main to
the output directory.
-
SnippetSample
-
A class to represent a snippet of sample code, marked by "{@tool
snippet}...{@end-tool}".
-
SourceElement
-
A class that represents a Dart element in a source file.
-
SourceLine
-
A class to represent a line of input code, with associated line number, file
and element name.
-
TemplateInjection
-
A class containing the name and contents associated with a code block inside of a
code sample, for named injection into a template.
Properties
-
errorExit
↔ void Function(String message)
-
Exit the app with a message to stderr.
Can be overridden by tests to avoid exits.
getter/setter pair
Functions
-
Filters the source
elements
to only return the comment elements.
-
Gets an iterable over all of the blocks of documentation comments from an
iterable over the SourceElements involved.
-
getElementsFromString(String content, File file)
→ Iterable<SourceElement>
-
Reads the file content from a string, to avoid having to read the file more
than once if the caller already has the content in memory.
-
Gets an iterable over the comment SourceElements in a file.
-
Gets an iterable over all of the blocks of documentation comments in a file
using the analyzer.
-
getFileElements(File file, {ResourceProvider? resourceProvider})
→ Iterable<SourceElement>
-
Gets an iterable over the SourceElements in the given
file
.
-
getIndent(String line)
→ int
-
Gets the number of whitespace characters at the beginning of a line.
-
getSamplesInElements(Iterable<SourceElement>? elements)
→ Iterable<CodeSample>
-
-
getSampleStats(SourceElement element)
→ SampleStats
-
-
interpolateTemplate(List<TemplateInjection> injections, String template, Map<String, Object?> metadata, {bool addSectionMarkers = false, bool addCopyright = false})
→ String
-
Injects the
injections
into the template
, while turning the
"description" injection into a comment.
-
sectionArrows(String name, {bool start = true})
→ String
-
Returns a marker with section arrows surrounding the given string.
-
sortImports(String contents)
→ String
-
Read the given source code, and return the new contents after sorting the
imports.
-
sourceElementTypeAsString(SourceElementType type)
→ String
-
Converts the enun type SourceElementType to a human readable string.
Exceptions / Errors
-
SnippetException
-
An exception class to allow capture of exceptions generated by the Snippets
package.