doc: Upgrade the notification documentation to the latest standards.

This commit is contained in:
Emmanuel Lepage Vallee 2020-01-13 02:32:28 -05:00
parent ef7e4ce967
commit 207efe318a
10 changed files with 171 additions and 36 deletions

View File

@ -27,6 +27,7 @@ local action = {}
-- The action name.
-- @property name
-- @tparam string name The name.
-- @propemits true false
-- If the action is selected.
--
@ -35,14 +36,17 @@ local action = {}
--
-- @property selected
-- @param boolean
-- @propemits true false
--- The action position (index).
-- @property position
-- @param number
-- @propemits true false
--- The action icon.
-- @property icon
-- @tparam gears.surface|string icon
-- @propemits true false
--- If the action should hide the label and only display the icon.
--
@ -50,6 +54,7 @@ local action = {}
--
-- @property icon_only
-- @param[opt=false] boolean
-- @propemits true false
--- When a notification is invoked.
-- @signal invoked

View File

@ -43,6 +43,7 @@ end
--- The attached notification.
-- @property notification
-- @tparam naughty.notification notification
-- @propemits true false
function background:set_notification(notif)
if self._private.notification == notif then return end
@ -66,12 +67,16 @@ function background:set_notification(notif)
notif:connect_signal("property::border_width", self._private.background_changed_callback)
notif:connect_signal("property::border_color", self._private.background_changed_callback)
notif:connect_signal("property::shape" , self._private.background_changed_callback)
self:emit_signal("property::notification", notif)
end
--- Create a new naughty.container.background.
-- @tparam table args
-- @tparam naughty.notification args.notification The notification.
-- @constructorfct naughty.container.background
-- @usebeautiful beautiful.notification_border_width Fallback when the `border_width` property isn't set.
-- @usebeautiful beautiful.notification_border_color Fallback when the `border_color` property isn't set.
-- @usebeautiful beautiful.notification_shape Fallback when the `shape` property isn't set.
local function new(args)
args = args or {}

View File

@ -102,6 +102,8 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property suspended
-- @param boolean
-- @emits added
-- @propemits true false
--- Do not allow notifications to auto-expire.
--
@ -111,6 +113,7 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property expiration_paused
-- @param[opt=false] boolean
-- @propemits true false
--- A table with all active notifications.
--
@ -122,6 +125,7 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property active
-- @param table
-- @propemits false false
--- True when there is a handler connected to `request::display`.
-- @property has_display_handler
@ -134,6 +138,7 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property auto_reset_timeout
-- @tparam[opt=true] boolean auto_reset_timeout
-- @propemits true false
--- Enable or disable naughty ability to claim to support animations.
--
@ -143,6 +148,7 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property image_animations_enabled
-- @param[opt=false] boolean
-- @propemits true false
--- Enable or disable the persistent notifications.
--
@ -158,6 +164,7 @@ gtable.crush(naughty, require("naughty.constants"))
--
-- @property persistence_enabled
-- @param[opt=false] boolean
-- @propemits true false
local properties = {
suspended = false,
@ -625,7 +632,7 @@ local function set_index_miss(_, key, value)
resume()
end
naughty.emit_signal("property::"..key)
naughty.emit_signal("property::"..key, value)
else
rawset(naughty, key, value)
end

View File

@ -119,8 +119,10 @@ end
-- @tparam[opt="top_right"] string notification_position
--- The widget notification object.
--
-- @property notification
-- @param naughty.notification
-- @tparam naughty.notification notification
-- @propemits true false
--- The widget template to construct the box content.
--
@ -162,6 +164,8 @@ end
--
-- @property widget_template
-- @param widget
-- @usebeautiful beautiful.notification_max_width The maximum width for the
-- resulting widget.
local function generate_widget(args, n)
local w = gpcall(wibox.widget.base.make_widget_from_value,
@ -250,6 +254,8 @@ function box:set_notification(notif)
init(self, notif)
self._private.notification = notif
self:emit_signal("property::notification", notif)
end
function box:get_position()
@ -260,6 +266,18 @@ function box:get_position()
return "top_right"
end
--- Create a notification popup box.
--
-- @constructorfct naughty.layout.box
-- @tparam[opt=nil] table args
-- @tparam table args.widget_template A widget definition template which will
-- be instantiated for each box.
-- @tparam naughty.notification args.notification The notification object.
-- @tparam string args.position The position. See `naughty.notification.position`.
--@DOC_wibox_constructor_COMMON@
-- @usebeautiful beautiful.notification_position If `position` is not defined
-- in the notification object (or in this constructor).
local function new(args)
args = args or {}

View File

@ -186,23 +186,47 @@ local actionlist = {}
--- The actionlist parent notification.
-- @property notification
-- @param notification
-- @tparam naughty.notification notification
-- @propemits true false
-- @see naughty.notification
--- The actionlist layout.
-- If no layout is specified, a `wibox.layout.fixed.horizontal` will be created
-- automatically.
-- @property layout
-- @param widget
-- @property base_layout
-- @tparam widget base_layout
-- @propemits true false
-- @see wibox.layout.fixed.horizontal
--- The actionlist parent notification.
-- @property widget_template
-- @param table
-- @tparam table widget_template
-- @propemits true false
--- A table with values to override each `beautiful.notification_action` values.
-- @property style
-- @param table
-- @tparam table style
-- @propemits true false
-- @usebeautiful beautiful.font Fallback when the `font` property isn't set.
-- @usebeautiful beautiful.notification_action_underline_normal Fallback.
-- @usebeautiful beautiful.notification_action_underline_selected Fallback.
-- @usebeautiful beautiful.notification_action_icon_only Fallback.
-- @usebeautiful beautiful.notification_action_label_only Fallback.
-- @usebeautiful beautiful.notification_action_shape_normal Fallback.
-- @usebeautiful beautiful.notification_action_shape_selected Fallback.
-- @usebeautiful beautiful.notification_action_shape_border_color_normal Fallback.
-- @usebeautiful beautiful.notification_action_shape_border_color_selected Fallback.
-- @usebeautiful beautiful.notification_action_shape_border_width_normal Fallback.
-- @usebeautiful beautiful.notification_action_shape_border_width_selected Fallback.
-- @usebeautiful beautiful.notification_action_icon_size_normal Fallback.
-- @usebeautiful beautiful.notification_action_icon_size_selected Fallback.
-- @usebeautiful beautiful.notification_action_bg_normal Fallback.
-- @usebeautiful beautiful.notification_action_bg_selected Fallback.
-- @usebeautiful beautiful.notification_action_fg_normal Fallback.
-- @usebeautiful beautiful.notification_action_fg_selected Fallback.
-- @usebeautiful beautiful.notification_action_bgimage_normal Fallback.
-- @usebeautiful beautiful.notification_action_bgimage_selected Fallback.
function actionlist:set_notification(notif)
self._private.notification = notif
@ -215,6 +239,7 @@ function actionlist:set_notification(notif)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::notification", notif)
end
function actionlist:set_base_layout(layout)
@ -224,6 +249,7 @@ function actionlist:set_base_layout(layout)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::base_layout", layout)
end
function actionlist:set_widget_template(widget_template)
@ -236,6 +262,7 @@ function actionlist:set_widget_template(widget_template)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::widget_template", widget_template)
end
function actionlist:set_style(style)
@ -246,6 +273,7 @@ function actionlist:set_style(style)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::style", style)
end
function actionlist:get_notification()

View File

@ -159,23 +159,48 @@ local notificationlist = {}
--- The notificationlist parent notification.
-- @property notification
-- @param notification
-- @tparam naughty.notification notification
-- @propemits true false
-- @see naughty.notification
--- The notificationlist layout.
--- A `wibox.layout` to be used to place the entries.
--
-- If no layout is specified, a `wibox.layout.fixed.vertical` will be created
-- automatically.
-- @property layout
-- @param widget
--
-- @property base_layout
-- @tparam widget base_layout
-- @propemits true false
-- @usebeautiful beautiful.notification_spacing
-- @see wibox.layout.fixed.horizontal
-- @see wibox.layout.fixed.vertical
-- @see wibox.layout.flex.horizontal
-- @see wibox.layout.flex.vertical
-- @see wibox.layout.grid
--- The notificationlist parent notification.
-- @property widget_template
-- @param table
-- @tparam table widget_template
-- @propemits true false
--- A table with values to override each `beautiful.notification_action` values.
-- @property style
-- @param table
-- @tparam table style
-- @propemits true false
-- @usebeautiful beautiful.notification_shape_normal Fallback.
-- @usebeautiful beautiful.notification_shape_selected Fallback.
-- @usebeautiful beautiful.notification_shape_border_color_normal Fallback.
-- @usebeautiful beautiful.notification_shape_border_color_selected Fallback.
-- @usebeautiful beautiful.notification_shape_border_width_normal Fallback.
-- @usebeautiful beautiful.notification_shape_border_width_selected Fallback.
-- @usebeautiful beautiful.notification_icon_size_normal Fallback.
-- @usebeautiful beautiful.notification_icon_size_selected Fallback.
-- @usebeautiful beautiful.notification_bg_normal Fallback.
-- @usebeautiful beautiful.notification_bg_selected Fallback.
-- @usebeautiful beautiful.notification_fg_normal Fallback.
-- @usebeautiful beautiful.notification_fg_selected Fallback.
-- @usebeautiful beautiful.notification_bgimage_normal Fallback.
-- @usebeautiful beautiful.notification_bgimage_selected Fallback.
function notificationlist:set_widget_template(widget_template)
self._private.widget_template = widget_template
@ -187,6 +212,7 @@ function notificationlist:set_widget_template(widget_template)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::widget_template", widget_template)
end
function notificationlist:set_style(style)
@ -197,6 +223,7 @@ function notificationlist:set_style(style)
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::style", style)
end
function notificationlist:layout(_, width, height)
@ -213,20 +240,12 @@ function notificationlist:fit(context, width, height)
return wibox.widget.base.fit_widget(self, context, self._private.base_layout, width, height)
end
--- A `wibox.layout` to be used to place the entries.
-- @property base_layout
-- @param widget
-- @see wibox.layout.fixed.horizontal
-- @see wibox.layout.fixed.vertical
-- @see wibox.layout.flex.horizontal
-- @see wibox.layout.flex.vertical
-- @see wibox.layout.grid
--- A function to prevent some notifications from being added to the list.
-- @property filter
-- @param function
-- @tparam function filter
-- @propemits true false
for _, prop in ipairs { "filter", "client", "clients", "tag", "tags", "screen", "base_layout" } do
for _, prop in ipairs { "filter", "base_layout" } do
notificationlist["set_"..prop] = function(self, value)
self._private[prop] = value
@ -234,6 +253,7 @@ for _, prop in ipairs { "filter", "client", "clients", "tag", "tags", "screen",
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::"..prop, value)
end
notificationlist["get_"..prop] = function(self)
@ -319,9 +339,9 @@ end
module.filter = {}
---
-- @param n The notification.
-- @return Always returns true because it doesn't filter anything at all.
--- All notifications.
-- @tparam naughty.notification n The notification.
-- @treturn boolean Always returns true because it doesn't filter anything at all.
-- @filterfunction naughty.list.notifications.filter.all
function module.filter.all(n) -- luacheck: no unused args
return true
@ -333,9 +353,9 @@ end
--
-- filter = function(n) return naughty.list.notifications.filter.most_recent(n, 3) end
--
-- @param n The notification.
-- @tparam naughty.notification n The notification.
-- @tparam[opt=1] number count The number of recent notifications to allow.
-- @return Always returns true because it doesn't filter anything at all.
-- @treturn boolean Always returns true because it doesn't filter anything at all.
-- @filterfunction naughty.list.notifications.filter.most_recent
function module.filter.most_recent(n, count)
for i=1, count or 1 do

View File

@ -75,7 +75,8 @@ local notification = {}
-- This is the equivalent to a PID as allows external applications to select
-- notifications.
-- @property id
-- @param number
-- @tparam number id
-- @propemits true false
--- Text of the notification.
--
@ -89,12 +90,14 @@ local notification = {}
--- Title of the notification.
--@DOC_naughty_helloworld_EXAMPLE@
-- @property title
-- @param string
-- @tparam string title
-- @propemits true false
--- Time in seconds after which popup expires.
-- Set 0 for no timeout.
-- @property timeout
-- @param number
-- @tparam number timeout
-- @propemits true false
--- The notification urgency level.
--
@ -106,6 +109,7 @@ local notification = {}
--
-- @property urgency
-- @param string
-- @propemits true false
--- The notification category.
--
@ -152,6 +156,7 @@ local notification = {}
--
-- @property category
-- @tparam string|nil category
-- @propemits true false
--- True if the notification should be kept when an action is pressed.
--
@ -161,14 +166,17 @@ local notification = {}
--
-- @property resident
-- @param[opt=false] boolean
-- @propemits true false
--- Delay in seconds after which hovered popup disappears.
-- @property hover_timeout
-- @param number
-- @propemits true false
--- Target screen for the notification.
-- @property screen
-- @param screen
-- @propemits true false
--- Corner of the workarea displaying the popups.
--
@ -186,6 +194,7 @@ local notification = {}
--
-- @property position
-- @param string
-- @propemits true false
-- @see awful.placement.next_to
--- Boolean forcing popups to display on top.
@ -198,17 +207,20 @@ local notification = {}
--
-- @property height
-- @param number
-- @propemits true false
-- @see width
--- Popup width.
-- @property width
-- @param number
-- @propemits true false
-- @see height
--- Notification font.
--@DOC_naughty_colors_EXAMPLE@
-- @property font
-- @param string
-- @propemits true false
--- "All in one" way to access the default image or icon.
--
@ -228,12 +240,14 @@ local notification = {}
--
-- @property icon
-- @tparam string|surface icon
-- @propemits true false
-- @see app_icon
-- @see image
--- Desired icon size in px.
-- @property icon_size
-- @param number
-- @propemits true false
--- The icon provided in the `app_icon` field of the DBus notification.
--
@ -242,6 +256,7 @@ local notification = {}
--
-- @property app_icon
-- @param string
-- @propemits true false
--- The notification image.
--
@ -251,6 +266,7 @@ local notification = {}
--
-- @property image
-- @tparam string|surface image
-- @propemits true false
--- The notification (animated) images.
--
@ -262,6 +278,7 @@ local notification = {}
--
-- @property images
-- @tparam nil|table images
-- @propemits true false
--- Foreground color.
--
@ -269,6 +286,7 @@ local notification = {}
--
-- @property fg
-- @tparam string|color|pattern fg
-- @propemits true false
-- @see title
-- @see gears.color
@ -278,13 +296,14 @@ local notification = {}
--
-- @property bg
-- @tparam string|color|pattern bg
-- @propemits true false
-- @see title
-- @see gears.color
--- Border width.
-- @property border_width
-- @param number
-- @see title
-- @propemits true false
--- Border color.
--
@ -292,7 +311,7 @@ local notification = {}
--
-- @property border_color
-- @param string
-- @see title
-- @propemits true false
-- @see gears.color
--- Widget shape.
@ -311,10 +330,12 @@ local notification = {}
--
-- @property shape
-- @tparam gears.shape shape
-- @propemits true false
--- Widget opacity.
-- @property opacity
-- @tparam number opacity Between 0 to 1.
-- @propemits true false
--- Widget margin.
--
@ -322,6 +343,7 @@ local notification = {}
--
-- @property margin
-- @tparam number|table margin
-- @propemits true false
-- @see shape
--- Function to run on left click.
@ -345,12 +367,14 @@ local notification = {}
-- in the preset.
-- @property preset
-- @param table
-- @propemits true false
--- Function that will be called with all arguments.
-- The notification will only be displayed if the function returns true.
-- Note: this function is only relevant to notifications sent via dbus.
-- @property callback
-- @param function
-- @propemits true false
--- A table containing strings that represents actions to buttons.
--
@ -358,6 +382,7 @@ local notification = {}
--
-- @property actions
-- @param table
-- @propemits true false
--- Ignore this notification, do not display.
--
@ -366,16 +391,19 @@ local notification = {}
--
-- @property ignore
-- @param boolean
-- @propemits true false
--- Tell if the notification is currently suspended (read only).
--
-- This is always equal to `naughty.suspended`
--@property suspended
--@param boolean
-- @propemits true false
--- If the notification is expired.
-- @property is_expired
-- @param boolean
-- @propemits true false
-- @see naughty.expiration_paused
--- If the timeout needs to be reset when a property changes.
@ -385,6 +413,7 @@ local notification = {}
--
-- @property auto_reset_timeout
-- @tparam[opt=true] boolean auto_reset_timeout
-- @propemits true false
--- Emitted when the notification is destroyed.
-- @signal destroyed
@ -415,6 +444,7 @@ local notification = {}
--
-- @property[opt=500] max_width
-- @param number
-- @propemits true false
--- The application name specified by the notification.
--
@ -423,6 +453,7 @@ local notification = {}
-- In these case, it helps to triage and detect the notification from the rules.
-- @property app_name
-- @param string
-- @propemits true false
--- The widget template used to represent the notification.
--
@ -431,13 +462,18 @@ local notification = {}
--
-- @property widget_template
-- @param table
-- @propemits true false
--- Destroy notification by notification object.
--
-- @method destroy
-- @tparam string reason One of the reasons from `notification_closed_reason`
-- @tparam[opt=false] boolean keep_visible If true, keep the notification visible
-- @return True if the popup was successfully destroyed, false otherwise
-- @treturn boolean True if the popup was successfully destroyed, false otherwise.
-- @emits destroyed
-- @emitstparam destroyed integer reason The reason.
-- @emitstparam destroyed boolean keep_visible If the notification should be kept.
-- @see naughty.notification_closed_reason
function notification:destroy(reason, keep_visible)
if self._private.is_destroyed then
gdebug.print_warning("Trying to destroy the same notification twice. It"..
@ -522,6 +558,7 @@ function notification:set_timeout(timeout)
end
self.die = die
self._private.timeout = timeout
self:emit_signal("property::timeout", timeout)
end
function notification:set_text(txt)

View File

@ -77,6 +77,7 @@ end
--- The attached notification.
-- @property notification
-- @tparam naughty.notification notification
-- @propemits true false
function icon:set_notification(notif)
if self._private.notification == notif then return end
@ -95,6 +96,7 @@ function icon:set_notification(notif)
self._private.notification = notif
notif:connect_signal("property::icon", self._private.icon_changed_callback)
self:emit_signal("property::notification", notif)
end
local valid_strategies = {
@ -117,7 +119,11 @@ local valid_strategies = {
--@DOC_wibox_nwidget_icon_strategy_EXAMPLE@
--
-- @property resize_strategy
-- @param string
-- @tparam string resize_strategy
-- @propemits true false
-- @usebeautiful beautiful.notification_icon_resize_strategy The fallback when
-- there is no specified strategy.
-- @usebeautiful beautiful.notification_icon_size The size upper bound.
function icon:set_resize_strategy(strategy)
assert(valid_strategies[strategy], "Invalid strategy")
@ -125,6 +131,7 @@ function icon:set_resize_strategy(strategy)
self._private.resize_strategy = strategy
self:emit_signal("widget::redraw_needed")
self:emit_signal("property::resize_strategy", strategy)
end

View File

@ -36,6 +36,7 @@ end
--- The attached notification.
-- @property notification
-- @tparam naughty.notification notification
-- @propemits true false
function message:set_notification(notif)
if self._private.notification == notif then return end
@ -53,12 +54,15 @@ function message:set_notification(notif)
notif:connect_signal("property::message", self._private.message_changed_callback)
notif:connect_signal("property::fg" , self._private.message_changed_callback)
self:emit_signal("property::notification", notif)
end
--- Create a new naughty.widget.message.
-- @tparam table args
-- @tparam naughty.notification args.notification The notification.
-- @constructorfct naughty.widget.message
-- @usebeautiful beautiful.notification_fg
-- @usebeautiful beautiful.notification_font
local function new(args)
args = args or {}

View File

@ -36,6 +36,7 @@ end
--- The attached notification.
-- @property notification
-- @tparam naughty.notification notification
-- @propemits true false
function title:set_notification(notif)
if self._private.notification == notif then return end
@ -54,12 +55,15 @@ function title:set_notification(notif)
notif:connect_signal("property::title", self._private.title_changed_callback)
notif:connect_signal("property::fg" , self._private.title_changed_callback)
self:emit_signal("property::notification", notif)
end
--- Create a new naughty.widget.title.
-- @tparam table args
-- @tparam naughty.notification args.notification The notification.
-- @constructorfct naughty.widget.title
-- @usebeautiful beautiful.notification_fg
-- @usebeautiful beautiful.notification_font
local function new(args)
args = args or {}