refactor(types): extract inline anonymous types into named classes (#110)
Problem: several functions used inline `{...}` table types in their
`@param` and `@return` annotations, making them hard to read and
impossible to reference from other modules.
Solution: extract each into a named `---@class`: `pending.Metadata`,
`pending.TaskFields`, `pending.CompletionItem`, `pending.SystemResult`,
and `pending.OAuthClientOpts`.
This commit is contained in:
parent
b06249f101
commit
ac02526cf1
5 changed files with 123 additions and 45 deletions
|
|
@ -1,5 +1,12 @@
|
|||
local config = require('pending.config')
|
||||
|
||||
---@class pending.Metadata
|
||||
---@field due? string
|
||||
---@field cat? string
|
||||
---@field rec? string
|
||||
---@field rec_mode? 'scheduled'|'completion'
|
||||
---@field priority? integer
|
||||
|
||||
---@class pending.parse
|
||||
local M = {}
|
||||
|
||||
|
|
@ -515,7 +522,7 @@ end
|
|||
|
||||
---@param text string
|
||||
---@return string description
|
||||
---@return { due?: string, cat?: string, rec?: string, rec_mode?: 'scheduled'|'completion' } metadata
|
||||
---@return pending.Metadata metadata
|
||||
function M.body(text)
|
||||
local tokens = {}
|
||||
for token in text:gmatch('%S+') do
|
||||
|
|
@ -608,7 +615,7 @@ end
|
|||
|
||||
---@param text string
|
||||
---@return string description
|
||||
---@return { due?: string, cat?: string, rec?: string, rec_mode?: 'scheduled'|'completion' } metadata
|
||||
---@return pending.Metadata metadata
|
||||
function M.command_add(text)
|
||||
local cat_prefix = text:match('^(%S.-):%s')
|
||||
if cat_prefix then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue