LuaDeprecatedMethod - documentation generation failed to filter it out, instead though mark it as depcreated in documentation, Lua functions list - fix column sorting, simplifications

This commit is contained in:
adelikat 2020-04-06 17:12:16 -05:00
parent 7ddf2e0f3b
commit a47f89582b
2 changed files with 21 additions and 49 deletions

View File

@ -40,7 +40,7 @@ __Types and notation__
** A standard Lua table
");
foreach (var library in this.Where(lf => !lf.IsDeprecated).Select(lf => new { Name = lf.Library, Description = lf.LibraryDescription }).Distinct())
foreach (var library in this.Select(lf => new { Name = lf.Library, Description = lf.LibraryDescription }).Distinct())
{
sb
.AppendFormat("%%TAB {0}%%", library.Name)
@ -56,10 +56,11 @@ __Types and notation__
foreach (var func in this.Where(lf => lf.Library == library.Name))
{
string deprecated = func.IsDeprecated ? "__[[deprecated]]__ " : "";
sb
.AppendFormat("__{0}.{1}__%%%", func.Library, func.Name)
.AppendLine().AppendLine()
.AppendFormat("* {0} {1}.{2}{3}", func.ReturnType, func.Library, func.Name, func.ParameterList.Replace("[", "[[").Replace("]", "]]"))
.AppendFormat("* {4}{0} {1}.{2}{3}", func.ReturnType, func.Library, func.Name, func.ParameterList.Replace("[", "[[").Replace("]", "]]"), deprecated)
.AppendLine().AppendLine()
.AppendFormat("* {0}", func.Description)
.AppendLine().AppendLine();
@ -158,13 +159,12 @@ __Types and notation__
{
private readonly LuaMethodAttribute _luaAttributes;
private readonly LuaMethodExampleAttribute _luaExampleAttribute;
private readonly MethodInfo _method;
public LibraryFunction(string library, string libraryDescription, MethodInfo method)
{
_luaAttributes = method.GetCustomAttribute<LuaMethodAttribute>(false);
_luaExampleAttribute = method.GetCustomAttribute<LuaMethodExampleAttribute>(false);
_method = method;
Method = method;
IsDeprecated = method.GetCustomAttribute<LuaDeprecatedMethodAttribute>(false) != null;
Library = library;
@ -176,7 +176,7 @@ __Types and notation__
public readonly bool IsDeprecated;
public MethodInfo Method => _method;
public MethodInfo Method { get; }
public string Name => _luaAttributes.Name;
@ -192,7 +192,7 @@ __Types and notation__
{
if (_parameterList == null)
{
var parameters = _method.GetParameters();
var parameters = Method.GetParameters();
var list = new StringBuilder();
list.Append('(');
@ -259,7 +259,7 @@ __Types and notation__
{
get
{
var returnType = _method.ReturnType.ToString();
var returnType = Method.ReturnType.ToString();
return TypeCleanup(returnType).Trim();
}
}

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common.CollectionExtensions;
namespace BizHawk.Client.EmuHawk
{
@ -54,7 +55,9 @@ namespace BizHawk.Client.EmuHawk
var entry = _filteredList[e.ItemIndex];
e.Item = new ListViewItem(entry.ReturnType);
e.Item.SubItems.Add(entry.Library);
e.Item.SubItems.Add(entry.Name);
var deprecated = entry.IsDeprecated ? "[Deprecated] " : "";
e.Item.SubItems.Add(deprecated + entry.Name);
e.Item.SubItems.Add(entry.ParameterList);
e.Item.SubItems.Add(entry.Description);
}
@ -62,48 +65,16 @@ namespace BizHawk.Client.EmuHawk
private void OrderColumn(int column)
{
_columnSort.Column = column;
if (_columnSort.Descending)
_functionList = column switch
{
switch (column)
{
case 0: // Return
_functionList = _functionList.OrderByDescending(x => x.ReturnType).ToList();
break;
case 1: // Library
_functionList = _functionList.OrderByDescending(x => x.Library).ToList();
break;
case 2: // Name
_functionList = _functionList.OrderByDescending(x => x.Name).ToList();
break;
case 3: // Parameters
_functionList = _functionList.OrderByDescending(x => x.ParameterList).ToList();
break;
case 4: // Description
_functionList = _functionList.OrderByDescending(x => x.Description).ToList();
break;
}
}
else
{
switch (column)
{
case 0: // Return
_functionList = _functionList.OrderBy(x => x.ReturnType).ToList();
break;
case 1: // Library
_functionList = _functionList.OrderBy(x => x.Library).ToList();
break;
case 2: // Name
_functionList = _functionList.OrderBy(x => x.Name).ToList();
break;
case 3: // Parameters
_functionList = _functionList.OrderBy(x => x.ParameterList).ToList();
break;
case 4: // Description
_functionList = _functionList.OrderBy(x => x.Description).ToList();
break;
}
}
0 => _functionList.OrderBy(x => x.ReturnType, _columnSort.Descending).ToList(),
1 => _functionList.OrderBy(x => x.Library, _columnSort.Descending).ToList(),
2 => _functionList.OrderBy(x => x.Name, _columnSort.Descending).ToList(),
3 => _functionList.OrderBy(x => x.ParameterList, _columnSort.Descending).ToList(),
4 => _functionList.OrderBy(x => x.Description, _columnSort.Descending).ToList(),
_ => _functionList
};
UpdateList();
}
@ -176,6 +147,7 @@ namespace BizHawk.Client.EmuHawk
{
GenerateFilteredList();
FunctionView.VirtualListSize = _filteredList.Count;
FunctionView.Refresh();
}
private void FilterBox_KeyUp(object sender, KeyEventArgs e)