Skip to content

Commit

Permalink
docs: various fixes and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Oct 13, 2024
1 parent b452039 commit d230f4f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion lua/care/presets/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function PresetUtils.get_highlight_for_hex(hex)
return hl
end

---@param style? "blended"|"fg"
function PresetUtils.kind_highlight(entry, style)
local completion_item = entry.completion_item
local entry_kind = type(completion_item.kind) == "string" and completion_item.kind
Expand Down
9 changes: 9 additions & 0 deletions lua/care/types/preset_components.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
--- This module contains some high-level components for easily creating `format_entry` functions.
--- ```lua
--- format_entry = function(entry, data)
--- local preset_components = require("care.presets.components")
--- return {
--- preset_components.<component_name>(<component_parameters>),
--- preset_components.<component_name>(<component_parameters>),
--- }
--- end
--- ```
---@class care.preset_components
--- This adds a label for shortcuts [described here](/configuration_recipes#labels-and-shortcuts). By default this will
--- use the `Comment` highlight group. This can be overridden though.
Expand Down
2 changes: 1 addition & 1 deletion lua/care/types/preset_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
---@field get_highlight_for_hex fun(hex: string): string
--- With this function you can get the kind highlight group for a specific entry. The style can either be foreground
--- or blended.
---@field kind_highlight fun(entry: care.entry, style: "fg"|"blended")
---@field kind_highlight fun(entry: care.entry, style: "fg"|"blended"): string
9 changes: 7 additions & 2 deletions scripts/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ local function read_classes(path)
local class_strings = vim.split(contents, "\n\n")
for i, class_string in ipairs(class_strings) do
local class_desc =
table.concat(vim.split(class_string:match("%-%-%- (.-)\n%-%-%-@class") or "", "\n%-%-%- *"), "\n")
table.concat(vim.split(class_string:match("%-%-%- (.-)\n%-%-%-@class") or "", "\n%-%-%- "), "\n")
print(class_desc)
local class_name = class_string:match("%-%-%-@class (.-)\n")
local fields_string = class_string:match(".-%-%-%-@class .-\n(.*)")
local fields = { { descriptions = {} } }
Expand Down Expand Up @@ -138,6 +139,10 @@ local function cleanup_annotation(short_class_name, annotation)
end

local function get_class_docs(path, title, desc, mark_optionals, write_types)
if write_types == nil then
write_types = true
end
print(write_types)
mark_optionals = mark_optionals or false
local classes = read_classes(path)
local contents = {
Expand Down Expand Up @@ -208,7 +213,7 @@ end

local function write_class_docs()
for _, docs in ipairs(docs_files) do
local contents = get_class_docs(docs.type_file, docs.title, docs.desc or nil, docs.types or true)
local contents = get_class_docs(docs.type_file, docs.title, docs.desc or nil, nil, docs.types)
write_file(docs.doc_file, table.concat(contents, "\n"))
end
end
Expand Down

0 comments on commit d230f4f

Please sign in to comment.