Vous avez re莽u un message "Your GitLab account has been locked ..." ? Pas d'inqui茅tude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 8ec8c477 authored by Alexis Brenon's avatar Alexis Brenon
Browse files

馃毀馃摑 Complete documentation

parent 84238873
--- Continuous sensors SVG placeholder.
--
-- These placeholders will contain a dynamic icon to represent
-- the value of a continuous sensor.
-- Relevant sensors are lamp, thermometer, etc.
--
-- @classmod utils.placeholder.ContinuousIconPlaceHolder
-- @alias class
-- @inherit true
-- @see utils.placeholder.IconPlaceHolder
-- @author Alexis BRENON <brenon.alexis+arcades@gmail.com>
local torch = require('torch')
local min = math.min
......@@ -8,6 +20,15 @@ assert(placeholder.IconPlaceHolder)
local module = {}
local class, super = torch.class('ContinuousIconPlaceHolder', 'IconPlaceHolder', module)
--- Maximum value of the sensor.
-- @tfield number self.max_value
--- Minimum value of the sensor.
-- @tfield number self.min_value
--- Constructor.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element} to parse
-- @tparam table spec PlaceHolder's specification extracted from SVG聽description
function class:__init(element, spec)
super.__init(self, element, spec)
self.max_value = spec.max
......@@ -20,6 +41,14 @@ function class:__init(element, spec)
}
end
--- Private Methods
-- @section private-methods
--- Initialize @{PlaceHolder.string|string} and @{PlaceHolder.placed_values|placed_values}
-- from given @{penlight/libraries/pl.xml.html/|XML element}.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element}
-- @override true
-- @see PlaceHolder._prepare_string
function class:_prepare_string(element)
self.string = "<svg:g"
self.string = self.string .. self.dump_attribs(element, {style=true})
......@@ -51,8 +80,15 @@ function class:_prepare_string(element)
self.string = self.string .. "</svg:g>"
end
--- Public Methods
-- @section public-methods
--- Change current value of the @{ContinuousIconPlaceHolder|placeholder}.
-- @tparam number value New value to apply
-- @treturn ContinuousIconPlaceHolder `self`
-- @treturn boolean Is the value modified
-- @override true
-- @see PlaceHolder:set_value
function class:set_value(value)
value = value and max(min(value, self.max_value), self.min_value) or value
local change_value = (value ~= self.value)
......@@ -82,6 +118,12 @@ function class:set_value(value)
return self, change_value
end
--- Get a random value from the @{ContinuousIconPlaceHolder|placeholder}.
--
-- The value is sampled from the range `[``self.min_value``,``self.max_value``]`.
-- @treturn number A value in the range `[``self.min_value``,``self.max_value``]`
-- @override true
-- @see PlaceHolder:get_random_value
function class:get_random_value()
return torch.random(self.min_value, self.max_value)
end
......
--- Discrete sensors SVG placeholder.
--
-- These placeholders will contain a dynamic icon to represent
-- the value of a discrete sensor.
-- Relevant sensors are blinds, door switches, etc.
--
-- @classmod utils.placeholder.DiscreteIconPlaceHolder
-- @alias class
-- @inherit true
-- @see utils.placeholder.IconPlaceHolder
-- @author Alexis BRENON <brenon.alexis+arcades@gmail.com>
local torch = require('torch')
local placeholder = require('arcades.utils.placeholder')
......@@ -5,6 +17,9 @@ assert(placeholder.IconPlaceHolder)
local module = {}
local class, super = torch.class('DiscreteIconPlaceHolder', 'IconPlaceHolder', module)
--- Constructor.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element} to parse
-- @tparam table spec PlaceHolder's specification extracted from SVG聽description
function class:__init(element, spec)
super.__init(self, element, spec)
......@@ -14,6 +29,14 @@ function class:__init(element, spec)
}
end
--- Private Methods
-- @section private-methods
--- Initialize @{PlaceHolder.string|string} and @{PlaceHolder.placed_values|placed_values}
-- from given @{penlight/libraries/pl.xml.html/|XML element}.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element}
-- @override true
-- @see PlaceHolder._prepare_string
function class:_prepare_string(element)
self.string = "<svg:g"
self.string = self.string .. self.dump_attribs(element, {style=true})
......@@ -43,8 +66,15 @@ function class:_prepare_string(element)
self.string = self.string .. "</svg:g>"
end
--- Public Methods
-- @section public-methods
--- Change current value of the @{DiscreteIconPlaceHolder|placeholder}.
-- @tparam number value New value to apply
-- @treturn DiscreteIconPlaceHolder `self`
-- @treturn boolean Is the value modified
-- @override true
-- @see PlaceHolder:set_value
function class:set_value(value)
local change_value = (value ~= self.value)
if change_value then
......@@ -63,6 +93,13 @@ function class:set_value(value)
end
-- luacheck: push no self
--- Get a random value from the @{DiscreteIconPlaceHolder|placeholder}.
--
-- The value is `0` or `1`.
-- @treturn int `0` or `1`
-- @override true
-- @see PlaceHolder:get_random_value
function class:get_random_value()
return torch.random(0, 1)
end
......
--- SVG icon placeholder base class.
--
-- These placeholders will contain a dynamic icon to represent
-- a sensor value. Relevant sensors are door switches, lamp,
-- blinds, etc.
--
-- @classmod utils.placeholder.IconPlaceHolder
-- @alias class
-- @inherit true
-- @see utils.placeholder.PlaceHolder
-- @author Alexis BRENON <brenon.alexis+arcades@gmail.com>
local torch = require('torch')
local placeholder = require('arcades.utils.placeholder')
......
--- Factory to build @{IconPlaceHolder|IconPlaceHolders}.
--
-- @classmod utils.placeholder.IconPlaceHolderFactory
-- @alias class
-- @author Alexis BRENON <brenon.alexis+arcades@gmail.com>
local torch = require('torch')
local utils = require('arcades.utils.utils')
......@@ -6,6 +12,15 @@ local placeholder = require('arcades.utils.placeholder')
local module = {}
local class, _ = torch.class('IconPlaceHolderFactory', module)
--- Static Functions
-- @section static-functions
--- Build an `IconPlaceHolder` from a given SVG element.
--
-- If no `IconPlaceHolder` can be built this function returns `nil`.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element} to parse
-- @treturn[1] IconPlaceHolder A sub-class of `IconPlaceHolder`
-- @return[2] `nil` if no `IconPlaceHolder` can be built
function class.get_PlaceHolder(element)
-- Check that element has a description
local description = element:child_with_name("svg:desc")
......
......@@ -32,7 +32,7 @@ local class, _ = torch.class('PlaceHolder', module)
--- Placeholder constructor.
--
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element} to parse
-- @param spec TODO see child classes
-- @tparam table spec PlaceHolder's specification extracted from SVG聽description
function class:__init(element, spec)
self.sensor_id = spec.sensor_id
self.value = nil
......
--- Factory to build @{PlaceHolder|PlaceHolders}.
--
-- @classmod utils.placeholder.PlaceHolderFactory
-- @alias class
-- @author Alexis BRENON <brenon.alexis+arcades@gmail.com>
local torch = require('torch')
local utils = require('arcades.utils.utils')
......@@ -6,6 +12,15 @@ local placeholder = require('arcades.utils.placeholder')
local module = {}
local class, _ = torch.class('PlaceHolderFactory', module)
--- Static Functions
-- @section static-functions
--- Build a `PlaceHolder` from a given SVG element.
--
-- If no `PlaceHolder` can be built this function returns `nil`.
-- @tparam Doc element @{penlight/libraries/pl.xml.html/|XML element} to parse
-- @treturn[1] PlaceHolder A sub-class of `PlaceHolder`
-- @return[2] `nil` if no `PlaceHolder` can be built
function class.get_PlaceHolder(element)
-- Check that element has a description
local description = element:child_with_name("svg:desc")
......
......@@ -37,6 +37,7 @@
# level_index[i] = level_index[i] + 1
# for j = i+1, #level_index do level_index[j] = 0 end
# current_hierarchy[level_index[i]] = {
# super = current_hierarchy,
# label = hierarchy_name,
# subs = {},
# }
......@@ -344,7 +345,7 @@
</div> <!-- Module include -->
# end
# if module.see then
# if module.see and not module.tags.inherit then
<!-- Module sees -->
<div class="card-body">
<strong class="card-title">See also:</strong>
......@@ -388,6 +389,15 @@
<div class="module-presentation">
<p class="module-summary">$(M(module.summary,module))</p>
# if module.tags.inherit then
<div class="module-inheritance">
<p class="mb-1"><strong>Inherits from:</strong></p>
<ul>
# for inherit in iter(module.see) do
<li><a href="$(escape(ldoc.href(inherit)))">$(inherit.mod.mod_name)</a></li>
# end
</ul>
# end
<p class="module-description">$(M(module.description,module))</p>
</div>
</div> <!-- Name and summary -->
......@@ -538,6 +548,15 @@
$(M(ldoc.descript(item),item))
</p>
# if item.tags.override then
<div class="override">
<p>
<strong>Overrides:</strong>
<a href="$(escape(ldoc.href(item.see[1])))">$(escape(item.see[1].label))</a>
</p>
</div>
# end
# if ldoc.custom_tags then
# for custom in iter(ldoc.custom_tags) do
# local tag = item.tags[custom[1]]
......@@ -664,7 +683,7 @@
$(M(item.raise,item))
# end
# if item.see then
# if item.see and not item.tags.override then
<strong>See also:</strong>
<ul>
# for see in iter(item.see) do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment