Skip to content

Commit 7f49024

Browse files
Add links to language specification in docs for pseudo methods (#15864)
1 parent 31a9906 commit 7f49024

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/docs_pseudo_methods.cr

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#
2121
# The expressions passed as arguments to `typeof` do not evaluate. The compiler
2222
# only analyzes their return type.
23+
#
24+
# * See [`typeof`](https://crystal-lang.org/reference/syntax_and_semantics/typeof.html) in the language specification.
2325
def __crystal_pseudo_typeof(*expression) : Class
2426
end
2527

@@ -45,6 +47,8 @@ end
4547
# This is because a `Reference`'s memory is allocated on the heap and a pointer
4648
# to it is passed around. The size of a class on the heap can be determined
4749
# using `#instance_sizeof`.
50+
#
51+
# * See [`sizeof`](https://crystal-lang.org/reference/syntax_and_semantics/sizeof.html) in the language specification.
4852
def __crystal_pseudo_sizeof(type : Class) : Int32
4953
end
5054

@@ -58,6 +62,8 @@ end
5862
# ```
5963
#
6064
# See `sizeof` for determining the size of value types.
65+
#
66+
# * See [`instance_sizeof`](https://crystal-lang.org/reference/syntax_and_semantics/instance_sizeof.html) in the language specification.
6167
def __crystal_pseudo_instance_sizeof(type : Class) : Int32
6268
end
6369

@@ -82,6 +88,8 @@ end
8288
# This is because a `Reference`'s memory is allocated on the heap and a pointer
8389
# to it is passed around. The alignment of a class on the heap can be determined
8490
# using `#instance_alignof`.
91+
#
92+
# * See [`alignof`](https://crystal-lang.org/reference/syntax_and_semantics/alignof.html) in the language specification.
8593
def __crystal_pseudo_alignof(type : Class) : Int32
8694
end
8795

@@ -95,6 +103,8 @@ end
95103
# ```
96104
#
97105
# See `alignof` for determining the size of value types.
106+
#
107+
# * See [`instance_alignof`](https://crystal-lang.org/reference/syntax_and_semantics/instance_alignof.html) in the language specification.
98108
def __crystal_pseudo_instance_alignof(type : Class) : Int32
99109
end
100110

@@ -109,6 +119,8 @@ end
109119
#
110120
# a # => 2
111121
# ```
122+
#
123+
# * See [`pointerof`](https://crystal-lang.org/reference/syntax_and_semantics/pointerof.html) in the language specification.
112124
def __crystal_pseudo_pointerof(variable : T) : Pointer(T) forall T
113125
end
114126

@@ -125,6 +137,8 @@ end
125137
# offsetof({Int32, Int8, Int32}, 1) # => 4
126138
# offsetof({Int32, Int8, Int32}, 2) # => 8
127139
# ```
140+
#
141+
# * See [`offsetof`](https://crystal-lang.org/reference/syntax_and_semantics/offsetof.html) in the language specification.
128142
def __crystal_pseudo_offsetof(type : Class, offset) : Int32
129143
end
130144

@@ -155,6 +169,8 @@ class Object
155169
# a.is_a?(Number) # => true
156170
# a.is_a?(Int32 | String) # => true
157171
# ```
172+
#
173+
# * See [`is_a?`](https://crystal-lang.org/reference/syntax_and_semantics/is_a.html) in the language specification.
158174
def __crystal_pseudo_is_a?(type : Class) : Bool
159175
end
160176

@@ -166,6 +182,8 @@ class Object
166182
# ```
167183
#
168184
# This method is equivalent to `is_a?(Nil)`.
185+
#
186+
# * See [`nil?`](https://crystal-lang.org/reference/syntax_and_semantics/nil_question.html) in the language specification.
169187
def __crystal_pseudo_nil? : Bool
170188
end
171189

@@ -196,6 +214,8 @@ class Object
196214
# typeof(a.as(Int32 | Bool)) # => Int32
197215
# a.as(Int32 | Bool) # => 1
198216
# ```
217+
#
218+
# * See [`as`](https://crystal-lang.org/reference/syntax_and_semantics/as.html) in the language specification.
199219
def __crystal_pseudo_as(type : Class)
200220
end
201221

@@ -222,6 +242,8 @@ class Object
222242
# typeof(a.as?(Int32 | Bool)) # => Int32 | Nil
223243
# a.as?(Int32 | Bool) # => 1
224244
# ```
245+
#
246+
# * See [`#as?`](https://crystal-lang.org/reference/syntax_and_semantics/as_question.html) in the language specification.
225247
def __crystal_pseudo_as?(type : Class)
226248
end
227249

@@ -234,6 +256,8 @@ class Object
234256
# a.responds_to?(:abs) # => true
235257
# a.responds_to?(:size) # => false
236258
# ```
259+
#
260+
# * See [`#responds_to?`](https://crystal-lang.org/reference/syntax_and_semantics/responds_to.html) in the language specification.
237261
def __crystal_pseudo_responds_to?(name : Symbol) : Bool
238262
end
239263
end

0 commit comments

Comments
 (0)