1
- # The Macros module is a fictitious module used to document macros
1
+ # The ` Macros` module is a fictitious module used to document macros
2
2
# and macro methods.
3
3
#
4
4
# You can invoke a **fixed subset** of methods on AST nodes at compile-time. These methods
@@ -44,7 +44,7 @@ module Crystal::Macros
44
44
def system (command ) : MacroId
45
45
end
46
46
47
- # Gives a compile-time error with the given message.
47
+ # Gives a compile-time error with the given * message* .
48
48
def raise (message ) : NoReturn
49
49
end
50
50
@@ -133,7 +133,7 @@ module Crystal::Macros
133
133
end
134
134
135
135
# Returns a `StringLiteral` that contains this node's textual representation.
136
- # Note that invoking stringify on a string literal will return a StringLiteral
136
+ # Note that invoking stringify on a string literal will return a ` StringLiteral`
137
137
# that contains a string literal.
138
138
#
139
139
# ```
@@ -159,49 +159,49 @@ module Crystal::Macros
159
159
end
160
160
161
161
# Returns the filename where this node is located.
162
- # Might return nil if the location is not known.
162
+ # Might return ` nil` if the location is not known.
163
163
def filename : StringLiteral | NilLiteral
164
164
end
165
165
166
166
# Returns the line number where this node begins.
167
- # Might return nil if the location is not known.
167
+ # Might return ` nil` if the location is not known.
168
168
#
169
169
# The first line number in a file is 1.
170
170
def line_number : StringLiteral | NilLiteral
171
171
end
172
172
173
173
# Returns the column number where this node begins.
174
- # Might return nil if the location is not known.
174
+ # Might return ` nil` if the location is not known.
175
175
#
176
- # The first column number in a line is 1 .
176
+ # The first column number in a line is `1` .
177
177
def column_number : StringLiteral | NilLiteral
178
178
end
179
179
180
180
# Returns the line number where this node ends.
181
- # Might return nil if the location is not known.
181
+ # Might return ` nil` if the location is not known.
182
182
#
183
- # The first line number in a file is 1 .
183
+ # The first line number in a file is `1` .
184
184
def end_line_number : StringLiteral | NilLiteral
185
185
end
186
186
187
187
# Returns the column number where this node ends.
188
- # Might return nil if the location is not known.
188
+ # Might return ` nil` if the location is not known.
189
189
#
190
- # The first column number in a line is 1 .
190
+ # The first column number in a line is `1` .
191
191
def end_column_number : StringLiteral | NilLiteral
192
192
end
193
193
194
- # Returns true if this node's textual representation is the same as
195
- # the other node.
194
+ # Returns ` true` if this node's textual representation is the same as
195
+ # the * other* node.
196
196
def == (other : ASTNode ) : BoolLiteral
197
197
end
198
198
199
- # Returns true if this node's textual representation is not the same as
200
- # the other node.
199
+ # Returns ` true` if this node's textual representation is not the same as
200
+ # the * other* node.
201
201
def != (other : ASTNode ) : BoolLiteral
202
202
end
203
203
204
- # Gives a compile-time error with the given message. This will
204
+ # Gives a compile-time error with the given * message* . This will
205
205
# highlight this node in the error message.
206
206
def raise (message ) : NoReturn
207
207
end
@@ -535,7 +535,7 @@ module Crystal::Macros
535
535
def find (& block) : ASTNode | NilLiteral
536
536
end
537
537
538
- # Similar to `Array#first`, but returns a NilLiteral if the array is empty.
538
+ # Similar to `Array#first`, but returns a ` NilLiteral` if the array is empty.
539
539
def first : ASTNode | NilLiteral
540
540
end
541
541
@@ -547,7 +547,7 @@ module Crystal::Macros
547
547
def join (separator ) : StringLiteral
548
548
end
549
549
550
- # Similar to `Array#last`, but returns a NilLiteral if the array is empty.
550
+ # Similar to `Array#last`, but returns a ` NilLiteral` if the array is empty.
551
551
def last : ASTNode | NilLiteral
552
552
end
553
553
@@ -738,7 +738,7 @@ module Crystal::Macros
738
738
end
739
739
740
740
# Similar to `Regex#options`,
741
- # but returns an array of symbols such as [:i, :m, :x]
741
+ # but returns an array of symbols such as ` [:i, :m, :x]`
742
742
def options : ArrayLiteral (SymbolLiteral )
743
743
end
744
744
end
@@ -838,11 +838,11 @@ module Crystal::Macros
838
838
def cond : ASTNode
839
839
end
840
840
841
- # Returns this if's " then" clause's body.
841
+ # Returns this if's ` then` clause's body.
842
842
def then : ASTNode
843
843
end
844
844
845
- # Returns this if's " else" clause's body.
845
+ # Returns this if's ` else` clause's body.
846
846
def else : ASTNode
847
847
end
848
848
end
@@ -927,13 +927,13 @@ module Crystal::Macros
927
927
class Arg < ASTNode
928
928
# Returns the external name of this argument.
929
929
#
930
- # For example, for `def write(to file)` this returns "to" .
930
+ # For example, for `def write(to file)` returns `to` .
931
931
def name : MacroId
932
932
end
933
933
934
934
# Returns the internal name of this argument.
935
935
#
936
- # For example, for `def write(to file)` this returns " file" .
936
+ # For example, for `def write(to file)` returns ` file` .
937
937
def internal_name : MacroId
938
938
end
939
939
@@ -1027,7 +1027,7 @@ module Crystal::Macros
1027
1027
end
1028
1028
end
1029
1029
1030
- # An unary " not" (`!`).
1030
+ # An unary ` not` (`!`).
1031
1031
class Not < UnaryExpression
1032
1032
end
1033
1033
@@ -1131,7 +1131,7 @@ module Crystal::Macros
1131
1131
def names : ArrayLiteral (MacroId )
1132
1132
end
1133
1133
1134
- # Returns true if this is a global path (starts with `::`)
1134
+ # Returns ` true` if this is a global path (starts with `::`)
1135
1135
def global ? : BoolLiteral
1136
1136
end
1137
1137
@@ -1346,7 +1346,7 @@ module Crystal::Macros
1346
1346
# A fictitious node representing an idenfitifer like, `foo`, `Bar` or `something_else`.
1347
1347
#
1348
1348
# The parser doesn't create this nodes. Instead, you create them by invoking `id`
1349
- # on some nodes. For example, invoking `id` on a `StringLiteral` returns a MacroId
1349
+ # on some nodes. For example, invoking `id` on a `StringLiteral` returns a ` MacroId`
1350
1350
# for the string's content. Similarly, invoking ID on a `SymbolLiteral`, `Call`, `Var` and `Path`
1351
1351
# return MacroIds for the node's content.
1352
1352
#
@@ -1474,11 +1474,11 @@ module Crystal::Macros
1474
1474
1475
1475
# Represents a type in the program, like `Int32` or `String`.
1476
1476
class TypeNode < ASTNode
1477
- # Returns true if this type is abstract.
1477
+ # Returns ` true` if this type is abstract.
1478
1478
def abstract ? : BoolLiteral
1479
1479
end
1480
1480
1481
- # Returns true if this type is a union type, false otherwise.
1481
+ # Returns ` true` if this type is a union type, ` false` otherwise.
1482
1482
#
1483
1483
# See also: `union_types`.
1484
1484
def union ? : BoolLiteral
@@ -1527,13 +1527,13 @@ module Crystal::Macros
1527
1527
# Returns a constant defined in this type.
1528
1528
#
1529
1529
# If the constant is a constant (like `A = 1`), then its value
1530
- # as an ASTNode is returned. If the constant is a type, the
1530
+ # as an ` ASTNode` is returned. If the constant is a type, the
1531
1531
# type is returned as a `TypeNode`. Otherwise, `NilLiteral` is returned.
1532
1532
def constant (name : StringLiteral | SymbolLiteral | MacroId ) : ASTNode
1533
1533
end
1534
1534
1535
- # Returns true if this type has a constant. For example `DEFAULT_OPTIONS`
1536
- # (the name you pass to this method is "DEFAULT_OPTIONS" or :DEFAULT_OPTIONS
1535
+ # Returns ` true` if this type has a constant. For example `DEFAULT_OPTIONS`
1536
+ # (the name you pass to this method is ` "DEFAULT_OPTIONS"` or ` :DEFAULT_OPTIONS`
1537
1537
# in this cases).
1538
1538
def has_constant ?(name : StringLiteral | SymbolLiteral ) : BoolLiteral
1539
1539
end
@@ -1544,13 +1544,13 @@ module Crystal::Macros
1544
1544
end
1545
1545
1546
1546
# Returns `true` if this type has a method. For example `default_options`
1547
- # (the name you pass to this method is "default_options" or :default_options
1547
+ # (the name you pass to this method is ` "default_options"` or ` :default_options`
1548
1548
# in this cases).
1549
1549
def has_method ?(name : StringLiteral | SymbolLiteral ) : BoolLiteral
1550
1550
end
1551
1551
1552
- # Returns true if this type has an attribute. For example `@[Flags]`
1553
- # or `@[Packed]` (the name you pass to this method is "Flags" or "Packed"
1552
+ # Returns ` true` if this type has an attribute. For example `@[Flags]`
1553
+ # or `@[Packed]` (the name you pass to this method is ` "Flags"` or ` "Packed"`
1554
1554
# in these cases).
1555
1555
def has_attribute ?(name : StringLiteral | SymbolLiteral ) : BoolLiteral
1556
1556
end
0 commit comments