@@ -3,14 +3,14 @@ Namespace wx.newdocs
33
44Class DocsBuffer
55
6- Method New()
7-
8- End
9-
10- Method New( docs:DocsNode,baseDir:String )
6+ Method New( docs:DocsNode, parent:DocsNode, module:Module, baseDir:String="" )
117
128 _docs=docs
139
10+ _parent=parent
11+
12+ _module=module
13+
1414 _baseDir=baseDir
1515
1616 End
@@ -74,7 +74,7 @@ Class DocsBuffer
7474 Local tag:=line.Slice( 1,j )
7575 Local arg:=line.Slice( j+1 ).Trim()
7676
77- Select tag
77+ Select tag.ToLower()
7878 Case "deprecated"
7979
8080 Emit( "(Deprecated: "+arg+")" )
@@ -92,6 +92,8 @@ Class DocsBuffer
9292 _return=arg
9393
9494 Case "import"
95+
96+ If arg.StartsWith("~q") And arg.EndsWith("~q") Then arg = arg.Slice(1,-1)
9597
9698 Local path:=_baseDir+arg
9799
@@ -102,14 +104,44 @@ Class DocsBuffer
102104
103105 Local docs:=New DocsNode( "","",_docs,DocsType.Nav,True )
104106
105- Local buf:=New DocsBuffer( docs,ExtractDir( path ) )
107+ Local buf:=New DocsBuffer( docs, _parent, _module, ExtractDir( path ) )
106108
107109 buf.Emit( src )
108110
109111 docs.Markdown=buf.Flush()
110112 Else
111113 Print "DocsBuffer: Can't @import file '"+path+"'"
114+ Print " FileName: "+arg
115+ 'Debug()
112116 Endif
117+
118+ Case "image"
119+
120+ If arg.StartsWith("~q") And arg.EndsWith("~q") Then arg = arg.Slice(1,-1)
121+
122+ Local srcImage:String, dstImage:String
123+
124+ If _module
125+ srcImage = _module.baseDir+"images/"+arg
126+ dstImage = "modules/"+_module.name+"/images/"+arg
127+ Endif
128+
129+ If srcImage And dstImage And GetFileType( srcImage ) = FileType.File
130+ 'Print "Importing Image: "+arg
131+ 'Print " FileName: "+arg
132+ 'Debug()
133+
134+ EmitLine( "<img src=~q../images/"+arg+"~q alt=~qImage~q>" )
135+
136+ DocsMaker.AddImage(srcImage, dstImage)
137+
138+ Else
139+ Print "DocsBuffer: '@image' Can't find file '"+arg+"'"
140+ If _docs Then Print " Entity: "+_docs.DeclPath
141+ If srcImage Then Print " Expected location: "+srcImage
142+ 'Debug()
143+ Endif
144+
113145
114146 Case "example"
115147
@@ -144,7 +176,7 @@ Class DocsBuffer
144176
145177 Local docs:=New DocsNode( ident,label,_docs,DocsType.Decl )
146178
147- Local buf:=New DocsBuffer( docs,_baseDir )
179+ Local buf:=New DocsBuffer( docs, _parent, _module, _baseDir )
148180
149181 buf.EmitLines( lines.Slice( i ) )
150182
@@ -196,9 +228,51 @@ Class DocsBuffer
196228 Return markdown
197229 End
198230
231+ Method Debug()
232+ Print " DocsBuffer.Debug()"
233+ Print " BaseDir : "+_baseDir
234+ If _docs
235+ Print " _docs.Ident : "+_docs.Ident
236+ Print " _docs.Label : "+_docs.Label
237+ Print " _docs.FilePath : "+_docs.FilePath
238+ Print " _docs.FilePathUrl: "+_docs.FilePathUrl
239+ Print " _docs.DeclPath : "+_docs.DeclPath
240+ Print " _docs.DeclLink : "+_docs.DeclLink
241+ Else
242+ Print " _docs:DocsNode = Null"
243+ Endif
244+ If _parent
245+ Print " _parent.Ident : "+_parent.Ident
246+ Print " _parent.Label : "+_parent.Label
247+ Print " _parent.FilePath : "+_parent.FilePath
248+ Print " _parent.FilePathUrl: "+_parent.FilePathUrl
249+ Print " _parent.DeclPath : "+_parent.DeclPath
250+ Print " _parent.DeclLink : "+_parent.DeclLink
251+ Else
252+ Print " _docs:DocsNode = Null"
253+ Endif
254+ If _module
255+ Print " _module.name: "+_module.name
256+ Print " _module.srcPath: "+_module.srcPath
257+ Print " _module.ident: "+_module.ident
258+ Print " _module.baseDir: "+_module.baseDir
259+ Print " _module.buildDir: "+_module.buildDir
260+ Print " _module.outputDir: "+_module.outputDir
261+ Print " _module.cacheDir: "+_module.cacheDir
262+ Print " _module.hfileDir: "+_module.hfileDir
263+ Print " _module.cfileDir: "+_module.cfileDir
264+ Print " _module.afile: "+_module.afile
265+ Print " _module.rfile: "+_module.rfile
266+ Else
267+ Print " _module:Module = Null"
268+ Endif
269+ End
270+
199271 Private
200272
201273 Field _docs:DocsNode
274+ Field _parent:DocsNode
275+ Field _module:Module
202276 field _baseDir:String
203277 Field _lines:=New StringStack
204278 Field _label:String
0 commit comments