doc: tooltip: add type/optional information

Closes https://github.com/awesomeWM/awesome/pull/379.
This commit is contained in:
Daniel Hahler 2015-07-30 20:29:07 +02:00
parent 836aded988
commit 475b469f96
1 changed files with 40 additions and 36 deletions

View File

@ -53,24 +53,24 @@ local setmetatable = setmetatable
local ipairs = ipairs local ipairs = ipairs
--- Tooltip object definition. --- Tooltip object definition.
-- @table awful.tooltip -- @table tooltip
-- @field wibox The wibox displaying the tooltip. -- @tfield wibox wibox The wibox displaying the tooltip.
-- @field visible True if tooltip is visible. -- @tfield boolean visible True if tooltip is visible.
local tooltip = { mt = {} } local tooltip = { mt = {} }
--- Tooltip private data. --- Tooltip private data.
-- @local -- @local
-- @table awful.tooltip.data -- @table tooltip.data
-- @field fg tooltip foreground color. -- @tfield string fg tooltip foreground color.
-- @field font Tooltip font. -- @tfield string font Tooltip font.
-- @field hide The hide() function. -- @tfield function hide The hide() function.
-- @field show The show() function. -- @tfield function show The show() function.
-- @field timer The text update timer. -- @tfield gears.timer timer The text update timer.
-- @field timer_function The text update timer function. -- @tfield function timer_function The text update timer function.
local data = setmetatable({}, { __mode = 'k' }) local data = setmetatable({}, { __mode = 'k' })
-- Place the tooltip on the screen. -- Place the tooltip on the screen.
-- @param self A tooltip object. -- @tparam tooltip self A tooltip object.
local function place(self) local function place(self)
a_placement.under_mouse(self.wibox) a_placement.under_mouse(self.wibox)
a_placement.no_offscreen(self.wibox) a_placement.no_offscreen(self.wibox)
@ -78,7 +78,7 @@ end
-- Place the tooltip under the mouse. -- Place the tooltip under the mouse.
-- --
-- @param self A tooltip object. -- @tparam tooltip self A tooltip object.
local function set_geometry(self) local function set_geometry(self)
local my_geo = self.wibox:geometry() local my_geo = self.wibox:geometry()
-- calculate width / height -- calculate width / height
@ -92,7 +92,7 @@ end
-- Show a tooltip. -- Show a tooltip.
-- --
-- @param self The tooltip to show. -- @tparam tooltip self The tooltip to show.
local function show(self) local function show(self)
-- do nothing if the tooltip is already shown -- do nothing if the tooltip is already shown
if self.visible then return end if self.visible then return end
@ -110,7 +110,7 @@ end
-- Hide a tooltip. -- Hide a tooltip.
-- --
-- @param self The tooltip to hide. -- @tparam tooltip self The tooltip to hide.
local function hide(self) local function hide(self)
-- do nothing if the tooltip is already hidden -- do nothing if the tooltip is already hidden
if not self.visible then return end if not self.visible then return end
@ -125,8 +125,9 @@ end
--- Change displayed text. --- Change displayed text.
-- --
-- @param self The tooltip object. -- @tparam tooltip self The tooltip object.
-- @param text New tooltip text. -- @tparam string text New tooltip text, passed to
-- `wibox.widget.textbox.set_text`.
tooltip.set_text = function(self, text) tooltip.set_text = function(self, text)
self.textbox:set_text(text) self.textbox:set_text(text)
set_geometry(self) set_geometry(self)
@ -134,8 +135,9 @@ end
--- Change displayed text. --- Change displayed text.
-- --
-- @param self The tooltip object. -- @tparam tooltip self The tooltip object.
-- @param text New tooltip text, including pango markup. -- @tparam string text New tooltip markup, passed to
-- `wibox.widget.textbox.set_markup`.
tooltip.set_markup = function(self, text) tooltip.set_markup = function(self, text)
self.textbox:set_markup(text) self.textbox:set_markup(text)
set_geometry(self) set_geometry(self)
@ -143,9 +145,8 @@ end
--- Change the tooltip's update interval. --- Change the tooltip's update interval.
-- --
-- @param self A tooltip object. -- @tparam tooltip self A tooltip object.
-- @param timeout The timeout value. -- @tparam number timeout The timeout value.
-- @function set_timeout
tooltip.set_timeout = function(self, timeout) tooltip.set_timeout = function(self, timeout)
if data[self].timer then if data[self].timer then
data[self].timer.timeout = timeout data[self].timer.timeout = timeout
@ -154,8 +155,9 @@ end
--- Add tooltip to an object. --- Add tooltip to an object.
-- --
-- @param self The tooltip. -- @tparam tooltip self The tooltip.
-- @param object An object. -- @tparam gears.object object An object with `mouse::enter` and
-- `mouse::leave` signals.
tooltip.add_to_object = function(self, object) tooltip.add_to_object = function(self, object)
object:connect_signal("mouse::enter", data[self].show) object:connect_signal("mouse::enter", data[self].show)
object:connect_signal("mouse::leave", data[self].hide) object:connect_signal("mouse::leave", data[self].hide)
@ -163,9 +165,9 @@ end
--- Remove tooltip from an object. --- Remove tooltip from an object.
-- --
-- @param self The tooltip. -- @tparam tooltip self The tooltip.
-- @param object An object. -- @tparam gears.object object An object with `mouse::enter` and
-- @function remove_from_object -- `mouse::leave` signals.
tooltip.remove_from_object = function(self, object) tooltip.remove_from_object = function(self, object)
object:disconnect_signal("mouse::enter", data[self].show) object:disconnect_signal("mouse::enter", data[self].show)
object:disconnect_signal("mouse::leave", data[self].hide) object:disconnect_signal("mouse::leave", data[self].hide)
@ -173,16 +175,18 @@ end
--- Create a new tooltip and link it to a widget. --- Create a new tooltip and link it to a widget.
-- @tparam table args Arguments for tooltip creation. -- @tparam table args Arguments for tooltip creation.
-- @tparam number args.timeout The timeout value for update_func. -- @tparam[opt=1] number args.timeout The timeout value for
-- @tparam function args.timer_function A function to dynamically change the -- `timer_function`.
-- tooltip text. -- @tparam function args.timer_function A function to dynamically set the
-- @tparam table args.objects A list of objects linked to the tooltip. -- tooltip text. Its return value will be passed to
-- @tparam number args.delay_show Delay showing the tooltip by this many -- `wibox.widget.textbox.set_markup`.
-- seconds. -- @tparam[opt] table args.objects A list of objects linked to the tooltip.
-- @tparam integer args.margin_leftright The left/right margin for the text. -- @tparam[opt] number args.delay_show Delay showing the tooltip by this many
-- @tparam integer args.margin_topbottom The top/bottom margin for the text. -- seconds.
-- @return The created tooltip. -- @tparam[opt=apply_dpi(5)] integer args.margin_leftright The left/right margin for the text.
-- @tparam[opt=apply_dpi(3)] integer args.margin_topbottom The top/bottom margin for the text.
-- @treturn awful.tooltip The created tooltip.
-- @see add_to_object -- @see add_to_object
-- @see set_timeout -- @see set_timeout
-- @see set_text -- @see set_text