Skip to content

Commit

Permalink
🐛fix(args): All generators now accept a option to pass arguments dire…
Browse files Browse the repository at this point in the history
…ctly to the command to generate documentation.
  • Loading branch information
Zeioth committed Jan 12, 2024
1 parent 9dc8c56 commit ad5b4d4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lua/dooku/backends/doxygen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function M.generate(is_autocmd)
if job then uv.process_kill(job, 9) end -- Running already? kill it
job = uv.spawn(
"doxygen",
{ args = { "Doxyfile", config.doxygen_args }, cwd = doxygen_dir, detach = true }
{ args = config.doxygen_args , cwd = doxygen_dir, detach = true }
)

-- Open html docs
Expand Down
2 changes: 1 addition & 1 deletion lua/dooku/backends/godoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function M.generate(is_autocmd)
vim.log.levels.INFO, {title="dooku.nvim"})
end

job = vim.fn.jobstart('godoc ' .. config.godoc_args, { cwd = cwd })
job = uv.spawn("godoc", { args = config.godoc_args, cwd = cwd, detach = true })
autocmd("VimLeavePre", {
desc = "Stop godoc when exiting vim",
group = augroup("dooku_stop_godoc", { clear = true }),
Expand Down
2 changes: 1 addition & 1 deletion lua/dooku/backends/jsdoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function M.generate(is_autocmd)

if job then uv.process_kill(job, 9) end -- Running already? kill it
job = uv.spawn(
"jsdoc", { args = { "-c", "jsdoc.json" }, cwd = cwd, detach = true }
"jsdoc", { args = config.jsdoc_args , cwd = cwd, detach = true }
)

-- Open html docs
Expand Down
2 changes: 1 addition & 1 deletion lua/dooku/backends/rustdoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function M.generate(is_autocmd)
if job then uv.process_kill(job, 9) end -- Running already? kill it
job = uv.spawn(
"cargo",
{ args = {"rustdoc", config.cargo_rustdoc_args, "--", config.rustdoc_args}, cwd = cwd, detach = true }
{ args = config.rustdoc_args, cwd = cwd, detach = true }
)

-- Open html docs
Expand Down
2 changes: 1 addition & 1 deletion lua/dooku/backends/typedoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function M.generate(is_autocmd)

if job then uv.process_kill(job, 9) end -- Running already? kill it
job = uv.spawn(
"typedoc", { cwd = cwd, detach = true }
"typedoc", { args = config.typedoc_args, cwd = cwd, detach = true }
)

-- Open html docs
Expand Down
18 changes: 10 additions & 8 deletions lua/dooku/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function M.set(opts)
M.doxygen_clone_to_dir .. "/README.md"
)

-- Args for godoc
M.doxygen_args = opts.doxygen_args or ""
-- Args for doxygen
M.doxygen_args = opts.doxygen_args or { "Doxyfile" }

-- [TYPEDOC]
-- -----------------------------------------------------------------------
Expand Down Expand Up @@ -106,6 +106,9 @@ function M.set(opts)
.. M.typedoc_clone_to_dir
)

-- Args for typedoc
M.typedoc_args = opts.typedoc_args or { "" }

-- [JSDOC]
-- -----------------------------------------------------------------------
M.jsdoc_filetypes = opts.jsdoc_filetypes or { "javascript" }
Expand Down Expand Up @@ -135,6 +138,9 @@ function M.set(opts)
.. M.jsdoc_clone_to_dir
)

-- Args for jsdoc
M.jsdoc_args = opts.jsdoc_args or { "-c", "jsdoc.json", "--readme", "README.md" }

-- [RUSTDOC]
-- -----------------------------------------------------------------------
M.rustdoc_filetypes = opts.rustdoc_filetypes or { "rust" }
Expand All @@ -146,8 +152,7 @@ function M.set(opts)
M.rustdoc_html_file = opts.rustdoc_html_file or "index.html"

-- args for rustdoc
M.cargo_rustdoc_args = opts.cargo_rustdoc_args or ""
M.rustdoc_args = opts.rustdoc_args or ""
M.rustdoc_args = opts.rustdoc_args or { "rustdoc" }

-- [GODOC]
---------------------------------------------------------------
Expand All @@ -157,13 +162,10 @@ function M.set(opts)
M.godoc_html_url = opts.godoc_html_file or "localhost:6060"

-- Args for godoc
M.godoc_args = opts.godoc_args or "-index"
M.godoc_args = opts.godoc_args or { "-index" }

-- After setting the config
---------------------------------------------------------------
-- Convert empty string to nil where necessary
M.cargo_rustdoc_args = utils.sanitize_string(M.cargo_rustdoc_args)
M.rustdoc_args = utils.sanitize_string(M.rustdoc_args)

-- expose the config as global
vim.g.dooku_config = M
Expand Down

0 comments on commit ad5b4d4

Please sign in to comment.