1- --- @class (exact ) Module
1+ --- @class (exact ) Src
22--- @field helptag string must be globally unique
33--- @field section string arbitrary
44--- @field path string relative to root
5- --- @field file string ? generated from path
6- --- @field name string ? override generated module name
5+ --- @field file_name string ? generated from path
6+ --- @field name string ? override generated name
77
8- --- Generated within help files in this order
9- --- @type Module []
10- local modules = {
8+ --- Help txt is deleted from first tag down and generated content is appended.
9+ --- @type Src []
10+ local srcs = {
1111 { helptag = " nvim-tree-config" , section = " Class: Config" , path = " ./lua/nvim_tree/_meta/config.lua" , },
1212 { helptag = " nvim-tree-config-sort" , section = " Class: Config.Sort" , path = " ./lua/nvim_tree/_meta/config/sort.lua" , },
1313 { helptag = " nvim-tree-config-view" , section = " Class: Config.View" , path = " ./lua/nvim_tree/_meta/config/view.lua" , },
@@ -47,17 +47,17 @@ local modules = {
4747}
4848
4949-- hydrate file names
50- for _ , m in ipairs (modules ) do
51- m .file = vim .fn .fnamemodify (m .path , " :t" )
50+ for _ , m in ipairs (srcs ) do
51+ m .file_name = vim .fn .fnamemodify (m .path , " :t" )
5252end
5353
5454-- name is derived by the generator as the file name with the first letter capitalised
55- -- except for some like UI
56- --- @type table<string , Module >
57- local modules_by_section = {}
58- for _ , m in ipairs (modules ) do
59- local name = m .name or m .file :gsub (" .lua" , " " ):gsub (" ^%l" , string.upper )
60- modules_by_section [name ] = m
55+ -- except for some like UI which are overridden in srcs
56+ --- @type table<string , Src >
57+ local srcs_by_name = {}
58+ for _ , m in ipairs (srcs ) do
59+ local name = m .name or m .file_name :gsub (" .lua" , " " ):gsub (" ^%l" , string.upper )
60+ srcs_by_name [name ] = m
6161end
6262
6363--- @diagnostic disable-next-line : undefined-doc-name
@@ -66,22 +66,22 @@ local config = {
6666 all = {
6767 filename = " nvim-tree-lua.txt" ,
6868
69- -- file is used to set order
70- section_order = vim .tbl_map (function (m ) return m . file end , modules ),
69+ -- source file name is used to set order
70+ section_order = vim .tbl_map (function (src ) return src . file_name end , srcs ),
7171
7272 -- path
73- files = vim .tbl_map (function (m ) return m .path end , modules ),
73+ files = vim .tbl_map (function (src ) return src .path end , srcs ),
7474
7575 section_fmt = function (name )
7676 print (string.format (" section_fmt name=%s" , name ))
77- return modules_by_section [name ] and modules_by_section [name ].section or
78- error (string.format (" unknown module %s passed to section_fmt" , name ))
77+ return srcs_by_name [name ] and srcs_by_name [name ].section or
78+ error (string.format (" unknown name %s passed to section_fmt" , name ))
7979 end ,
8080
8181 helptag_fmt = function (name )
8282 print (string.format (" helptag_fmt name=%s" , name ))
83- return modules_by_section [name ] and modules_by_section [name ].helptag or
84- error (string.format (" unknown module %s passed to helptag_fmt" , name ))
83+ return srcs_by_name [name ] and srcs_by_name [name ].helptag or
84+ error (string.format (" unknown name %s passed to helptag_fmt" , name ))
8585 end ,
8686
8787 -- optional, no default xform
0 commit comments