|
@@ -44,7 +44,8 @@ Class DocsMaker
|
|
Local md:=stringio.LoadString( mdocs )
|
|
Local md:=stringio.LoadString( mdocs )
|
|
_linkScope=Null
|
|
_linkScope=Null
|
|
_md.Emit( md )
|
|
_md.Emit( md )
|
|
- page=_module.name+"-default"
|
|
|
|
|
|
+ page="module"
|
|
|
|
+' page=_module.name+"-Default"
|
|
SavePage( _md.Flush(),page )
|
|
SavePage( _md.Flush(),page )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
@@ -63,6 +64,85 @@ Class DocsMaker
|
|
Return tree
|
|
Return tree
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ 'Kludgy as!
|
|
|
|
+ '
|
|
|
|
+ 'Converts the 'TOC' tree generated by stackedit into a json nav tree...
|
|
|
|
+ '
|
|
|
|
+ Method MakeLangNav:String()
|
|
|
|
+
|
|
|
|
+ #rem
|
|
|
|
+ Local md:=stringio.LoadString( "docs/The Monkey2 Language.md" )
|
|
|
|
+ _md.Emit( md )
|
|
|
|
+ Local html:=_md.Flush()
|
|
|
|
+
|
|
|
|
+ Local src:=stringio.LoadString( "docs/monkey2-language-template.html" )
|
|
|
|
+ src=src.Replace( "${CONTENT}",html )
|
|
|
|
+
|
|
|
|
+ stringio.SaveString( src,"docs/The Monkey2 Language.html" )
|
|
|
|
+ #End
|
|
|
|
+
|
|
|
|
+ Local src:=stringio.LoadString( "docs/The Monkey2 Language.html" )
|
|
|
|
+
|
|
|
|
+ src=src.Replace( "~r~n","~n" )
|
|
|
|
+
|
|
|
|
+ Local tag1:="<p><div class=~qtoc~q>"
|
|
|
|
+ Local tag2:="</div>"
|
|
|
|
+
|
|
|
|
+ Local i:=src.Find( tag1 )
|
|
|
|
+ If i=-1
|
|
|
|
+ Print "Can't find lang TOC div"
|
|
|
|
+ Return ""
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ Local i2:=src.Find( tag2,i+tag1.Length )
|
|
|
|
+ If i2=-1
|
|
|
|
+ Print "Can't find lang TOC /div"
|
|
|
|
+ Return ""
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ src=src.Slice( i+tag1.Length,i2 )
|
|
|
|
+
|
|
|
|
+ Local nest:=0
|
|
|
|
+
|
|
|
|
+ For Local line:=Eachin src.Split( "~n" )
|
|
|
|
+
|
|
|
|
+ If line="</ul>"
|
|
|
|
+
|
|
|
|
+ If nest
|
|
|
|
+ _nav.Emit( "]}" )
|
|
|
|
+ nest-=1
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ Else If line="</li>"
|
|
|
|
+
|
|
|
|
+ Else If line.StartsWith( "<li>" )
|
|
|
|
+
|
|
|
|
+ Local i:=line.Find( "<a href=~q#" )
|
|
|
|
+ If i=-1 Continue
|
|
|
|
+ Local i2:=line.Find( "~q>",i+10 )
|
|
|
|
+ If i2=-1 Continue
|
|
|
|
+ Local i3:=line.Find( "</a>",i2+2 )
|
|
|
|
+ If i3=-1 Continue
|
|
|
|
+
|
|
|
|
+ Local href:=line.Slice( i+10,i2 )
|
|
|
|
+ Local text:=line.Slice( i2+2,i3 )
|
|
|
|
+
|
|
|
|
+ If line.EndsWith( "<ul>" )
|
|
|
|
+ nest+=1
|
|
|
|
+ _nav.Emit( "{text:~q"+text+"~q,data:{topic:~q"+href+"~q},children:[" )
|
|
|
|
+ Else If line.EndsWith( "</li>" )
|
|
|
|
+ _nav.Emit( "{text:~q"+text+"~q,data:{topic:~q"+href+"~q}}" )
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ Next
|
|
|
|
+
|
|
|
|
+ Local tree:=_nav.Flush()
|
|
|
|
+
|
|
|
|
+ Return tree
|
|
|
|
+ End
|
|
|
|
+
|
|
Private
|
|
Private
|
|
|
|
|
|
Field _nav:JsonBuffer
|
|
Field _nav:JsonBuffer
|
|
@@ -127,14 +207,14 @@ Class DocsMaker
|
|
|
|
|
|
Local slug:=DeclSlug( decl,scope )
|
|
Local slug:=DeclSlug( decl,scope )
|
|
|
|
|
|
- Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qdocsLinkClicked('"+slug+"')~q>"+text+"</a>"
|
|
|
|
|
|
+ Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qopenDocsPage('"+slug+"')~q>"+text+"</a>"
|
|
End
|
|
End
|
|
|
|
|
|
Method MakeLink:String( text:String,nmspace:NamespaceScope )
|
|
Method MakeLink:String( text:String,nmspace:NamespaceScope )
|
|
|
|
|
|
Local slug:=NamespaceSlug( nmspace )
|
|
Local slug:=NamespaceSlug( nmspace )
|
|
|
|
|
|
- Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qdocsLinkClicked('"+slug+"')~q>"+text+"</a>"
|
|
|
|
|
|
+ Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qopenDocsPage('"+slug+"')~q>"+text+"</a>"
|
|
End
|
|
End
|
|
|
|
|
|
Method ResolveLink:String( path:String,scope:Scope )
|
|
Method ResolveLink:String( path:String,scope:Scope )
|
|
@@ -148,8 +228,10 @@ Class DocsMaker
|
|
Local i1:=path.Find( ".",i0 )
|
|
Local i1:=path.Find( ".",i0 )
|
|
If i1=-1
|
|
If i1=-1
|
|
|
|
|
|
- Local id:=path.Slice( i0 )
|
|
|
|
|
|
+ If Not scope Return ""
|
|
|
|
|
|
|
|
+ Local id:=path.Slice( i0 )
|
|
|
|
+
|
|
Local node:=scope.FindNode( id )
|
|
Local node:=scope.FindNode( id )
|
|
If Not node
|
|
If Not node
|
|
Return path
|
|
Return path
|
|
@@ -166,6 +248,9 @@ Class DocsMaker
|
|
Local etype:=TCast<EnumType>( node )
|
|
Local etype:=TCast<EnumType>( node )
|
|
If etype Return MakeLink( tpath,etype.edecl,etype.scope.outer )
|
|
If etype Return MakeLink( tpath,etype.edecl,etype.scope.outer )
|
|
|
|
|
|
|
|
+ Local ntype:=TCast<NamespaceType>( node )
|
|
|
|
+ If ntype Return MakeLink( tpath,ntype.scope )
|
|
|
|
+
|
|
Local ctype:=TCast<ClassType>( node )
|
|
Local ctype:=TCast<ClassType>( node )
|
|
If ctype Return MakeLink( tpath,ctype.cdecl,ctype.scope.outer )
|
|
If ctype Return MakeLink( tpath,ctype.cdecl,ctype.scope.outer )
|
|
|
|
|
|
@@ -202,18 +287,18 @@ Class DocsMaker
|
|
Continue
|
|
Continue
|
|
Endif
|
|
Endif
|
|
|
|
|
|
- Local etype:=TCast<EnumType>( type )
|
|
|
|
- If etype
|
|
|
|
- 'stop at enum!
|
|
|
|
- Return MakeLink( tpath+"."+path.Slice( i0 ),etype.edecl,etype.scope.outer )
|
|
|
|
- Endif
|
|
|
|
-
|
|
|
|
Local ctype:=TCast<ClassType>( type )
|
|
Local ctype:=TCast<ClassType>( type )
|
|
If ctype
|
|
If ctype
|
|
scope=ctype.scope
|
|
scope=ctype.scope
|
|
Continue
|
|
Continue
|
|
Endif
|
|
Endif
|
|
|
|
|
|
|
|
+ Local etype:=TCast<EnumType>( type )
|
|
|
|
+ If etype
|
|
|
|
+ 'stop at Enum!
|
|
|
|
+ Return MakeLink( tpath+"."+path.Slice( i0 ),etype.edecl,etype.scope.outer )
|
|
|
|
+ Endif
|
|
|
|
+
|
|
Return ""
|
|
Return ""
|
|
|
|
|
|
Forever
|
|
Forever
|