Skip to content

Commit 107f127

Browse files
Updated articles.lua
1 parent fd46272 commit 107f127

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

scripts/docs/articles.lua

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ local function writeMethods( section, methods, separator )
7676
-- Header
7777
local md = {}
7878
local signature = section .. separator .. method
79+
if ( docs.isGameInterface( section ) ) then
80+
signature = method
81+
end
7982
local constructor = section == method
8083
if ( constructor ) then
8184
signature = section
@@ -98,19 +101,21 @@ local function writeMethods( section, methods, separator )
98101
insert( md, "" )
99102

100103
-- Usage
101-
insert( md, r_header2( "Usage" ) )
102104
require( "engine.shared.dblib" )
103105
local params, isvararg = debug.getparameters( v[ method ] )
104106
if ( params[ 1 ] == "self" ) then
105107
table.remove( params, 1 )
106108
end
107-
local args = ( #params > 0 and "( " ..
108-
concat( params, ", " ) .. ( isvararg and ", ..." or "" ) ..
109-
" )" or "()" )
110-
insert( md, "```lua\r\n" ..
111-
signature .. args .. "\r\n" ..
112-
"```" )
113-
insert( md, "" )
109+
if ( not docs.isGameInterface( section ) ) then
110+
insert( md, r_header2( "Usage" ) )
111+
local args = ( #params > 0 and "( " ..
112+
concat( params, ", " ) .. ( isvararg and ", ..." or "" ) ..
113+
" )" or "()" )
114+
insert( md, "```lua\r\n" ..
115+
signature .. args .. "\r\n" ..
116+
"```" )
117+
insert( md, "" )
118+
end
114119

115120
-- Parameters
116121
local parameters = {}
@@ -125,18 +130,22 @@ local function writeMethods( section, methods, separator )
125130
insert( md, r_header2( "Parameters" ) )
126131
insert( md, r_table( parameters ) )
127132
end
128-
insert( md, "" )
129133

130134
-- Stub
131135
-- local baseHref = "https://github.com/Planimeter/grid-sdk/wiki/"
132136
insert(
133137
md,
134-
"_This article is a stub. You can help Planimeter by expanding it._"
138+
"*This article is a stub. You can help Planimeter by expanding it.*"
135139
)
136140
insert( md, "" )
137141

142+
local filename = section .. "." .. method
143+
if ( docs.isGameInterface( section ) ) then
144+
filename = method
145+
end
146+
138147
md = concat( md, "\r\n" )
139-
filesystem.write( "docs/" .. section .. "." .. method .. ".md", md )
148+
filesystem.write( "docs/" .. filename .. ".md", md )
140149
end
141150
end
142151

@@ -176,6 +185,7 @@ local function writeArticles( section )
176185
end
177186

178187
local sections = {}
188+
table.append( sections, { "game" } )
179189
table.append( sections, docs.getClasses() )
180190
table.append( sections, docs.getInterfacesAndLibraries() )
181191
table.append( sections, docs.getPanels() )

scripts/docs/init.lua

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ function getClasses()
149149
return classes
150150
end
151151

152-
function isClassMethod( f )
153-
require( "engine.shared.dblib" )
154-
local parameters = debug.getparameters( f )
155-
return not parameters[ 1 ] or parameters[ 1 ] ~= "self"
156-
end
157-
158152
function getClassMethods( class )
159153
local classMethods = {}
160154
local methods = getAllMethods( class )
@@ -173,10 +167,10 @@ function getInterfacesAndLibraries()
173167
"serverengine",
174168
"networkclient",
175169
"networkserver",
176-
"gameclient",
177-
"gameserver",
170+
-- "gameclient",
171+
-- "gameserver",
178172
"docs",
179-
"game"
173+
-- "game"
180174
}
181175
for k, v in pairs( _G ) do
182176
if ( rawtype( v ) == "table" and
@@ -218,11 +212,6 @@ function getMethods( t )
218212
return methods
219213
end
220214

221-
function isPanel( modname )
222-
local v = findModule( modname )
223-
return typeof( v, "panel" ) or v == gui.panel
224-
end
225-
226215
function getPanels()
227216
local panels = {}
228217
local blacklist = {
@@ -245,3 +234,24 @@ function getPanels()
245234
table.sort( panels )
246235
return panels
247236
end
237+
238+
function isClassMethod( f )
239+
require( "engine.shared.dblib" )
240+
local parameters = debug.getparameters( f )
241+
return not parameters[ 1 ] or parameters[ 1 ] ~= "self"
242+
end
243+
244+
local interfaces = {
245+
"gameclient",
246+
"gameserver",
247+
"game"
248+
}
249+
250+
function isGameInterface( modname )
251+
return table.hasvalue( interfaces, modname )
252+
end
253+
254+
function isPanel( modname )
255+
local v = findModule( modname )
256+
return typeof( v, "panel" ) or v == gui.panel
257+
end

scripts/docs/sections.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ local function r_methods( section, methods, separator )
9696
end
9797

9898
local function writeSection( section )
99+
if ( docs.isGameInterface( section ) ) then
100+
return
101+
end
102+
99103
local md = {}
100104
insert( md, r_header( section ) )
101105
insert( md, r_purpose( section ) )
@@ -107,7 +111,9 @@ local function writeSection( section )
107111
insert( md, r_methods( section, docs.getClassMethods( v ), "." ) )
108112
end
109113

110-
insert( md, r_constructor( section ) )
114+
if ( v[ section ] ) then
115+
insert( md, r_constructor( section ) )
116+
end
111117

112118
if ( #docs.getMethods( v ) > 0 ) then
113119
insert( md, r_header2( "Methods" ) )

0 commit comments

Comments
 (0)