Quellcode durchsuchen

added haxedoc -v to list api incompatibilities resulting in duplicates entries in merged API

Nicolas Cannasse vor 13 Jahren
Ursprung
Commit
9a3f43a666
5 geänderte Dateien mit 31 neuen und 21 gelöschten Zeilen
  1. 1 1
      doc/release.neko
  2. 3 2
      std/haxe/macro/Context.hx
  3. 18 16
      std/haxe/rtti/XmlParser.hx
  4. 2 2
      std/js/_std/HxOverrides.hx
  5. 7 0
      std/tools/haxedoc/Main.hx

+ 1 - 1
doc/release.neko

@@ -50,7 +50,7 @@ chdir(dir+"/std/tools");
 
 chdir("haxedoc");
 cmd("haxe haxedoc.hxml");
-cmd(curdir+"haxedoc \"../../../../flash8.xml;flash8;flash\" \"../../../../neko.xml;neko\" \"../../../../js.xml;js\" \"../../../../flash9.xml;flash\" \"../../../../php.xml;php\" \"../../../../cpp.xml;cpp\" \"../../../../cs.xml;cs\" \"../../../../java.xml;java\"");
+cmd(curdir+"haxedoc -v \"../../../../flash8.xml;flash8;flash\" \"../../../../neko.xml;neko\" \"../../../../js.xml;js\" \"../../../../flash9.xml;flash\" \"../../../../php.xml;php\" \"../../../../cpp.xml;cpp\" \"../../../../cs.xml;cs\" \"../../../../java.xml;java\"");
 cmd("mv index.html content ../../../doc");
 cmd("mv haxedoc"+binext+" ../../..");
 chdir("..");

+ 3 - 2
std/haxe/macro/Context.hx

@@ -28,6 +28,7 @@ import haxe.macro.Expr;
 /**
 	This is an API that can be used by macros implementations.
 **/
+#if !neko @:noDoc #end
 class Context {
 
 #if neko
@@ -93,13 +94,13 @@ class Context {
 
 	/**
 		Returns the name of the method from which the macro was called
-	**/	
+	**/
 	public static function getLocalMethod() : Null<String> {
 		var l : String = load("local_method", 0)();
 		if (l == "") return null;
 		return l;
 	}
-	
+
 	/**
 		Tells is the given compiler directive has been defined with -D
 	**/

+ 18 - 16
std/haxe/rtti/XmlParser.hx

@@ -61,13 +61,6 @@ class XmlParser {
 			}
 	}
 
-	function simplifyDoc(d:String) {
-		if( d == null ) return null;
-		// don't take newline differences or extra spaces into account
-		d = d.split("\r\n").join("\n").split("\r").join("\n");
-		return StringTools.trim(d);
-	}
-
 	function sortFields(fl) {
 		var a = Lambda.array(fl);
 		a.sort(function(f1 : ClassField,f2 : ClassField) {
@@ -103,8 +96,19 @@ class XmlParser {
 		return false;
 	}
 
+	function mergeDoc( f1 : ClassField, f2 : ClassField ) {
+		if( f1.doc == null )
+			f2.doc = f2.doc;
+		else if( f2.doc == null )
+			f2.doc = f1.doc;
+		return true;
+	}
+
 	function mergeFields( f : ClassField, f2 : ClassField ) {
-		return TypeApi.fieldEq(f,f2) || (f.name == f2.name && (mergeRights(f,f2) || mergeRights(f2,f)) && TypeApi.fieldEq(f,f2));
+		return TypeApi.fieldEq(f,f2) || (f.name == f2.name && (mergeRights(f,f2) || mergeRights(f2,f)) && mergeDoc(f,f2) && TypeApi.fieldEq(f,f2));
+	}
+
+	public dynamic function newField( c : Classdef, f : ClassField ) {
 	}
 
 	function mergeClasses( c : Classdef, c2 : Classdef ) {
@@ -123,9 +127,10 @@ class XmlParser {
 					found = f;
 					break;
 				}
-			if( found == null )
+			if( found == null ) {
+				newField(c,f2);
 				c.fields.add(f2);
-			else if( curplatform != null )
+			} else if( curplatform != null )
 				found.platforms.add(curplatform);
 		}
 		for( f2 in c2.statics ) {
@@ -135,9 +140,10 @@ class XmlParser {
 					found = f;
 					break;
 				}
-			if( found == null )
+			if( found == null ) {
+				newField(c,f2);
 				c.statics.add(f2);
-			else if( curplatform != null )
+			} else if( curplatform != null )
 				found.platforms.add(curplatform);
 		}
 		return true;
@@ -212,10 +218,6 @@ class XmlParser {
 					else
 						tinf.doc = inf.doc;
 				}
-				if( tinf.doc != inf.doc ) {
-					tinf.doc = simplifyDoc(tinf.doc);
-					inf.doc = simplifyDoc(inf.doc);
-				}
 				if( tinf.module == inf.module && tinf.doc == inf.doc && tinf.isPrivate == inf.isPrivate )
 					switch( ct ) {
 					case TClassdecl(c):

+ 2 - 2
std/js/_std/HxOverrides.hx

@@ -23,10 +23,10 @@
  * DAMAGE.
  */
 
-/**
+/*
  * Static methods that override calls to built-in JS methods.
- * @private
  */
+@:noDoc
 class HxOverrides {
 
 	static function dateStr( date :Date ) : String {

+ 7 - 0
std/tools/haxedoc/Main.hx

@@ -125,14 +125,21 @@ class Main {
 		} else {
 			var filter = false;
 			var filters = new List();
+			var pf = null;
 			for( x in neko.Sys.args() ) {
 				if( x == "-f" )
 					filter = true;
+				else if( x == "-v" )
+					parser.newField = function(c,f) {
+						if( f.isPublic && !f.isOverride && !c.isPrivate )
+							Sys.println("[API INCOMPATIBILITY] "+c.path+"."+f.name+" ["+pf+"]");
+					};
 				else if( filter ) {
 					filters.add(x);
 					filter = false;
 				} else {
 					var f = x.split(";");
+					pf = f[1];
 					loadFile(f[0],f[1],f[2]);
 				}
 			}