Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Create a `Makefile` target:

```makefile
.deps/docgen.nvim:
git clone --depth 1 --branch v1.0.0 https://github.com/jamestrew/docgen.nvim $@
git clone --depth 1 --branch v1.0.1 https://github.com/jamestrew/docgen.nvim $@

.PHONY: docgen
docgen: .deps/docgen.nvim
Expand Down
2 changes: 1 addition & 1 deletion lua/docgen/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ end
---@return string
function M.render_file_header(name, description)
local tag = string.format("*%s.txt*", name)
return string.format("%s\n\n", tag .. " " .. description)
return string.format("%s%" .. (TEXT_WIDTH - #tag) .. "s\n\n", tag, description)
end

---@param doc_lines string[]
Expand Down
15 changes: 15 additions & 0 deletions tests/renderer_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1087,3 +1087,18 @@ new paragraph
assert_md(input, input)
end)
end)

describe("file header", function()
it("works", function()
local result = renderer.render_file_header("myplugin", "My plugin description")
local lines = vim.split(result, "\n")
assert.equal(#lines, 3)

local line = lines[1]
assert.equal(type(line), "string")
---@cast line string
assert.equal(78, #line)
assert.truthy(vim.startswith(line, "*myplugin.txt*"))
assert.truthy(vim.endswith(line, "My plugin description"))
end)
end)
Loading