Skip to content

Commit

Permalink
Small refactor doc gen
Browse files Browse the repository at this point in the history
  • Loading branch information
notomo committed May 15, 2024
1 parent 6ed3fe4 commit 4df0d8a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions spec/lua/promise/doc.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local util = require("genvdoc.util")
local example_path = "./spec/lua/promise/example.lua"

local wait = dofile(example_path)
Expand All @@ -22,7 +23,7 @@ require("genvdoc").generate("promise.nvim", {
name = "EXAMPLES",
body = function()
local exclude = false
return require("genvdoc.util").help_code_block_from_file(example_path, {
return util.help_code_block_from_file(example_path, {
include = function(line)
exclude = exclude or line:match("finished")
return not exclude
Expand All @@ -35,9 +36,7 @@ require("genvdoc").generate("promise.nvim", {
})

local gen_readme = function()
local f = io.open(example_path, "r")
local exmaple = f:read("*a"):gsub("local wait.*", "")
f:close()
local exmaple = util.read_all(example_path):gsub("local wait.*", "")

local content = ([[
# promise.nvim
Expand All @@ -50,8 +49,6 @@ Mainly used by embedding `lua/promise/init.lua` in plugins.
```lua
%s```]]):format(exmaple)

local readme = io.open("README.md", "w")
readme:write(content)
readme:close()
util.write("README.md", content)
end
gen_readme()

0 comments on commit 4df0d8a

Please sign in to comment.