Add vscript documentation sorting

This commit is contained in:
samisalreadytaken 2022-01-14 22:47:00 +03:00
parent c25053d1d2
commit 9156ba84bd

View File

@ -452,20 +452,28 @@ if (developer)
printdocl(text); printdocl(text);
} }
local function PrintMatchesInDocList(pattern, list, printfunc) local function PrintMatches( pattern, docs, printfunc )
{ {
local foundMatches = 0; local matches = [];
local always = pattern == "*";
foreach(name, doc in list) foreach( name, doc in docs )
{ {
if (pattern == "*" || name.tolower().find(pattern) != null || (doc[1].len() && doc[1].tolower().find(pattern) != null)) if (always || name.tolower().find(pattern) != null || (doc[1].len() && doc[1].tolower().find(pattern) != null))
{ {
foundMatches = 1; matches.append( name );
printfunc(name, doc)
} }
} }
return foundMatches; if ( !matches.len() )
return 0;
matches.sort();
foreach( name in matches )
printfunc( name, docs[name] );
return 1;
} }
function __Documentation::PrintHelp(pattern = "*") function __Documentation::PrintHelp(pattern = "*")
@ -474,12 +482,12 @@ if (developer)
// Have a specific order // Have a specific order
if (!( if (!(
PrintMatchesInDocList( patternLower, DocumentedEnums, PrintEnum ) | PrintMatches( patternLower, DocumentedEnums, PrintEnum ) |
PrintMatchesInDocList( patternLower, DocumentedConsts, PrintConst ) | PrintMatches( patternLower, DocumentedConsts, PrintConst ) |
PrintMatchesInDocList( patternLower, DocumentedClasses, PrintClass ) | PrintMatches( patternLower, DocumentedClasses, PrintClass ) |
PrintMatchesInDocList( patternLower, DocumentedFuncs, PrintFunc ) | PrintMatches( patternLower, DocumentedFuncs, PrintFunc ) |
PrintMatchesInDocList( patternLower, DocumentedMembers, PrintMember ) | PrintMatches( patternLower, DocumentedMembers, PrintMember ) |
PrintMatchesInDocList( patternLower, DocumentedHooks, PrintHook ) PrintMatches( patternLower, DocumentedHooks, PrintHook )
)) ))
{ {
printdocl("Pattern " + pattern + " not found"); printdocl("Pattern " + pattern + " not found");
@ -503,7 +511,6 @@ else
if (developer) if (developer)
{ {
// Vector documentation
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." ); __Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
__Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." ); __Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
__Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." ); __Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );