Skip to content

Commit fd46272

Browse files
Updated articles.lua
1 parent 32ea9a3 commit fd46272

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

scripts/docs/articles.lua

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,26 @@ local function writeMethods( section, methods, separator )
7979
local constructor = section == method
8080
if ( constructor ) then
8181
signature = section
82+
83+
if ( docs.isPanel( section ) ) then
84+
signature = "gui." .. signature
85+
end
8286
end
8387
insert( md, r_header( signature .. "()" ) )
8488

89+
-- Location
90+
local v = docs.findModule( section )
91+
insert( md, r_header2( "Source" ) )
92+
local info = debug.getinfo( v[ method ], "S" )
93+
local path = info.short_src
94+
local line = info.linedefined
95+
local href = "https://github.com/Planimeter/grid-sdk/blob/master/src/"
96+
href = href .. path .. "#L" .. line
97+
insert( md, "[`" .. path .. "`](" .. href .. ")" )
98+
insert( md, "" )
99+
85100
-- Usage
86101
insert( md, r_header2( "Usage" ) )
87-
local v = docs.findModule( section )
88102
require( "engine.shared.dblib" )
89103
local params, isvararg = debug.getparameters( v[ method ] )
90104
if ( params[ 1 ] == "self" ) then
@@ -111,8 +125,16 @@ local function writeMethods( section, methods, separator )
111125
insert( md, r_header2( "Parameters" ) )
112126
insert( md, r_table( parameters ) )
113127
end
128+
insert( md, "" )
114129

130+
-- Stub
131+
-- local baseHref = "https://github.com/Planimeter/grid-sdk/wiki/"
132+
insert(
133+
md,
134+
"_This article is a stub. You can help Planimeter by expanding it._"
135+
)
115136
insert( md, "" )
137+
116138
md = concat( md, "\r\n" )
117139
filesystem.write( "docs/" .. section .. "." .. method .. ".md", md )
118140
end

scripts/docs/init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ local string = string
1717
local table = table
1818
local tostring = tostring
1919
local type = type
20+
local typeof = typeof
2021
local _G = _G
2122

2223
module( "docs" )
@@ -217,6 +218,11 @@ function getMethods( t )
217218
return methods
218219
end
219220

221+
function isPanel( modname )
222+
local v = findModule( modname )
223+
return typeof( v, "panel" ) or v == gui.panel
224+
end
225+
220226
function getPanels()
221227
local panels = {}
222228
local blacklist = {

scripts/docs/sections.lua

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,13 @@ local function r_header2( header )
7171
return concat( md, "\r\n" )
7272
end
7373

74-
local function isPanel( module )
75-
local v = docs.findModule( module )
76-
return typeof( v, "panel" ) or v == gui.panel
77-
end
78-
7974
local function r_constructor( section )
8075
local md = {}
8176
insert( md, r_header2( "Constructor" ) )
82-
local modname = isPanel( section ) and "gui" or section
83-
insert(
84-
md,
85-
"* [`" .. ( modname == "gui" and "gui." or "" ) .. section .. "()`]" ..
86-
"(" .. modname .. "." .. section .. ")"
87-
)
77+
local modname = docs.isPanel( section ) and "gui" or section
78+
local signature = ( modname == "gui" and "gui." or "" ) .. section
79+
local href = ( modname == "gui" and section or modname ) .. "." .. section
80+
insert( md, "* [`" .. signature .. "()`]" .. "(" .. href .. ")" )
8881
insert( md, "" )
8982
return concat( md, "\r\n" )
9083
end

0 commit comments

Comments
 (0)