Docs: Add local functions to beautiful and naughty

Signed-off-by: Ignas Anikevicius (gns_ank) <anikevicius@gmail.com>
This commit is contained in:
Ignas Anikevicius (gns_ank) 2014-05-26 20:43:39 +01:00 committed by Daniel Hahler
parent ac7377aa3e
commit 6ab86b5d03
2 changed files with 72 additions and 49 deletions

View File

@ -35,6 +35,10 @@ local descs = setmetatable({}, { __mode = 'k' })
local fonts = setmetatable({}, { __mode = 'v' }) local fonts = setmetatable({}, { __mode = 'v' })
local active_font local active_font
--- Load a font name
--
-- @param Font name, which can be a string or a table
-- @local here
local function load_font(name) local function load_font(name)
name = name or active_font name = name or active_font
if name and type(name) ~= "string" and descs[name] then if name and type(name) ~= "string" and descs[name] then
@ -61,14 +65,24 @@ local function load_font(name)
return font return font
end end
--- Set an active font
--
-- @param name The font
-- @local here
local function set_font(name) local function set_font(name)
active_font = load_font(name).name active_font = load_font(name).name
end end
--- Get a font description
--
-- @param name The name of the font
function beautiful.get_font(name) function beautiful.get_font(name)
return load_font(name).description return load_font(name).description
end end
--- Get the heigh of a font
--
-- @param name Name of the font
function beautiful.get_font_height(name) function beautiful.get_font_height(name)
return load_font(name).height return load_font(name).height
end end

View File

@ -31,48 +31,50 @@ local tins = table.insert
local naughty = {} local naughty = {}
--- Naughty configuration - a table containing common popup settings. --[[--
-- Naughty configuration - a table containing common popup settings.
-- @table naughty.config
-- @field padding Space between popups and edge of the workarea. @table naughty.config
-- Default: `4` @field padding Space between popups and edge of the workarea.
-- @field spacing Spacing between popups. Default: `4`
-- Default: `1` @field spacing Spacing between popups.
-- @field icon_dirs List of directories that will be checked by `getIcon()`. Default: `1`
-- Default: `{ "/usr/share/pixmaps/", }` @field icon_dirs List of directories that will be checked by `getIcon()`.
-- @field icon_formats List of formats that will be checked by `getIcon()`. Default: `{ "/usr/share/pixmaps/", }`
-- Default: `{ "png", "gif" }` @field icon_formats List of formats that will be checked by `getIcon()`.
-- @field notify_callback Callback used to modify or reject notifications. Default: `{ "png", "gif" }`
-- Default: `nil` @field notify_callback Callback used to modify or reject notifications.
-- naughty.config.notify_callback = function(args) Default: `nil`
-- args.text = 'prefix: ' .. args.text naughty.config.notify_callback = function(args)
-- return args args.text = 'prefix: ' .. args.text
-- end return args
-- end
-- @field presets Notification Presets - a table containing presets for
-- different purposes. Preset is a table of any parameters available to @field presets Notification Presets - a table containing presets for
-- `notify()`, overriding default values (`naughty.config.defaults`) You have different purposes. Preset is a table of any parameters available to
-- to pass a reference of a preset in your notify() call to use the preset The `notify()`, overriding default values (`naughty.config.defaults`) You have
-- presets `"low"`, `"normal"` and `"critical"` are used for notifications to pass a reference of a preset in your notify() call to use the preset The
-- over DBUS. presets `"low"`, `"normal"` and `"critical"` are used for notifications
-- over DBUS.
-- @field presets.low The preset for notifications with low urgency level.
-- @field presets.normal The default preset for every notification without a @field presets.low The preset for notifications with low urgency level.
-- preset that will also be used for normal urgency level. @field presets.normal The default preset for every notification without a
-- @field presets.critical The preset for notifications with a critical urgency preset that will also be used for normal urgency level.
-- level. @field presets.critical The preset for notifications with a critical urgency
-- level.
-- @field defaults Default values for the params to `notify()`.
-- These can optionally be overridden by specifying a preset. @field defaults Default values for the params to `notify()`.
-- These can optionally be overridden by specifying a preset.
-- @field mapping DBUS notification to preset mapping.
-- The first element is an object containing the filter If the rules in the @field mapping DBUS notification to preset mapping.
-- filter matches the associated preset will be applied The rules object can The first element is an object containing the filter If the rules in the
-- contain: urgency, category, appname The second element is the preset filter matches the associated preset will be applied The rules object can
-- contain: urgency, category, appname The second element is the preset
-- @field mapping.1 low urgency
-- @field mapping.2 normal urgency @field mapping.1 low urgency
-- @field mapping.3 critical urgency @field mapping.2 normal urgency
@field mapping.3 critical urgency
--]]
-- --
naughty.config = { naughty.config = {
padding = 4, padding = 4,
@ -120,8 +122,9 @@ local counter = 1
local suspended = false local suspended = false
--- Index of notifications per screen and position. --- Index of notifications per screen and position.
-- See config table for valid 'position' values. -- See config table for valid 'position' values.
-- Each element is a table consisting of: -- Each element is a table consisting of:
--
-- @field box Wibox object containing the popup -- @field box Wibox object containing the popup
-- @field height Popup height -- @field height Popup height
-- @field width Popup width -- @field width Popup width
@ -164,13 +167,15 @@ function naughty.toggle()
end end
end end
-- Evaluate desired position of the notification by index - internal --- Evaluate desired position of the notification by index - internal
--
-- @param idx Index of the notification -- @param idx Index of the notification
-- @param position top_right | top_left | bottom_right | bottom_left -- @param position top_right | top_left | bottom_right | bottom_left
-- | top_middle | bottom_middle -- | top_middle | bottom_middle
-- @param height Popup height -- @param height Popup height
-- @param width Popup width (optional) -- @param width Popup width (optional)
-- @return Absolute position and index in { x = X, y = Y, idx = I } table -- @return Absolute position and index in { x = X, y = Y, idx = I } table
-- @local here
local function get_offset(screen, position, idx, width, height) local function get_offset(screen, position, idx, width, height)
local ws = capi.screen[screen].workarea local ws = capi.screen[screen].workarea
local v = {} local v = {}
@ -210,8 +215,10 @@ local function get_offset(screen, position, idx, width, height)
return v return v
end end
-- Re-arrange notifications according to their position and index - internal --- Re-arrange notifications according to their position and index - internal
--
-- @return None -- @return None
-- @local here
local function arrange(screen) local function arrange(screen)
for p,pos in pairs(naughty.notifications[screen]) do for p,pos in pairs(naughty.notifications[screen]) do
for i,notification in pairs(naughty.notifications[screen][p]) do for i,notification in pairs(naughty.notifications[screen][p]) do
@ -223,6 +230,7 @@ local function arrange(screen)
end end
--- Destroy notification by notification object --- Destroy notification by notification object
--
-- @param notification Notification object to be destroyed -- @param notification Notification object to be destroyed
-- @param reason One of the reasons from notificationClosedReason -- @param reason One of the reasons from notificationClosedReason
-- @return True if the popup was successfully destroyed, nil otherwise -- @return True if the popup was successfully destroyed, nil otherwise
@ -250,7 +258,8 @@ function naughty.destroy(notification, reason)
end end
end end
-- Get notification by ID --- Get notification by ID
--
-- @param id ID of the notification -- @param id ID of the notification
-- @return notification object if it was found, nil otherwise -- @return notification object if it was found, nil otherwise
function naughty.getById(id) function naughty.getById(id)
@ -266,9 +275,9 @@ function naughty.getById(id)
end end
end end
--- Create notification. --- Create a notification.
-- --
-- @tab args The argument table containing any of the arguments bellow. -- @tab args The argument table containing any of the arguments below.
-- @string args.text Text of the notification. -- @string args.text Text of the notification.
-- Default: '' -- Default: ''
-- @string args.title Title of the notification. -- @string args.title Title of the notification.