Przeglądaj źródła

fixed : parenthesis for function-arg

Nicolas Cannasse 19 lat temu
rodzic
commit
0ef859baa9
1 zmienionych plików z 11 dodań i 2 usunięć
  1. 11 2
      std/tools/haxedoc/HtmlPrinter.hx

+ 11 - 2
std/tools/haxedoc/HtmlPrinter.hx

@@ -374,10 +374,10 @@ class HtmlPrinter {
 				if( a.opt )
 					print("?");
 				print(a.name+" : ");
-				processType(a.t);
+				processTypeFun(a.t,true);
 				print(" -> ");
 			}
-			processType(ret);
+			processTypeFun(ret,false);
 		case TAnonymous(fields):
 			print("{ ");
 			var me = this;
@@ -397,6 +397,15 @@ class HtmlPrinter {
 		}
 	}
 	
+	function processTypeFun( t : Type, isArg ) {
+		var parent =  switch( t ) { case TFunction(_,_): true; case TEnum(n,_): isArg && n == "Void"; default : false; };
+		if( parent )
+			print("(");
+		processType(t);
+		if( parent )
+			print(")");		
+	}
+	
 	function rightsStr(r) {
 		return switch(r) {
 		case RNormal: "default";