Skip to content

Commit 4c02adc

Browse files
Removed duplicates of debug.info() (#1085)
## Changes <!-- Please summarize your changes. --> <!-- Please link to any applicable information (forum posts, bug reports, etc.). --> I ran into the debug.info() thing 3 times while scrolling. This should fix it. One of the duplicates had a different code sample that the other two, so I cut and pasted it into the one debug.info() that I made. ## Checks By submitting your pull request for review, you agree to the following: - [x] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [x] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [x] To the best of my knowledge, all proposed changes are accurate. --------- Co-authored-by: IgnisRBX <[email protected]>
1 parent 65bca5e commit 4c02adc

File tree

1 file changed

+33
-176
lines changed
  • content/en-us/reference/engine/libraries

1 file changed

+33
-176
lines changed

content/en-us/reference/engine/libraries/debug.yaml

Lines changed: 33 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,10 @@ functions:
2424
the call of the function calling `Library.debug.traceback()`, and so on.
2525
See the code sample below for an example of sequential function calls.
2626
27-
Note that this function will often return inaccurate results (compared to
28-
the original source code) and that the format of the returned traceback
29-
may change at any time. You should **not** parse the return value for
30-
specific information such as script names or line numbers.
27+
This function can accept two variations in its parameters:
3128
32-
The following example includes sequential function calls; `fnB()` is
33-
called, and it calls `fnA()` which then calls `Library.debug.traceback()`.
34-
35-
```lua
36-
local function fnA()
37-
print(debug.traceback("Specific moment during fnA()"))
38-
end
39-
40-
local function fnB()
41-
fnA()
42-
end
43-
44-
-- Call function fnB() to begin traceback
45-
fnB()
46-
```
47-
parameters:
48-
- name: message
49-
type: string
50-
default: ''
51-
summary: |
52-
The first line of the returned string.
53-
- name: level
54-
type: number
55-
default: 1
56-
summary: |
57-
The number of calls "up" the call stack to return.
58-
returns:
59-
- type: string
60-
summary: |
61-
Traceback of the current function call stack.
62-
tags:
63-
code_samples:
64-
- name: debug.traceback
65-
summary: |
66-
Returns a string of undefined format that describes the current function
67-
call stack.
68-
description: |
69-
Returns a traceback of the current function call stack as a string; in
70-
other words, a description of the functions that have been called up to
71-
this point. During debugging, this behaves like an error stack trace but
72-
does not stop execution of the script.
73-
74-
The `level` parameter specifies what level of the call stack to consider,
75-
with `1` being the call of `Library.debug.traceback()` itself, `2` being
76-
the call of the function calling `Library.debug.traceback()`, and so on.
77-
See the code sample below for an example of sequential function calls.
29+
- `debug.traceback(message, level)`
30+
- `debug.traceback(thread, message, level)` — Similar except the first parameter is a thread as returned by `Library.coroutine.create()`.
7831
7932
Note that this function will often return inaccurate results (compared to
8033
the original source code) and that the format of the returned traceback
@@ -98,10 +51,10 @@ functions:
9851
```
9952
parameters:
10053
- name: thread
101-
type: thread
54+
type: thread?
10255
default:
10356
summary: |
104-
A thread as returned by `Library.coroutine.create()`.
57+
Optional thread as returned by `Library.coroutine.create()`.
10558
- name: message
10659
type: string
10760
default: ''
@@ -129,145 +82,49 @@ functions:
12982
as well as for sending the data to systems expecting structured input,
13083
such as crash aggregation.
13184
132-
```lua
133-
local function fnA()
134-
-- Output source identifier ("s") and line ("l") at levels 1 and 2
135-
print(debug.info(1, "sl")) --> fnA() 3
136-
print(debug.info(2, "sl")) --> fnA() 7
137-
end
85+
This function can accept three variations in its parameters:
13886
139-
fnA()
140-
```
87+
- `debug.info(level, options)`
14188
142-
Note that this function is similar to
143-
[debug.getinfo](https://www.lua.org/pil/23.1.html), an unavailable part of
144-
the standard Lua library which serves a similar purpose.
145-
parameters:
146-
- name: level
147-
type: number
148-
default:
149-
summary: |
150-
Determines at what level of the call stack the information returned
151-
should describe. A value of `1` represents the function which is
152-
calling `Library.debug.info()`, a value of `2` represents the function
153-
that called that function, and so on.
154-
- name: options
155-
type: string
156-
default:
157-
summary: |
158-
A string that describes what the returned information should
159-
represent. It must only contain 0 or 1 instances of the characters
160-
`slnaf`, each representing a piece of information:
161-
162-
- `s` ([string](/luau/strings.md)) — The function source identifier,
163-
equal to the full name of the script the function is defined in.
164-
- `l` ([number](/luau/numbers.md)) — The line number of the function
165-
call represented by `level`.
166-
- `n` ([string](/luau/strings.md)) — The name of the function; may be
167-
`nil` for anonymous functions and C functions without an assigned
168-
debug name.
169-
- `a` ([number](/luau/numbers.md), [boolean](/luau/booleans.md)) —
170-
Arity of the function, which refers to the parameter count and
171-
whether the function is variadic.
172-
- `f` ([function](/luau/functions.md)) — The function which was
173-
inspected.
174-
returns:
175-
- type: Tuple
176-
summary: ''
177-
tags:
178-
code_samples:
179-
- name: debug.info
180-
summary: |
181-
Traverses the entire stack of current thread and returns a string
182-
containing the call stack of target function details.
183-
description: |
184-
Allows programmatic inspection of the call stack. This function differs
185-
from `Library.debug.traceback()` in that it guarantees the format of the
186-
data it returns. This is useful for general logging and filtering purposes
187-
as well as for sending the data to systems expecting structured input,
188-
such as crash aggregation.
89+
```lua
90+
local function fnA()
91+
-- Output source identifier ("s") and line ("l") at levels 1 and 2
92+
print(debug.info(1, "sl")) --> fnA() 3
93+
print(debug.info(2, "sl")) --> fnA() 7
94+
end
18995
190-
```lua
191-
local function fnA()
96+
fnA()
97+
```
19298
193-
end
99+
- `debug.info(thread, level, options)` — Similar to above except the first parameter is a thread as returned by `Library.coroutine.create()`.
194100
195-
local function fnB()
101+
- `debug.info(function, options)`
196102
197-
end
103+
```lua
104+
local function fnA()
105+
end
198106
199-
-- Output line ("l"), name ("n"), and identifier ("f") for both fnA() and fnB()
200-
print(debug.info(fnA, "lnf")) --> 1 fnA function: 0x75e3d3c398a81252
201-
print(debug.info(fnB, "lnf")) --> 5 fnB function: 0x6022a6dc5ccf4ab2
202-
```
107+
local function fnB()
108+
end
203109
204-
Note that this function is similar to
205-
[debug.getinfo](https://www.lua.org/pil/23.1.html), an unavailable part of
206-
the standard Lua library which serves a similar purpose.
110+
-- Output line ("l"), name ("n"), and identifier ("f") for both fnA() and fnB()
111+
print(debug.info(fnA, "lnf")) --> 1 fnA function: 0x75e3d3c398a81252
112+
print(debug.info(fnB, "lnf")) --> 5 fnB function: 0x6022a6dc5ccf4ab2
113+
```
207114
parameters:
115+
- name: thread
116+
type: thread?
117+
default:
118+
summary: |
119+
Optional thread as returned by `Library.coroutine.create()`.
208120
- name: function
209-
type: function
121+
type: function?
210122
default:
211123
summary: |
212124
The function of the call stack which the information returned should
213125
describe.
214-
- name: options
215-
type: string
216-
default:
217-
summary: |
218-
A string that describes what the returned information should
219-
represent. It must only contain 0 or 1 instances of the characters
220-
`slnaf`, each representing a piece of information:
221-
222-
- `s` ([string](/luau/strings.md)) — The function source identifier,
223-
equal to the full name of the script the function is defined in.
224-
- `l` ([number](/luau/numbers.md)) — The line that `function` is
225-
defined on.
226-
- `n` ([string](/luau/strings.md)) — The name of the function; may be
227-
`nil` for anonymous functions and C functions without an assigned
228-
debug name.
229-
- `a` ([number](/luau/numbers.md), [boolean](/luau/booleans.md)) —
230-
Arity of the function, which refers to the parameter count and
231-
whether the function is variadic.
232-
- `f` ([function](/luau/functions.md)) — The function which was
233-
inspected.
234-
returns:
235-
- type: Tuple
236-
summary: ''
237-
tags:
238-
code_samples:
239-
- name: debug.info
240-
summary: |
241-
Traverses the entire stack of target thread and returns a string
242-
containing the call stack of target level details.
243-
description: |
244-
Allows programmatic inspection of the call stack. This function differs
245-
from `Library.debug.traceback()` in that it guarantees the format of the
246-
data it returns. This is useful for general logging and filtering purposes
247-
as well as for sending the data to systems expecting structured input,
248-
such as crash aggregation.
249-
250-
```lua
251-
local function fnA()
252-
-- Output source identifier ("s") and line ("l") at levels 1 and 2
253-
print(debug.info(1, "sl")) --> fnA() 3
254-
print(debug.info(2, "sl")) --> fnA() 7
255-
end
256-
257-
fnA()
258-
```
259-
260-
Note that this function is similar to
261-
[debug.getinfo](https://www.lua.org/pil/23.1.html), an unavailable part of
262-
the standard Lua library which serves a similar purpose.
263-
parameters:
264-
- name: thread
265-
type: thread
266-
default:
267-
summary: |
268-
A thread as returned by `Library.coroutine.create()`.
269126
- name: level
270-
type: number
127+
type: number?
271128
default:
272129
summary: |
273130
Determines at what level of the call stack the information returned

0 commit comments

Comments
 (0)