Explorar el Código

Added support for overloading.
Split methods into constructor, destructor, operator and method groups.

woollybah hace 6 años
padre
commit
189a80766d

+ 24 - 2
src/makedocs/docnode.bmx

@@ -10,6 +10,7 @@ Type TDocNode
 	Field kind$		'eg: "Module", "Function", "Type" etc
 	
 	Field proto$		'eg: Function LoadImage(...)
+	Field protoId:String
 	Field bbdoc$		'eg: Load an image (shortdesc?)
 	Field returns$	'eg: A new image
 	Field about$		'eg: blah etc blah (longdesc?)
@@ -25,10 +26,30 @@ Type TDocNode
 		Return TDocNode( _pathMap.ValueForKey( path ) )
 
 	End Function
+
+	Function GetDocNodeOrOverloadPath:TDocNode(kind:String, origPath:String, path:String Var, protoId:String, count:Int = 0)
+		Local t:TDocNode=TDocNode( _pathMap.ValueForKey( path ) )
+
+		If kind <> "Method" And kind <> "Function" Then
+			Return t
+		End If
+		
+		If t And t.protoId <> protoId Then
+		
+			count :+ 1
+			
+			path = origPath + "_" + count
+			
+			Return GetDocNodeOrOverloadPath(kind, origPath, path, protoId, count)
+		End If
+		
+		Return t
+	End Function
 	
-	Function Create:TDocNode( id$,path$,kind$ )
+	Function Create:TDocNode( id$,path$,kind$, protoId:String )
 	
-		Local t:TDocNode=TDocNode( _pathMap.ValueForKey( path ) )
+		'Local t:TDocNode=TDocNode( _pathMap.ValueForKey( path ) )
+		Local t:TDocNode = GetDocNodeOrOverloadPath(kind, path, path, protoId)
 		
 		If t
 			If t.kind<>"/" And t.path<>path Throw "ERROR: "+t.kind+" "+kind
@@ -41,6 +62,7 @@ Type TDocNode
 		t.id=id
 		t.path=path
 		t.kind=kind
+		t.protoId = protoId
 		
 		Local q:TDocNode=t
 		

+ 20 - 3
src/makedocs/docstyle.bmx

@@ -148,9 +148,26 @@ Type TDocStyle Extends TBBLinkResolver
 			EmitLinks t
 		Next
 		
-		For Local t$=EachIn LeafKinds
-			EmitDecls t, node
+		Local leafOrder:String[] = ["Field", "Method", "Function", "Global", "Const", "Keyword"]
+		Local categoryOrder:String[] = ["Constructor", "Operator", "-", "Destructor"]
+
+		For Local order:String = EachIn leafOrder
+			For Local t$=EachIn LeafKinds
+				If order = t Then
+					If order = "Method" Then
+						For Local category:String = EachIn categoryOrder
+							EmitDecls t, node, category
+						Next
+					Else
+						EmitDecls t, node
+					End If
+				End If
+			Next
 		Next
+
+'		For Local t$=EachIn LeafKinds
+'			EmitDecls t, node
+'		Next
 		
 		EmitFooter
 		
@@ -186,7 +203,7 @@ Type TDocStyle Extends TBBLinkResolver
 	
 	Method EmitLinks( kind$ ) Abstract
 	
-	Method EmitDecls( kind$, parent:TDocNode ) Abstract
+	Method EmitDecls( kind$, parent:TDocNode, category:String = Null ) Abstract
 	
 End Type
 

+ 40 - 4
src/makedocs/fredborgstyle.bmx

@@ -85,15 +85,51 @@ Type TFredborgStyle Extends TDocStyle
 	
 	End Method
 	
-	Method EmitDecls( kind$, parent:TDocNode )
+	Method EmitDecls( kind$, parent:TDocNode, category:String = Null )
 
 		Local list:TList=ChildList( kind )
 		If Not list Return
-		
-		Emit "<h2>"+kind+" reference</h2>"
+
+		Local title:String
+		Local emittedTitle:Int
+	
+		If category And category <> "-" Then
+			title = "<h2>"+category+" reference</h2>"
+		Else
+			title = "<h2>"+kind+" reference</h2>"
+		End If
+
+		'Emit "<h2>"+kind+" reference</h2>"
 		
 		For Local t:TDocNode=EachIn list
-		
+
+			If category Then
+				Local id:String = t.id.ToLower()
+				Select category
+					Case "-"
+						If id = "new" Or id = "delete" Or id = "operator" Then
+							Continue
+						End If
+					Case "Constructor"
+						If id <> "new" Then
+							Continue
+						End If
+					Case "Destructor"
+						If id <> "delete" Then
+							Continue
+						End If
+					Case "Operator"
+						If id <> "operator" Then
+							Continue
+						End If
+				End Select
+			End If
+			
+			If Not emittedTitle Then
+				Emit title
+				emittedTitle = True
+			End If
+
 			Emit "<a name=~q"+t.id+"~q></a>"
 		
 			Emit "<p><table class=doc width=100% cellspacing=3>"

+ 27 - 5
src/makedocs/makedocs.bmx

@@ -25,7 +25,7 @@ DeleteDir BmxDocDir,True
 
 CopyDir BlitzMaxPath()+"/docs/src",BmxDocDir
 
-Local root:TDocNode=TDocNode.Create( "BlitzMax Help","/","/" )
+Local root:TDocNode=TDocNode.Create( "BlitzMax Help","/","/", Null )
 root.about=LoadText( BmxDocDir+"/index.html" )
 
 DocMods
@@ -96,7 +96,7 @@ Function DocBBDocs( docPath$ )
 				If id="index" Or id="intro" Continue
 				
 				Local path$=(docPath+"/"+id).Replace( "//","/" )
-				Local node:TDocNode=TDocNode.Create( id,path,"/" )
+				Local node:TDocNode=TDocNode.Create( id,path,"/", Null )
 				
 				node.about=LoadText( q )
 			End Select
@@ -121,9 +121,9 @@ Function docBmxFile( filePath$,docPath$ )
 	
 	Local bbdoc$,returns$,about$,keyword$,params:TList
 	
-	Local text$=LoadText( filepath )
+	Local Text$=LoadText( filepath )
 	
-	For Local line$=EachIn text.Split( "~n" )
+	For Local line$=EachIn Text.Split( "~n" )
 
 		line=line.Trim()
 		Local tline$=line.ToLower()
@@ -261,7 +261,7 @@ Function docBmxFile( filePath$,docPath$ )
 					proto=proto[..i]
 				EndIf
 				
-				Local node:TDocNode=TDocNode.Create( id,path,kind )
+				Local node:TDocNode=TDocNode.Create( id,path,kind, BuildProtoId(proto) )
 				
 				node.proto=proto
 				node.bbdoc=bbdoc
@@ -289,3 +289,25 @@ Function docBmxFile( filePath$,docPath$ )
 	Next
 	
 End Function
+
+Function BuildProtoId:String(proto:String)
+	' function-stripdir-path"
+	Local s:String
+	Local previousIdentChar:Int = False
+	For Local n:Int = EachIn proto.Trim()
+		If IsProtoIdentChar(n) Then
+			s :+ Chr(n)
+			previousIdentChar = True
+		Else
+			If previousIdentChar Then
+				s :+ "-"
+			End If
+			previousIdentChar = False
+		End If
+	Next
+	If s.EndsWith("-") Then
+		s = s[..s.Length-1]
+	End If
+	
+	Return s.ToLower()
+End Function

+ 8 - 0
src/makedocs/parse.bmx

@@ -5,6 +5,10 @@ Function IsAlphaChar( char )
 	Return (char>=Asc("A") And char<=Asc("Z")) Or (char>=Asc("a") And char<=Asc("z")) Or (char=Asc("_"))
 End Function
 
+Function IsProtoAlphaChar( char )
+	Return (char>=Asc("A") And char<=Asc("Z")) Or (char>=Asc("a") And char<=Asc("z"))
+End Function
+
 Function IsDecChar( char )
 	Return (char>=Asc("0") And char<=Asc("9"))
 End Function
@@ -13,6 +17,10 @@ Function IsIdentChar( char )
 	Return IsAlphaChar( char ) Or IsDecChar( char )
 End Function
 
+Function IsProtoIdentChar( char )
+	Return IsProtoAlphaChar( char ) Or IsDecChar( char )
+End Function
+
 Function IsHexChar( char )
 	Return IsDecChar( char ) Or (char>=Asc("A") And char<=Asc("F")) Or (char>=Asc("a") And char<=Asc("f"))
 End Function