@@ -7,6 +7,19 @@ local glob = require 'glob'
7
7
--- @class parser.object
8
8
--- @field package _visibleType ? parser.visibleType
9
9
10
+ local function globMatch (patterns , fieldName )
11
+ return glob .glob (patterns )(fieldName )
12
+ end
13
+
14
+ local function luaMatch (patterns , fieldName )
15
+ for i = 1 , # patterns do
16
+ if string.find (fieldName , patterns [i ]) then
17
+ return true
18
+ end
19
+ end
20
+ return false
21
+ end
22
+
10
23
local function getVisibleType (source )
11
24
if guide .isLiteral (source ) then
12
25
return ' public'
@@ -43,32 +56,21 @@ local function getVisibleType(source)
43
56
if type (fieldName ) == ' string' then
44
57
local uri = guide .getUri (source )
45
58
local regengine = config .get (uri , ' Lua.doc.regengine' )
46
- local function match (patterns )
47
- if regengine == " glob" then
48
- return glob .glob (patterns )(fieldName )
49
- else
50
- for i = 1 , # patterns do
51
- if string.find (fieldName , patterns [i ]) then
52
- return true
53
- end
54
- end
55
- end
56
- end
57
-
59
+ local match = regengine == " glob" and globMatch or luaMatch
58
60
local privateNames = config .get (uri , ' Lua.doc.privateName' )
59
- if # privateNames > 0 and match (privateNames ) then
61
+ if # privateNames > 0 and match (privateNames , fieldName ) then
60
62
source ._visibleType = ' private'
61
63
return ' private'
62
64
end
63
65
64
66
local protectedNames = config .get (uri , ' Lua.doc.protectedName' )
65
- if # protectedNames > 0 and match (protectedNames ) then
67
+ if # protectedNames > 0 and match (protectedNames , fieldName ) then
66
68
source ._visibleType = ' protected'
67
69
return ' protected'
68
70
end
69
71
70
72
local packageNames = config .get (uri , ' Lua.doc.packageName' )
71
- if # packageNames > 0 and match (packageNames ) then
73
+ if # packageNames > 0 and match (packageNames , fieldName ) then
72
74
source ._visibleType = ' package'
73
75
return ' package'
74
76
end
0 commit comments