Added filenames to enum documentation

This commit is contained in:
Pavel Penev
2025-04-27 22:06:18 +03:00
committed by Gustas Kažukauskas
parent 3f53abc4c4
commit f590e806a1
5 changed files with 8 additions and 4 deletions

View File

@@ -68,12 +68,14 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
});
}
public static IEnumerable<ExtractedEnumInfo> GetRelatedEnumInfos(HashSet<Type> relatedEnumTypes)
public static IEnumerable<ExtractedEnumInfo> GetRelatedEnumInfos(
HashSet<Type> relatedEnumTypes, Cache<string, IReadOnlyDictionary<string, ImmutableArray<string>>> pdbTypesCache)
{
return relatedEnumTypes.OrderBy(t => t.Name).Select(type => new ExtractedEnumInfo
{
Namespace = type.Namespace,
Name = type.Name,
Filename = GetSourceFilenameForType(type, pdbTypesCache),
Values = Enum.GetNames(type).ToDictionary(x => Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo), y => y)
});
}

View File

@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
{
Version = version,
SpriteSequenceTypes = sequenceTypesInfo,
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes)
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes, pdbTypesCache)
};
return JsonSerializer.Serialize(result);

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
{
Version = version,
TraitInfos = traitTypesInfo,
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes)
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes, pdbTypesCache)
};
return JsonSerializer.Serialize(result);

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
{
Version = version,
WeaponTypes = weaponTypesInfo,
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes)
RelatedEnums = DocumentationHelpers.GetRelatedEnumInfos(relatedEnumTypes, pdbTypesCache)
};
return JsonSerializer.Serialize(result);

View File

@@ -19,6 +19,8 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
public string Name { get; set; }
public string Filename { get; set; }
public IDictionary<int, string> Values { get; set; }
}
}