Browse Source

[xml] fix API doc generation (#10946)

* [xml] don't generate static/@:from/@:to fields if @:noDoc is present
* [doc] fix API doc generation for java's haxe.Rest
Rudy Ges 2 years ago
parent
commit
0d62f64e23
2 changed files with 6 additions and 6 deletions
  1. 4 4
      src/codegen/genxml.ml
  2. 2 2
      std/java/_std/haxe/Rest.hx

+ 4 - 4
src/codegen/genxml.ml

@@ -216,7 +216,7 @@ let rec gen_type_decl com pos t =
 	match t with
 	match t with
 	| TClassDecl c ->
 	| TClassDecl c ->
 		let stats = List.filter (fun cf ->
 		let stats = List.filter (fun cf ->
-			cf.cf_name <> "__meta__" && not (Meta.has Meta.GenericInstance cf.cf_meta)
+			cf.cf_name <> "__meta__" && not (Meta.has Meta.GenericInstance cf.cf_meta) && not (Meta.has Meta.NoDoc cf.cf_meta)
 		) c.cl_ordered_statics in
 		) c.cl_ordered_statics in
 		let stats = List.map (gen_field ["static","1"]) stats in
 		let stats = List.map (gen_field ["static","1"]) stats in
 		let fields = List.filter (fun cf ->
 		let fields = List.filter (fun cf ->
@@ -253,9 +253,9 @@ let rec gen_type_decl com pos t =
 		let doc = gen_doc_opt a.a_doc in
 		let doc = gen_doc_opt a.a_doc in
 		let meta = gen_meta a.a_meta in
 		let meta = gen_meta a.a_meta in
 		let mk_cast t = node "icast" [] [gen_type t] in
 		let mk_cast t = node "icast" [] [gen_type t] in
-		let mk_field_cast (t,cf) = node "icast" ["field",cf.cf_name] [gen_type t] in
-		let sub = (match a.a_from,a.a_from_field with [],[] -> [] | l1,l2 -> [node "from" [] ((List.map mk_cast l1) @ (List.map mk_field_cast l2))]) in
-		let super = (match a.a_to,a.a_to_field with [],[] -> [] | l1,l2 -> [node "to" [] ((List.map mk_cast l1) @ (List.map mk_field_cast l2))]) in
+		let mk_field_cast (t,cf) = if Meta.has Meta.NoDoc cf.cf_meta then None else Some (node "icast" ["field",cf.cf_name] [gen_type t]) in
+		let sub = (match a.a_from,a.a_from_field with [],[] -> [] | l1,l2 -> [node "from" [] ((List.map mk_cast l1) @ (ExtList.List.filter_map mk_field_cast l2))]) in
+		let super = (match a.a_to,a.a_to_field with [],[] -> [] | l1,l2 -> [node "to" [] ((List.map mk_cast l1) @ (ExtList.List.filter_map mk_field_cast l2))]) in
 		let impl = (match a.a_impl with None -> [] | Some c -> [node "impl" [] [gen_type_decl com pos (TClassDecl c)]]) in
 		let impl = (match a.a_impl with None -> [] | Some c -> [node "impl" [] [gen_type_decl com pos (TClassDecl c)]]) in
 		let this = [node "this" [] [gen_type a.a_this]] in
 		let this = [node "this" [] [gen_type a.a_this]] in
 		node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_params a.a_pos m) (sub @ this @ super @ doc @ meta @ impl)
 		node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_params a.a_pos m) (sub @ this @ super @ doc @ meta @ impl)

+ 2 - 2
std/java/_std/haxe/Rest.hx

@@ -37,11 +37,11 @@ abstract Rest<T>(NativeRest<T>) {
 		return new Rest(cast result);
 		return new Rest(cast result);
 	}
 	}
 
 
-	@:dox(hide)
+	@:noDoc
 	@:from static function ofNativeInt(collection:NativeArray<Int>):Rest<Int>
 	@:from static function ofNativeInt(collection:NativeArray<Int>):Rest<Int>
 		return ofNativePrimitive(new NativeRest<java.lang.Integer>(collection.length), collection);
 		return ofNativePrimitive(new NativeRest<java.lang.Integer>(collection.length), collection);
 
 
-	@:dox(hide)
+	@:noDoc
 	@:from static function ofNativeFloat(collection:NativeArray<Float>):Rest<Float>
 	@:from static function ofNativeFloat(collection:NativeArray<Float>):Rest<Float>
 		return ofNativePrimitive(new NativeRest<java.lang.Double>(collection.length), collection);
 		return ofNativePrimitive(new NativeRest<java.lang.Double>(collection.length), collection);