feat(generator): improve `indent` implementation
This commit is contained in:
parent
89f66119ee
commit
b1c3d80604
|
@ -1,17 +1,14 @@
|
||||||
local Function_Info = require "entity.Function_Info"
|
local Function_Info = require "entity.Function_Info"
|
||||||
local List = require "pl.List"
|
local List = require "pl.List"
|
||||||
local utils = require "utils"
|
local stringx = require "pl.stringx"
|
||||||
local template = require "pl.template"
|
local template = require "pl.template"
|
||||||
|
local utils = require "utils"
|
||||||
|
|
||||||
local snippets = {}
|
local snippets = {}
|
||||||
|
|
||||||
function snippets.indent(str: string, level: number): string
|
function snippets.indent(str: string, level: number): string
|
||||||
level = level or 1
|
level = level or 1
|
||||||
local ret = ""
|
return stringx.rstrip(stringx.indent(str, level, string.rep(" ", 3)))
|
||||||
for line in str:gmatch("[^\n]+") do
|
|
||||||
ret = ret .. string.rep(" ", level * 3) .. line .. "\n"
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function snippets.render_typed_variable(name: string, types: List<string>): string
|
function snippets.render_typed_variable(name: string, types: List<string>): string
|
||||||
|
|
Loading…
Reference in New Issue