Added types for Utility documentation output
This commit is contained in:
@@ -17,6 +17,7 @@ using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.UtilityCommands.Documentation.Objects;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
@@ -54,10 +55,10 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
|
||||
var sequenceTypesInfo = sequenceTypes
|
||||
.Where(x => !x.ContainsGenericParameters && !x.IsAbstract)
|
||||
.Select(type => new
|
||||
.Select(type => new ExtractedClassInfo
|
||||
{
|
||||
type.Namespace,
|
||||
type.Name,
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name,
|
||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||
Filename = Utilities.GetSourceFilenameFromPdb(type, pdbReaderCache),
|
||||
InheritedTypes = type.BaseTypes()
|
||||
@@ -82,7 +83,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
if (defaultValueField != null && defaultValueField.FieldType.IsEnum)
|
||||
relatedEnumTypes.Add(defaultValueField.FieldType);
|
||||
|
||||
return new
|
||||
return new ExtractedClassFieldInfo
|
||||
{
|
||||
PropertyName = key,
|
||||
DefaultValue = defaultValue?.ToString(),
|
||||
@@ -93,15 +94,11 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
})
|
||||
});
|
||||
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new ExtractedEnumInfo
|
||||
{
|
||||
type.Namespace,
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name,
|
||||
Values = Enum.GetNames(type).ToDictionary(x => Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo), y => y)
|
||||
});
|
||||
|
||||
var result = new
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using OpenRA.Mods.Common.UtilityCommands.Documentation.Objects;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -52,9 +53,9 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
|
||||
var traitTypesInfo = traitTypes
|
||||
.Where(x => !x.ContainsGenericParameters && !x.IsAbstract)
|
||||
.Select(type => new
|
||||
.Select(type => new ExtractedTraitInfo
|
||||
{
|
||||
type.Namespace,
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||
Filename = Utilities.GetSourceFilenameFromPdb(type, pdbReaderCache),
|
||||
@@ -70,7 +71,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
if (fi.Field.FieldType.IsEnum)
|
||||
relatedEnumTypes.Add(fi.Field.FieldType);
|
||||
|
||||
return new
|
||||
return new ExtractedClassFieldInfo
|
||||
{
|
||||
PropertyName = fi.YamlName,
|
||||
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
||||
@@ -84,13 +85,13 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
var name = a.AttributeType.Name;
|
||||
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||
|
||||
return new
|
||||
return new ExtractedClassFieldAttributeInfo
|
||||
{
|
||||
Name = name,
|
||||
Parameters = a.Constructor.GetParameters()
|
||||
.Select(pi => new
|
||||
.Select(pi => new ExtractedClassFieldAttributeInfo.Parameter
|
||||
{
|
||||
pi.Name,
|
||||
Name = pi.Name,
|
||||
Value = Util.GetAttributeParameterValue(a.ConstructorArguments[pi.Position])
|
||||
})
|
||||
};
|
||||
@@ -99,15 +100,11 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
})
|
||||
});
|
||||
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new ExtractedEnumInfo
|
||||
{
|
||||
type.Namespace,
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name,
|
||||
Values = Enum.GetNames(type).ToDictionary(x => Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo), y => y)
|
||||
});
|
||||
|
||||
var result = new
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.UtilityCommands.Documentation.Objects;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -57,9 +58,9 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
|
||||
var weaponTypesInfo = weaponTypes
|
||||
.Where(x => !x.ContainsGenericParameters && !x.IsAbstract)
|
||||
.Select(type => new
|
||||
.Select(type => new ExtractedClassInfo
|
||||
{
|
||||
type.Namespace,
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||
Filename = Utilities.GetSourceFilenameFromPdb(type, pdbReaderCache),
|
||||
@@ -73,7 +74,7 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
if (fi.Field.FieldType.IsEnum)
|
||||
relatedEnumTypes.Add(fi.Field.FieldType);
|
||||
|
||||
return new
|
||||
return new ExtractedClassFieldInfo
|
||||
{
|
||||
PropertyName = fi.YamlName,
|
||||
DefaultValue = FieldSaver.SaveField(objectCreator.CreateBasic(type), fi.Field.Name).Value.Value,
|
||||
@@ -87,13 +88,13 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
var name = a.AttributeType.Name;
|
||||
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||
|
||||
return new
|
||||
return new ExtractedClassFieldAttributeInfo
|
||||
{
|
||||
Name = name,
|
||||
Parameters = a.Constructor.GetParameters()
|
||||
.Select(pi => new
|
||||
.Select(pi => new ExtractedClassFieldAttributeInfo.Parameter
|
||||
{
|
||||
pi.Name,
|
||||
Name = pi.Name,
|
||||
Value = Util.GetAttributeParameterValue(a.ConstructorArguments[pi.Position])
|
||||
})
|
||||
};
|
||||
@@ -102,15 +103,11 @@ namespace OpenRA.Mods.Common.UtilityCommands.Documentation
|
||||
})
|
||||
});
|
||||
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new
|
||||
var relatedEnums = relatedEnumTypes.OrderBy(t => t.Name).Select(type => new ExtractedEnumInfo
|
||||
{
|
||||
type.Namespace,
|
||||
type.Name,
|
||||
Values = Enum.GetNames(type).Select(x => new
|
||||
{
|
||||
Key = Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo),
|
||||
Value = x
|
||||
})
|
||||
Namespace = type.Namespace,
|
||||
Name = type.Name,
|
||||
Values = Enum.GetNames(type).ToDictionary(x => Convert.ToInt32(Enum.Parse(type, x), NumberFormatInfo.InvariantInfo), y => y)
|
||||
});
|
||||
|
||||
var result = new
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
|
||||
{
|
||||
public class ExtractedClassFieldAttributeInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public IEnumerable<Parameter> Parameters { get; set; }
|
||||
|
||||
public class Parameter
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
|
||||
{
|
||||
public class ExtractedClassFieldInfo
|
||||
{
|
||||
public string PropertyName { get; set; }
|
||||
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
public string InternalType { get; set; }
|
||||
|
||||
public string UserFriendlyType { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public IEnumerable<ExtractedClassFieldAttributeInfo> OtherAttributes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
|
||||
{
|
||||
public class ExtractedClassInfo
|
||||
{
|
||||
public string Namespace { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Filename { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public IEnumerable<string> InheritedTypes { get; set; }
|
||||
|
||||
public IEnumerable<ExtractedClassFieldInfo> Properties { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
|
||||
{
|
||||
public record ExtractedEnumInfo
|
||||
{
|
||||
public string Namespace { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public IDictionary<int, string> Values { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands.Documentation.Objects
|
||||
{
|
||||
public class ExtractedTraitInfo : ExtractedClassInfo
|
||||
{
|
||||
public IEnumerable<string> RequiresTraits { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user