Skip to content

Commit 4cf7388

Browse files
committed
docs(mqtt): fix some doc comments
1 parent d712269 commit 4cf7388

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

mqtt/init.lua

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
--- MQTT module
22
-- @module mqtt
3+
-- @usage
4+
-- local client = mqtt.client {
5+
-- uri = "mqtts://aladdin:[email protected]",
6+
-- clean = true,
7+
-- version = mqtt.v50, -- specify constant for MQTT version
8+
-- }
39

410
--[[
511
MQTT protocol DOC: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html
@@ -18,13 +24,6 @@ CONVENTIONS:
1824
-- @tfield number v50 MQTT v5.0 protocol version constant
1925
-- @tfield string _VERSION luamqtt library version string
2026
-- @table mqtt
21-
-- @see mqtt.const
22-
-- @usage
23-
-- local client = mqtt.client {
24-
-- uri = "mqtts://aladdin:[email protected]",
25-
-- clean = true,
26-
-- version = mqtt.v50, -- specify constant for MQTT version
27-
-- }
2827
local mqtt = {}
2928

3029
-- copy all values from const module
@@ -47,6 +46,7 @@ local ioloop_get = ioloop.get
4746

4847
--- Create new MQTT client instance
4948
-- @param ... Same as for `Client.create`(...)
49+
-- @treturn Client new client instance
5050
-- @see Client:__init
5151
function mqtt.client(...)
5252
return client_create(...)
@@ -76,8 +76,10 @@ end
7676

7777

7878
--- Validates a topic with wildcards.
79-
-- @param t (string) wildcard topic to validate
80-
-- @return topic, or false+error
79+
-- @tparam string t wildcard-topic to validate
80+
-- @treturn[1] string the input topic if valid
81+
-- @treturn[2] boolean false if invalid
82+
-- @treturn[2] string error description
8183
-- @usage local t = assert(mqtt.validate_subscribe_topic("base/+/thermostat/#"))
8284
function mqtt.validate_subscribe_topic(t)
8385
if type(t) ~= "string" then
@@ -114,8 +116,10 @@ function mqtt.validate_subscribe_topic(t)
114116
end
115117

116118
--- Validates a topic without wildcards.
117-
-- @param t (string) topic to validate
118-
-- @return topic, or false+error
119+
-- @tparam string t topic to validate
120+
-- @treturn[1] string the input topic if valid
121+
-- @treturn[2] boolean false if invalid
122+
-- @treturn[2] string error description
119123
-- @usage local t = assert(mqtt.validate_publish_topic("base/living/thermostat/setpoint"))
120124
function mqtt.validate_publish_topic(t)
121125
if type(t) ~= "string" then
@@ -133,8 +137,10 @@ end
133137
--- Returns a Lua pattern from topic.
134138
-- Takes a wildcarded-topic and returns a Lua pattern that can be used
135139
-- to validate if a received topic matches the wildcard-topic
136-
-- @param t (string) the wildcard topic
137-
-- @return Lua-pattern (string) or false+err
140+
-- @tparam string t the wildcard topic
141+
-- @treturn[1] string Lua-pattern that matches the topic and returns the captures
142+
-- @treturn[2] boolean false if the topic was invalid
143+
-- @treturn[2] string error description
138144
-- @usage
139145
-- local patt = compile_topic_pattern("homes/+/+/#")
140146
--
@@ -171,7 +177,7 @@ function mqtt.compile_topic_pattern(t)
171177
end
172178

173179
--- Parses wildcards in a topic into a table.
174-
-- @tparam topic string incoming topic string
180+
-- @tparam string topic incoming topic string
175181
-- @tparam table opts parsing options table
176182
-- @tparam string opts.topic the wild-carded topic to match against (optional if `opts.pattern` is given)
177183
-- @tparam string opts.pattern the compiled pattern for the wild-carded topic (optional if `opts.topic`

0 commit comments

Comments
 (0)