doc: Force all properties to document their default value.

This commit is contained in:
Emmanuel Lepage Vallee 2022-07-10 00:29:33 -07:00
parent 86d1b1c22c
commit 4fa957b75d
8 changed files with 52 additions and 21 deletions

View File

@ -234,6 +234,37 @@ create_type {
" doesn't match the property name. For linting purpose, please fix this." " doesn't match the property name. For linting purpose, please fix this."
) )
end end
-- Properties should have a default value. If they don't or if the
-- default depends on the context, then `opt=nil` should be used to
-- mute this warning.
if not item:default_of_param(item.params[1]) then
local auto_opt = nil
-- Extract the default value from other metadata.
if item.tags["propbeautiful"] and item.tags["propbeautiful"][1] then
auto_opt = "beautiful."..(item.module.name.."_"..item.name):gsub("[.]", "_")
elseif item.tags["usebeautiful"] and item.tags["usebeautiful"][1] then
auto_opt = item.tags["usebeautiful"][1]:match("[^ ]+")
end
-- This adds a default value. It works for LDoc 1.4.5, but is a
-- private API and might break in the future.
if auto_opt then
local mods = item.modifiers[item.parameter]
if mods then
mods[item.params[1]].opt = auto_opt
end
else
-- The default could not be determined automatically, it requires
-- an explicit `opt=<value>`.
print(
"WARNING: Property", item.name .." from "..item.module.name --,
--"doesn't have a default value. Add `[opt=value]` to the @tparam"
)
end
end
end end
} }

View File

@ -304,7 +304,7 @@ end
-- * `nil`: Unset the image. -- * `nil`: Unset the image.
-- --
-- @property image -- @property image
-- @tparam image image The image to render. -- @tparam[opt=nil] image image The image to render.
-- @propemits false false -- @propemits false false
--- Set the `imagebox` image. --- Set the `imagebox` image.
@ -370,7 +370,7 @@ end
-- @DOC_wibox_widget_imagebox_clip_shape_EXAMPLE@ -- @DOC_wibox_widget_imagebox_clip_shape_EXAMPLE@
-- --
-- @property clip_shape -- @property clip_shape
-- @tparam function|gears.shape clip_shape A `gears.shape` compatible shape function. -- @tparam[opt=nil] function|gears.shape clip_shape A `gears.shape` compatible shape function.
-- @propemits true false -- @propemits true false
-- @see gears.shape -- @see gears.shape
@ -402,7 +402,7 @@ end
-- @DOC_wibox_widget_imagebox_resize_EXAMPLE@ -- @DOC_wibox_widget_imagebox_resize_EXAMPLE@
-- @property resize -- @property resize
-- @propemits true false -- @propemits true false
-- @tparam boolean resize -- @tparam[opt=true] boolean resize
--- Allow the image to be upscaled (made bigger). --- Allow the image to be upscaled (made bigger).
-- --
@ -412,7 +412,7 @@ end
-- --
-- @DOC_wibox_widget_imagebox_upscale_EXAMPLE@ -- @DOC_wibox_widget_imagebox_upscale_EXAMPLE@
-- @property upscale -- @property upscale
-- @tparam boolean upscale -- @tparam[opt=self.resize] boolean upscale
-- @see downscale -- @see downscale
-- @see resize -- @see resize
@ -424,7 +424,7 @@ end
-- --
-- @DOC_wibox_widget_imagebox_downscale_EXAMPLE@ -- @DOC_wibox_widget_imagebox_downscale_EXAMPLE@
-- @property downscale -- @property downscale
-- @tparam boolean downscale -- @tparam[opt=self.resize] boolean downscale
-- @see upscale -- @see upscale
-- @see resize -- @see resize
@ -439,7 +439,7 @@ end
--@DOC_wibox_widget_imagebox_stylesheet_EXAMPLE@ --@DOC_wibox_widget_imagebox_stylesheet_EXAMPLE@
-- --
-- @property stylesheet -- @property stylesheet
-- @tparam string stylesheet -- @tparam[opt=""] string stylesheet
-- @propemits true false -- @propemits true false
--- Set the SVG DPI (dot per inch). --- Set the SVG DPI (dot per inch).
@ -455,7 +455,7 @@ end
--@DOC_wibox_widget_imagebox_dpi_EXAMPLE@ --@DOC_wibox_widget_imagebox_dpi_EXAMPLE@
-- --
-- @property dpi -- @property dpi
-- @tparam number|table dpi -- @tparam[opt=96] number|table dpi
-- @propemits true false -- @propemits true false
-- @see auto_dpi -- @see auto_dpi
@ -597,7 +597,7 @@ end
-- @DOC_wibox_widget_imagebox_max_scaling_factor_EXAMPLE@ -- @DOC_wibox_widget_imagebox_max_scaling_factor_EXAMPLE@
-- --
-- @property max_scaling_factor -- @property max_scaling_factor
-- @tparam number max_scaling_factor -- @tparam[opt=0] number max_scaling_factor Use `0` for "no limit".
-- @propemits true false -- @propemits true false
-- @see valign -- @see valign
-- @see halign -- @see halign
@ -629,7 +629,7 @@ end
-- @DOC_wibox_widget_imagebox_scaling_quality_EXAMPLE@ -- @DOC_wibox_widget_imagebox_scaling_quality_EXAMPLE@
-- --
-- @property scaling_quality -- @property scaling_quality
-- @tparam string scaling_quality Either `"fast"`, `"good"`, `"best"`, -- @tparam[op="fast"] string scaling_quality Either `"fast"`, `"good"`, `"best"`,
-- `"nearest"` or `"bilinear"`. -- `"nearest"` or `"bilinear"`.
-- @propemits true false -- @propemits true false
-- @see resize -- @see resize

View File

@ -140,7 +140,7 @@ end
--- The pie chart data list. --- The pie chart data list.
-- --
-- @property data_list -- @property data_list
-- @tparam table data_list Sorted table where each entry has a label as its -- @tparam[opt={}] table data_list Sorted table where each entry has a label as its
-- first value and a number as its second value. -- first value and a number as its second value.
-- @propemits false false -- @propemits false false

View File

@ -519,7 +519,7 @@ end
-- @DOC_wibox_widget_progressbar_value_EXAMPLE@ -- @DOC_wibox_widget_progressbar_value_EXAMPLE@
-- --
-- @property value -- @property value
-- @tparam number value The progress bar value. -- @tparam[opt=0] number value The progress bar value.
-- @propemits true false -- @propemits true false
-- @see max_value -- @see max_value

View File

@ -43,7 +43,7 @@ local separator = {}
--@DOC_wibox_widget_separator_orientation_EXAMPLE@ --@DOC_wibox_widget_separator_orientation_EXAMPLE@
-- --
-- @property orientation -- @property orientation
-- @tparam string orientation -- @tparam[opt="auto"] string orientation
-- @propemits true false -- @propemits true false
--- The separator's thickness. --- The separator's thickness.

View File

@ -148,7 +148,7 @@ end
-- available space. Otherwise, any single icon has a size of `size`x`size`. -- available space. Otherwise, any single icon has a size of `size`x`size`.
-- --
-- @property base_size -- @property base_size
-- @tparam integer|nil base_size The base size -- @tparam[opt=nil] integer|nil base_size The base size
-- @propemits true false -- @propemits true false
function systray:set_base_size(size) function systray:set_base_size(size)
@ -162,7 +162,7 @@ end
--- Decide between horizontal or vertical display. --- Decide between horizontal or vertical display.
-- --
-- @property horizontal -- @property horizontal
-- @tparam boolean horizontal Use horizontal mode? -- @tparam[opt=true] boolean horizontal Use horizontal mode?
-- @propemits true false -- @propemits true false
function systray:set_horizontal(horiz) function systray:set_horizontal(horiz)
@ -176,7 +176,7 @@ end
--- Should the systray icons be displayed in reverse order? --- Should the systray icons be displayed in reverse order?
-- --
-- @property reverse -- @property reverse
-- @tparam boolean reverse Display in reverse order. -- @tparam[opt=false] boolean reverse Display in reverse order.
-- @propemits true false -- @propemits true false
function systray:set_reverse(rev) function systray:set_reverse(rev)
@ -194,7 +194,7 @@ end
-- visible on the primary screen. The default value is "primary". -- visible on the primary screen. The default value is "primary".
-- --
-- @property screen -- @property screen
-- @tparam screen|"primary" screen The screen to display on. -- @tparam[opt=nil] screen|"primary" screen The screen to display on.
-- @propemits true false -- @propemits true false
function systray:set_screen(s) function systray:set_screen(s)

View File

@ -189,7 +189,7 @@ end
-- @DOC_wibox_widget_textbox_markup2_EXAMPLE@ -- @DOC_wibox_widget_textbox_markup2_EXAMPLE@
-- --
-- @property markup -- @property markup
-- @tparam string markup The text to set. This can contain pango markup (e.g. -- @tparam[opt=self.text] string markup The text to set. This can contain pango markup (e.g.
-- `<b>bold</b>`). You can use `gears.string.escape` to escape -- `<b>bold</b>`). You can use `gears.string.escape` to escape
-- parts of it. -- parts of it.
-- @propemits true false -- @propemits true false
@ -217,7 +217,7 @@ end
-- @DOC_wibox_widget_textbox_text2_EXAMPLE@ -- @DOC_wibox_widget_textbox_text2_EXAMPLE@
-- --
-- @property text -- @property text
-- @tparam string text The text to display. Pango markup is ignored and shown -- @tparam[opt=""] string text The text to display. Pango markup is ignored and shown
-- as-is. -- as-is.
-- @propemits true false -- @propemits true false
-- @see markup -- @see markup

View File

@ -70,7 +70,7 @@ end
-- For information about the format specifiers, see -- For information about the format specifiers, see
-- [the GLib docs](https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format). -- [the GLib docs](https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format).
-- @property format -- @property format
-- @tparam string format The new time format. This can contain pango markup. -- @tparam[opt=" %a %b %d %H:%M"] string format The new time format. This can contain pango markup.
function textclock:set_format(format) function textclock:set_format(format)
self._private.format = format self._private.format = format
@ -86,7 +86,7 @@ end
-- e.g. "Z" for UTC, "±hh:mm" or "Europe/Amsterdam". See -- e.g. "Z" for UTC, "±hh:mm" or "Europe/Amsterdam". See
-- [GTimeZone](https://developer.gnome.org/glib/stable/glib-GTimeZone.html#g-time-zone-new). -- [GTimeZone](https://developer.gnome.org/glib/stable/glib-GTimeZone.html#g-time-zone-new).
-- @property timezone -- @property timezone
-- @tparam string timezone -- @tparam[opt=TimeZone.new()] string timezone
function textclock:set_timezone(tzid) function textclock:set_timezone(tzid)
self._private.tzid = tzid self._private.tzid = tzid
@ -101,7 +101,7 @@ end
--- Set the clock's refresh rate. --- Set the clock's refresh rate.
-- --
-- @property refresh -- @property refresh
-- @tparam number refresh How often the clock is updated, in seconds -- @tparam[opt=60] number refresh How often the clock is updated, in seconds
function textclock:set_refresh(refresh) function textclock:set_refresh(refresh)
self._private.refresh = refresh or self._private.refresh self._private.refresh = refresh or self._private.refresh