Skip to content

Commit 564fd20

Browse files
committed
Moved lib/libLog.lua to lib/dtutils/log.lua. Rewrote most of it to make it more configurable and easier to use. Updated doc format to a fixed list of fields. Did away with the comment blocks and just relying on the libdoc comments. Update doc tools to use new formats. Moved dtutils/extensions.lua to dtutils/string.lua. Pulled dtutils/processor.lua back for now since there is no context for it. Removed unneeded functions and cleaned up others.
1 parent a254ac8 commit 564fd20

File tree

10 files changed

+651
-1458
lines changed

10 files changed

+651
-1458
lines changed

lib/dtutils.lua

Lines changed: 59 additions & 298 deletions
Large diffs are not rendered by default.

lib/dtutils/de_DE/LC_MESSAGES/dtutils.processor.po

Lines changed: 0 additions & 23 deletions
This file was deleted.

lib/dtutils/debug.lua

Lines changed: 59 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--[[
22
This file is part of darktable,
3-
copyright (c) 2014 Jérémy Rosen
3+
Copyright (c) 2014 Jérémy Rosen
4+
Copyright (c) 2016 Bill Ferguson
45
56
darktable is free software: you can redistribute it and/or modify
67
it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@ A collection of helper functions to help debugging lua scripts.
2122
2223
require it as
2324
24-
dhelpers = require "official/debug-helpers"
25+
dhelpers = require "lib/dtutils.debug"
2526
2627
Each function is documented in its own header
2728
@@ -33,177 +34,118 @@ local dt = require "darktable"
3334
local io = require "io"
3435
local table = require "table"
3536
require "darktable.debug"
36-
local log = require "lib/libLog"
37+
local log = require "lib/dtutils.log"
3738
local M = {} -- The actual content of the module
3839

3940
M.libdoc = {
40-
Sections = {"Name", "Synopsis", "Description", "License"},
41-
Name = [[dtutils.debug - debugging helpers used in developing darktable lua scripts]],
42-
Synopsis = [[local dd = require "lib/dtutils.debug"]],
41+
Name = [[dtutils.debug]],
42+
Synopsis = [[debugging helpers used in developing darktable lua scripts]],
43+
Usage = [[local dd = require "lib/dtutils.debug"]],
4344
Description = [[dtutils.debug provides an interface to the darktable debugging routines.]],
44-
License = [[This program is free software: you can redistribute it and/or modify
45-
it under the terms of the GNU General Public License as published by
46-
the Free Software Foundation; either version 3 of the License, or
47-
(at your option) any later version.
48-
49-
This program is distributed in the hope that it will be useful,
50-
but WITHOUT ANY WARRANTY; without even the implied warranty of
51-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52-
GNU General Public License for more details.
53-
54-
You should have received a copy of the GNU General Public License
55-
along with this program. If not, see <http://www.gnu.org/licenses/>.]],
45+
Return_Value = [[dd - library - the darktable lua debugging helpers]],
46+
Limitations = [[]],
47+
Example = [[]],
48+
See_Also = [[]],
49+
Reference = [[]],
50+
License = log.libdoc.License,
51+
Copyright = [[Copyright (c) 2014 Jérémy Rosen
52+
Copyright (c) 2016 Bill Ferguson
53+
]],
5654
functions = {}
5755
}
5856

59-
--[[
60-
NAME
61-
tracepoint - print out a tracepoint and dump the arguments
62-
63-
SYNOPSIS
64-
local dd = require "lib/dtutils.debug"
65-
66-
local result = tracepoint(name, ...)
67-
name - string - the name of the tracepoint to print out
68-
... - arguments - variables to dump the contents of
69-
70-
DESCRIPTION
71-
tracepoint prints its name and dumps its parameters using
72-
dt.debug
73-
74-
RETURN VALUE
75-
result - ... - the supplied argument list
76-
77-
]]
78-
79-
M.libdoc.functions[#M.libdoc.functions + 1] = {
80-
Sections = {"Name", "Synopsis", "Description", "Return_Value"},
81-
Name = [[tracepoint - print out a tracepoint and dump the arguments]],
82-
Synopsis = [[local dd = require "lib/dtutils.debug"
57+
M.libdoc.functions["tracepoint"] = {
58+
Name = [[tracepoint]],
59+
Synopsis = [[print out a tracepoint and dump the arguments]],
60+
Usage = [[local dd = require "lib/dtutils.debug"
8361
8462
local result = tracepoint(name, ...)
8563
name - string - the name of the tracepoint to print out
8664
... - arguments - variables to dump the contents of]],
8765
Description = [[tracepoint prints its name and dumps its parameters using
8866
dt.debug]],
8967
Return_Value = [[result - ... - the supplied argument list]],
68+
Limitations = [[]],
69+
Example = [[]],
70+
See_Also = [[]],
71+
Reference = [[]],
72+
License = [[]],
73+
Copyright = [[]],
9074
}
9175

9276
function M.tracepoint(name,...)
93-
log.always(4, "***** "..name.." ****")
77+
log.msg(log.always, 4, "***** "..name.." ****")
9478
params = {...}
95-
print(dt.debug.dump(params,"parameters"))
79+
log.msg(log.always, 0, dt.debug.dump(params,"parameters"))
9680
return ...;
9781
end
9882

99-
100-
101-
--[[
102-
NAME
103-
new_tracepoint - create a function returning a tracepoint
104-
105-
SYNOPSIS
106-
local dd = require "lib/dtutils.debug"
107-
108-
local result = new_tracepoint(name, ...)
109-
name - string - the name of the tracepoint to print out
110-
... - arguments - variables to dump the contents of
111-
112-
113-
DESCRIPTION
114-
A function that returns a tracepoint function with the given name
115-
This is mainly used to debug callbacks.
116-
117-
RETURN VALUE
118-
result - function - a function that returns the result of a tracepoint
119-
120-
EXAMPLE
121-
register_event(event, dd.new_tracepoint("hit callback"))
122-
123-
will print the following each time the callback is called
124-
125-
**** hit callback ****
126-
<all the callback's parameters dumped>
127-
128-
]]
129-
130-
M.libdoc.functions[#M.libdoc.functions + 1] = {
131-
Sections = {"Name", "Synopsis", "Description", "Return_Value", "Example"},
132-
Name = [[new_tracepoint - create a function returning a tracepoint]],
133-
Synopsis = [[local dd = require "lib/dtutils.debug"
83+
M.libdoc.functions["new_tracepoint"] = {
84+
Name = [[new_tracepoint]],
85+
Synopsis = [[create a function returning a tracepoint]],
86+
Usage = [[local dd = require "lib/dtutils.debug"
13487
13588
local result = new_tracepoint(name, ...)
13689
name - string - the name of the tracepoint to print out
13790
... - arguments - variables to dump the contents of]],
13891
Description = [[A function that returns a tracepoint function with the given name
13992
This is mainly used to debug callbacks.]],
14093
Return_Value = [[result - function - a function that returns the result of a tracepoint]],
94+
Limitations = [[]],
14195
Example = [[register_event(event, dd.new_tracepoint("hit callback"))
14296
14397
will print the following each time the callback is called
14498
14599
**** hit callback ****
146100
<all the callback's parameters dumped>]],
101+
See_Also = [[]],
102+
Reference = [[]],
103+
License = [[]],
104+
Copyright = [[]],
147105
}
148106

149107
function M.new_tracepoint(name)
150108
return function(...) return M.tracepoint(name,...) end
151109
end
152110

153111

154-
--[[
155-
NAME
156-
dprint - pass a variable to dt.debug.dump and print the results to stdout
157-
158-
SYNOPSIS
159-
local dd = require "lib/dtutils.debug"
160-
161-
dd.dprint(var)
162-
var - variable - any variable that you want to see the contents of
163-
164-
DESCRIPTION
165-
Wrapper around debug.dump, will directly print to stdout,
166-
same calling convention
167-
168-
]]
169-
170-
M.libdoc.functions[#M.libdoc.functions + 1] = {
171-
Sections = {"Name", "Synopsis", "Description"},
172-
Name = [[dprint - pass a variable to dt.debug.dump and print the results to stdout]],
173-
Synopsis = [[local dd = require "lib/dtutils.debug"
112+
M.libdoc.functions["dprint"] = {
113+
Name = [[dprint]],
114+
Synopsis = [[pass a variable to dt.debug.dump and print the results to stdout]],
115+
Usage = [[local dd = require "lib/dtutils.debug"
174116
175117
dd.dprint(var)
176118
var - variable - any variable that you want to see the contents of]],
177119
Description = [[Wrapper around debug.dump, will directly print to stdout,
178120
same calling convention]],
121+
Return_Value = [[]],
122+
Limitations = [[]],
123+
Example = [[]],
124+
See_Also = [[]],
125+
Reference = [[]],
126+
License = [[]],
127+
Copyright = [[]],
179128
}
180129

181130
function M.dprint(...)
182131
log.always(4, dt.debug.dump(...))
183132
end
184133

185-
--[[
186-
NAME
187-
terse_dump - set dt.debug.known to shorten all image dumps to a single line
188-
189-
SYNOPSIS
190-
local dd = require "lib/dtutils.debug"
191-
192-
dd.terse_dump()
193-
194-
DESCRIPTION
195-
terse_dump sets dt.debug.known to shorten all images to a single line.
196-
If you don't need to debug the content of images, this will avoid them flooding your logs
197-
]]
198-
199-
M.libdoc.functions[#M.libdoc.functions + 1] = {
200-
Sections = {"Name", "Synopsis", "Description"},
201-
Name = [[terse_dump - set dt.debug.known to shorten all image dumps to a single line]],
202-
Synopsis = [[local dd = require "lib/dtutils.debug"
134+
M.libdoc.functions["terse_dump"] = {
135+
Name = [[terse_dump]],
136+
Synopsis = [[set dt.debug.known to shorten all image dumps to a single line]],
137+
Usage = [[local dd = require "lib/dtutils.debug"
203138
204139
dd.terse_dump()]],
205140
Description = [[terse_dump sets dt.debug.known to shorten all images to a single line.
206141
If you don't need to debug the content of images, this will avoid them flooding your logs]],
142+
Return_Value = [[]],
143+
Limitations = [[]],
144+
Example = [[]],
145+
See_Also = [[]],
146+
Reference = [[]],
147+
License = [[]],
148+
Copyright = [[]],
207149
}
208150

209151
function M.terse_dump()

0 commit comments

Comments
 (0)