Skip to content

Commit

Permalink
Don't include internal members (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
karimi authored Oct 23, 2024
1 parent acd029a commit 0b8f443
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/Parse/JsonBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,12 @@ static string WriteTypeAsObject(ParsedType type, Dictionary<string, ParsedType>
sb.Append(KeyValString(4, "deprecated", type.Deprecated, asJavascript));
}
//Morteza: debugging only
if (type.FullName == "Rhino.Geometry.SubDToBrepOptions"){
if (type.FullName == "Rhino.DocObjects.RhinoObject"){
var inspecting = type;
}
string delegates = MembersAsJsonArray(type, ParsedMemberType.Delegate, asJavascript);
string values = MembersAsJsonArray(type, ParsedMemberType.EnumValue, asJavascript);
string constructors = MembersAsJsonArray(type, ParsedMemberType.Constructor, asJavascript);
if (constructors==null){
//Try to add default constructor
constructors = DefaultConstructorAsJson(type, asJavascript);
}
string properties = MembersAsJsonArray(type, ParsedMemberType.Property, asJavascript);
string methods = MembersAsJsonArray(type, ParsedMemberType.Method, asJavascript);
string events = MembersAsJsonArray(type, ParsedMemberType.Event, asJavascript);
Expand Down Expand Up @@ -569,6 +565,7 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool
StringBuilder sb = new StringBuilder();
sb.AppendLine("[");
bool memberAdded = false;
bool internalConstructorSkipped = false;
foreach (var member in type.Members)
{
if (filter == ParsedMemberType.Property && member.MemberType == ParsedMemberType.Indexer){
Expand All @@ -578,6 +575,11 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool
if (filter != member.MemberType)
continue;
}
if (member.IsInternal){
if (member.MemberType == ParsedMemberType.Constructor)
internalConstructorSkipped = true;
continue;
}
if (memberAdded)
sb.AppendLine(",");
sb.AppendLine(" {");
Expand All @@ -589,6 +591,11 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool
sb.AppendLine();
sb.Append(" ]");

if (!memberAdded && filter == ParsedMemberType.Constructor){
if (!internalConstructorSkipped)
return DefaultConstructorAsJson(type, asJavascript);
}

return memberAdded ? sb.ToString() : null;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ static void Docify(string projDir, string examplesDir, string outputDir)
}
foreach (var parsedItem in parsedItems)
{
if (parsedItem.Signature(false).Contains("RhinoObject()")){
var inspecting = parsedItem;
}
if (!parsedItem.ParentIsPublic)
continue;
if (!parsedItem.IsPublic && !parsedItem.IsProtected)
if (!parsedItem.IsPublic && !parsedItem.IsProtected && !parsedItem.IsInternal) //We'll skip the internal members when we write the json, we need to know if a constructor is internal so we don't write default constructor
continue;
if (parsedItem.Signature(false).Contains("explodeNestedInstances")){
var inspecting = parsedItem;
}
string className = parsedItem.ClassPath;
if (className != null){
if (!allMembers.ContainsKey(className))
Expand Down

0 comments on commit 0b8f443

Please sign in to comment.