LuaDocumentation - some simplifying of code
This commit is contained in:
parent
05c08806d1
commit
83671539d1
|
@ -54,42 +54,56 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public class LibraryFunction
|
public class LibraryFunction
|
||||||
{
|
{
|
||||||
private readonly string _returnType = string.Empty;
|
private readonly LuaMethodAttributes _luaAttributes;
|
||||||
|
private readonly MethodInfo _method;
|
||||||
|
|
||||||
public LibraryFunction(string methodLib, string methodName, MethodInfo method, string description)
|
public LibraryFunction(string library, string libraryDescription, MethodInfo method)
|
||||||
{
|
{
|
||||||
Library = methodLib;
|
_luaAttributes = method.GetCustomAttributes(typeof(LuaMethodAttributes), false)
|
||||||
Name = methodName;
|
.First() as LuaMethodAttributes;
|
||||||
var info = method.GetParameters();
|
_method = method;
|
||||||
|
|
||||||
Parameters = new List<string>();
|
Library = library;
|
||||||
|
LibraryDescription = libraryDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Library { get; private set; }
|
||||||
|
public string LibraryDescription { get; private set; }
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _luaAttributes.Name; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> Parameters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var info = _method.GetParameters();
|
||||||
foreach (var p in info)
|
foreach (var p in info)
|
||||||
{
|
{
|
||||||
Parameters.Add(p.ToString());
|
yield return p.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_returnType = method.ReturnType.ToString();
|
public string Description
|
||||||
|
{
|
||||||
Description = description;
|
get { return _luaAttributes.Description; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Library { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public List<string> Parameters { get; set; }
|
|
||||||
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string LibraryDescription { get; set; }
|
|
||||||
|
|
||||||
public string ParameterList
|
public string ParameterList
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
var parameters = Parameters.ToList();
|
||||||
|
|
||||||
var list = new StringBuilder();
|
var list = new StringBuilder();
|
||||||
list.Append('(');
|
list.Append('(');
|
||||||
for (var i = 0; i < Parameters.Count; i++)
|
for (var i = 0; i < parameters.Count; i++)
|
||||||
{
|
{
|
||||||
var param =
|
var param =
|
||||||
Parameters[i].Replace("System", string.Empty)
|
parameters[i].Replace("System", string.Empty)
|
||||||
.Replace(" ", string.Empty)
|
.Replace(" ", string.Empty)
|
||||||
.Replace(".", string.Empty)
|
.Replace(".", string.Empty)
|
||||||
.Replace("LuaInterface", string.Empty)
|
.Replace("LuaInterface", string.Empty)
|
||||||
|
@ -116,7 +130,7 @@ namespace BizHawk.Client.Common
|
||||||
.Replace("DrawingColor", "Color ");
|
.Replace("DrawingColor", "Color ");
|
||||||
|
|
||||||
list.Append(param);
|
list.Append(param);
|
||||||
if (i < Parameters.Count - 1)
|
if (i < parameters.Count - 1)
|
||||||
{
|
{
|
||||||
list.Append(", ");
|
list.Append(", ");
|
||||||
}
|
}
|
||||||
|
@ -132,7 +146,9 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _returnType
|
var returnType = _method.ReturnType.ToString();
|
||||||
|
|
||||||
|
return returnType
|
||||||
.Replace("System.", string.Empty)
|
.Replace("System.", string.Empty)
|
||||||
.Replace("LuaInterface.", string.Empty)
|
.Replace("LuaInterface.", string.Empty)
|
||||||
.ToLower()
|
.ToLower()
|
||||||
|
|
|
@ -49,10 +49,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
if (docs != null)
|
if (docs != null)
|
||||||
{
|
{
|
||||||
docs.Add(new LibraryFunction(Name, luaMethodAttr.Name, method, luaMethodAttr.Description)
|
docs.Add(new LibraryFunction(Name, callingLibrary.Description(), method));
|
||||||
{
|
|
||||||
LibraryDescription = callingLibrary.Description()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue