Skip to content

Commit

Permalink
Update todo script and remove some todos
Browse files Browse the repository at this point in the history
  • Loading branch information
euclidianAce committed Jul 9, 2024
1 parent e16a6e7 commit bef8375
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 39 deletions.
5 changes: 0 additions & 5 deletions build/cyan/config.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions build/cyan/experimental/decoration.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion build/cyan/script.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 23 additions & 21 deletions scripts/todos.tl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local argparse <const> = require("argparse")
local log <const> = require("cyan.log")
local fs <const> = require("cyan.fs")
local cs <const> = require("cyan.colorstring")
local decoration <const> = require("cyan.experimental.decoration")
local util <const> = require("cyan.util")
local pad_left <const>, map <const> = util.str.pad_left, util.tab.map
local pad_left <const>, ivalues <const> = util.str.pad_left, util.tab.ivalues

local has_ltreesitter <const>, ts <const> = pcall(require, "ltreesitter")
if not has_ltreesitter then
Expand All @@ -22,21 +22,18 @@ parser:flag("--raw", "Output in a raw format useful for piping into other comman
local parsed <const> = parser:parse()
local raw <const> = parsed.raw as boolean

local query <const> = teal_parser:query[[
((comment) @c
(match? @c "TODO"))]]
local query <const> = teal_parser:query[[ ((comment) @c (#match? @c "TODO")) ]]

local todo <const> = log.create_logger(
io.stderr,
"normal",
cs.highlight(cs.colors.teal, "Todo"),
cs.highlight(cs.colors.teal, "...")
local todo <const> = log.err:copy(
decoration.decorate("Todo", decoration.scheme.teal),
decoration.decorate("...", decoration.scheme.teal)
)

local record Todo
line: integer
content: string
end
local total = 0
for path in fs.scan_dir(".", {"src/cyan/**/*"}) do
local real_path <const> = path:to_real_path()
local text <const> = fs.read(real_path)
Expand All @@ -46,7 +43,7 @@ for path in fs.scan_dir(".", {"src/cyan/**/*"}) do
local node <const> = match.captures.c as ts.Node
assert(node is ts.Node)
table.insert(todos, {
line = node:start_point().row,
line = node:start_point().row + 1,
content = node:source():match("TODO%s*:?%s*(.*)"),
})
end
Expand All @@ -57,17 +54,22 @@ for path in fs.scan_dir(".", {"src/cyan/**/*"}) do
end
else
todo(
cs.highlight(cs.colors.emphasis, #todos .. " todo comment" .. (#todos == 1 and "" or "s")), " in ",
cs.highlight(cs.colors.file, real_path),
"\n ",
table.concat(map(todos, function(t: Todo): string
return (
cs.highlight(cs.colors.number, pad_left(tostring(t.line), 4)) .. " | "
.. t.content
):tostring()
end), "\n "),
"\n"
decoration.decorate(#todos .. " todo comment" .. (#todos == 1 and "" or "s"), decoration.scheme.emphasis),
" in ",
decoration.file_name(real_path)
)
for t in ivalues(todos) do
todo:cont(
" ",
decoration.decorate(pad_left(tostring(t.line), 4)),
"", t.content
)
end

end
end
total = total + #todos
end
if not raw and total then
todo("Found ", total, " total todo comments")
end
5 changes: 0 additions & 5 deletions src/cyan/config.tl
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ local config <const> = {
filename = "tlconfig.lua",
}

-- TODO: Get Teal itself to do this typechecking for us
--
-- Ideally, we could somehow use teal to tell us the types inferred in the config file
-- For now, we just try to make a biased `type` function that reports nicer table types

local function get_types_in_array(val: {any}, typefn: function(any): string): {string}
typefn = typefn or type
local set <const> = {}
Expand Down
3 changes: 0 additions & 3 deletions src/cyan/experimental/decoration.tl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
--- A replacement for colorstring that doesn't specifically rely on ANSI
--- terminal escapes

-- local util <const> = require("cyan.util")
-- local tab <const> = util.tab

local util <const> = require("cyan.util")
local ivalues <const>, map <const> = util.tab.ivalues, util.tab.map
local insert <const> = table.insert
Expand Down
1 change: 0 additions & 1 deletion src/cyan/script.tl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function script.register(path: string, command_name: string, hooks: string | {st
registered[command_name] = {}
end
local reg <const> = registered[command_name]
-- TODO(tl bug)
for hook in ivalues((hooks is string and {hooks} or hooks) as {string}) do
if not reg[hook] then
reg[hook] = {}
Expand Down

0 comments on commit bef8375

Please sign in to comment.