Class DocStrings
The descriptions a parsed module writes, which its symbols carry as DocString: the short documentation strings an editor shows for the module, its members and its variables in a hover, a completion list or signature help, as the VBE's Object Browser shows them.
public static class DocStrings
- Inheritance
-
DocStrings
- Inherited Members
Remarks
A description is written with an attribute (RD-VBAL §3.1.1.7 VB_Description, and VB_VarDescription for a module
variable) or with an annotation (RD-VBAL §3.0.1.1): '@ModuleDescription("...") for the module, '@Description("...") for a
member, '@VariableDescription("...") for a module variable.
- The attribute is the description when the module writes one, whatever an annotation says: it is what the VBE stores and shows.
- The annotation is the description when the module writes no attribute for it, as in a block of a file, which has no attributes.
An annotation is trivia (Trivia), which no node of the tree holds, so these readers take the whole parse. For a file that has blocks, they take the parse of one module (ParseOf(Uri)), which holds that module's trivia alone.
A description is the text of a string: its quotes are not part of it, and a doubled quote in it is one. An empty string, and an annotation whose first argument is not a string, describe nothing.
Fields
MemberDescriptionAnnotation
The name of the annotation that describes a member: '@Description("...").
public const string MemberDescriptionAnnotation = "Description"
Field Value
ModuleDescriptionAnnotation
The name of the annotation that describes a module: '@ModuleDescription("...").
public const string ModuleDescriptionAnnotation = "ModuleDescription"
Field Value
VariableDescriptionAnnotation
The name of the annotation that describes a module variable: '@VariableDescription("...").
public const string VariableDescriptionAnnotation = "VariableDescription"
Field Value
Methods
GetMemberDescription(ModuleParseResult, string)
The description of a member or a module variable of the module, or null when the module writes none for it.
public static string? GetMemberDescription(this ModuleParseResult parse, string memberName)
Parameters
parseModuleParseResultThe module's parse.
memberNamestringThe name of the member or the variable, compared without regard to case.
Returns
- string
The member's
Attribute <member>.VB_Description(GetMemberDescription(ModuleNode, string)) or the variable'sAttribute <variable>.VB_VarDescription(GetVariableDescription(ModuleNode, string)); else the'@Descriptionannotation written immediately above a member of that name, or the'@VariableDescriptionone immediately above a variable of that name. The first declaration of that name that has one gives it.
Remarks
A member annotation is immediately above its declaration (RD-VBAL §3.0.1.1) when it is on one of the comment lines that end on
the line before the declaration's first line: no blank line, no code and no directive is written between them, and no code before the comment on
its line. Of several such annotations, the first written counts. A variable declared after another in one statement (b of
Dim a, b) has no lines above it of its own.
In a tree that holds the nodes of several files, an annotation and a declaration match only in one file, as each node's Uri says.
GetModuleDescription(ModuleParseResult)
The description of the module, or null when it writes none.
public static string? GetModuleDescription(this ModuleParseResult parse)
Parameters
parseModuleParseResultThe module's parse.
Returns
- string
The text of the node GetModuleDescriptionNode(ModuleParseResult) gives.
GetModuleDescriptionNode(ModuleParseResult)
Where the module writes its description: its own Attribute VB_Description directive (an AttributeDirectiveNode,
GetModuleDescriptionDirective(ModuleNode)), else its first description annotation (an AnnotationTriviaNode):
a '@ModuleDescription, or, above the header of a block's module, a '@Description. null when it writes none.
public static SyntaxNode? GetModuleDescriptionNode(this ModuleParseResult parse)
Parameters
parseModuleParseResultThe module's parse.
Returns
Remarks
A module annotation binds in the module's declarations section (RD-VBAL §3.0.1.1): one written after the start of the module's
first procedure does not describe the module. One written on the line right above that procedure still does, because @ModuleDescription
annotates a module only, and an annotation has one target (Annotations). In a tree that holds the nodes of several files, each
annotation is in the declarations section of its own file.
The module of a block of a file also binds the annotations on the comment lines directly above its header
(GetHeaderAnnotations(ModuleParseResult)). A '@Description there describes the block's module, as one above a member describes the
member; inside the block, it is a member's. Of the description annotations of the module, the first written counts.