Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vscript documentation sorting #171

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions sp/src/vscript/vscript_squirrel.nut
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
static char g_Script_vscript_squirrel[] = R"vscript(
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
//
// Purpose:
//
// Purpose:
//
//=============================================================================//

Warning <- error;
Expand Down Expand Up @@ -452,20 +452,28 @@ if (developer)
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;
printfunc(name, doc)
matches.append( name );
}
}

return foundMatches;
if ( !matches.len() )
return 0;

matches.sort();

foreach( name in matches )
printfunc( name, docs[name] );

return 1;
}

function __Documentation::PrintHelp(pattern = "*")
Expand All @@ -474,12 +482,12 @@ if (developer)

// Have a specific order
if (!(
PrintMatchesInDocList( patternLower, DocumentedEnums, PrintEnum ) |
PrintMatchesInDocList( patternLower, DocumentedConsts, PrintConst ) |
PrintMatchesInDocList( patternLower, DocumentedClasses, PrintClass ) |
PrintMatchesInDocList( patternLower, DocumentedFuncs, PrintFunc ) |
PrintMatchesInDocList( patternLower, DocumentedMembers, PrintMember ) |
PrintMatchesInDocList( patternLower, DocumentedHooks, PrintHook )
PrintMatches( patternLower, DocumentedEnums, PrintEnum ) |
PrintMatches( patternLower, DocumentedConsts, PrintConst ) |
PrintMatches( patternLower, DocumentedClasses, PrintClass ) |
PrintMatches( patternLower, DocumentedFuncs, PrintFunc ) |
PrintMatches( patternLower, DocumentedMembers, PrintMember ) |
PrintMatches( patternLower, DocumentedHooks, PrintHook )
))
{
printdocl("Pattern " + pattern + " not found");
Expand All @@ -503,7 +511,6 @@ else

if (developer)
{
// Vector documentation
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
__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." );
Expand Down