mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
add expanded documentation info upon hovering over a function
This commit is contained in:
parent
ba4d29d28d
commit
bd333e5e67
2 changed files with 115 additions and 13 deletions
|
@ -17,6 +17,13 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
public String mDocString = new String(256) ~ delete _;
|
public String mDocString = new String(256) ~ delete _;
|
||||||
public String mBriefString ~ delete _;
|
public String mBriefString ~ delete _;
|
||||||
|
public String mAuthorString ~ delete _;
|
||||||
|
public String mReturnString ~ delete _;
|
||||||
|
public String mRemarksString ~ delete _;
|
||||||
|
public String mNoteString ~ delete _;
|
||||||
|
public String mTODOString ~ delete _;
|
||||||
|
public String mSeeAlsoString ~ delete _;
|
||||||
|
public String mVersionString ~ delete _;
|
||||||
public Dictionary<String, String> mParamInfo ~ DeleteDictionaryAndKeysAndValues!(_);
|
public Dictionary<String, String> mParamInfo ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||||
|
|
||||||
public String ShowDocString
|
public String ShowDocString
|
||||||
|
@ -37,6 +44,24 @@ namespace IDE.ui
|
||||||
bool lineHadContent = false;
|
bool lineHadContent = false;
|
||||||
String curDocStr = null;
|
String curDocStr = null;
|
||||||
|
|
||||||
|
// Helper function to support adding various documentation strings without bloating code size
|
||||||
|
[System.Inline]
|
||||||
|
void AddPragma(ref String resultString, StringView pragma, StringSplitEnumerator splitEnum)
|
||||||
|
{
|
||||||
|
if (resultString == null)
|
||||||
|
resultString = new String(pragma.Length);
|
||||||
|
else if (resultString != null)
|
||||||
|
{
|
||||||
|
if (!resultString[resultString.Length - 1].IsWhiteSpace)
|
||||||
|
resultString.Append(" ");
|
||||||
|
}
|
||||||
|
var briefStr = StringView(pragma, splitEnum.MatchPos + 1);
|
||||||
|
briefStr.Trim();
|
||||||
|
resultString.Append(briefStr);
|
||||||
|
curDocStr = resultString;
|
||||||
|
lineHadContent = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (int idx = 0; idx < info.Length; idx++)
|
for (int idx = 0; idx < info.Length; idx++)
|
||||||
{
|
{
|
||||||
char8 c = info[idx];
|
char8 c = info[idx];
|
||||||
|
@ -128,24 +153,43 @@ namespace IDE.ui
|
||||||
if (mParamInfo == null)
|
if (mParamInfo == null)
|
||||||
mParamInfo = new .();
|
mParamInfo = new .();
|
||||||
curDocStr = new String(pragma, Math.Min(splitEnum.MatchPos + 1, pragma.Length));
|
curDocStr = new String(pragma, Math.Min(splitEnum.MatchPos + 1, pragma.Length));
|
||||||
|
curDocStr.Trim();
|
||||||
|
|
||||||
mParamInfo[new String(paramName)] = curDocStr;
|
mParamInfo[new String(paramName)] = curDocStr;
|
||||||
lineHadContent = true;
|
lineHadContent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pragmaName == "brief")
|
else if (pragmaName == "brief")
|
||||||
{
|
{
|
||||||
if (mBriefString == null)
|
AddPragma(ref mBriefString, pragma, splitEnum);
|
||||||
mBriefString = new String(pragma.Length);
|
}
|
||||||
else if (mBriefString != null)
|
else if (pragmaName == "author")
|
||||||
{
|
{
|
||||||
if (!mBriefString[mBriefString.Length - 1].IsWhiteSpace)
|
AddPragma(ref mAuthorString, pragma, splitEnum);
|
||||||
mBriefString.Append(" ");
|
}
|
||||||
}
|
else if (pragmaName == "return" || pragmaName == "retVal")
|
||||||
var briefStr = StringView(pragma, splitEnum.MatchPos + 1);
|
{
|
||||||
briefStr.Trim();
|
AddPragma(ref mReturnString, pragma, splitEnum);
|
||||||
mBriefString.Append(briefStr);
|
}
|
||||||
curDocStr = mBriefString;
|
else if (pragmaName == "remarks")
|
||||||
lineHadContent = true;
|
{
|
||||||
|
AddPragma(ref mRemarksString, pragma, splitEnum);
|
||||||
|
}
|
||||||
|
else if (pragmaName == "note")
|
||||||
|
{
|
||||||
|
AddPragma(ref mNoteString, pragma, splitEnum);
|
||||||
|
}
|
||||||
|
else if (pragmaName == "todo" || pragmaName == "TODO")
|
||||||
|
{
|
||||||
|
AddPragma(ref mTODOString, pragma, splitEnum);
|
||||||
|
}
|
||||||
|
else if (pragmaName == "see")
|
||||||
|
{
|
||||||
|
AddPragma(ref mSeeAlsoString, pragma, splitEnum);
|
||||||
|
}
|
||||||
|
else if (pragmaName == "version")
|
||||||
|
{
|
||||||
|
AddPragma(ref mVersionString, pragma, splitEnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1262,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (docParser.mParamInfo != null)
|
if (docParser.mParamInfo != null)
|
||||||
{
|
{
|
||||||
if (docParser.mParamInfo.TryGetValue(scope String(paramName), var paramDoc))
|
if (docParser.mParamInfo.TryGetValue(scope String(paramName), var paramDoc) || paramName.IsEmpty)
|
||||||
{
|
{
|
||||||
curY += font.GetLineSpacing() + GS!(4);
|
curY += font.GetLineSpacing() + GS!(4);
|
||||||
if (g != null)
|
if (g != null)
|
||||||
|
|
|
@ -5627,6 +5627,64 @@ namespace IDE.ui
|
||||||
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
debugExpr.Append(showString);
|
debugExpr.Append(showString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display Author if there is one documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mAuthorString))
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"Author: {docParser.mAuthorString}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display version if there is any documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mTODOString))
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"Version: {docParser.mVersionString}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display remarks if there is any documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mRemarksString))
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"Remarks: {docParser.mRemarksString}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display note if there is any documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mNoteString))
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"Note: {docParser.mNoteString}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display todo if there is any documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mTODOString))
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"TODO: {docParser.mTODOString}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display all parameters on hover
|
||||||
|
if (docParser.mParamInfo.Count > 0)
|
||||||
|
{
|
||||||
|
debugExpr.Append("\n");
|
||||||
|
debugExpr.Append("Parameters:");
|
||||||
|
|
||||||
|
for (var param in docParser.mParamInfo)
|
||||||
|
{
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"{param.key} {param.value}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display Return value if there is one documented
|
||||||
|
if (!String.IsNullOrEmpty(docParser.mReturnString))
|
||||||
|
{
|
||||||
|
debugExpr.Append("\n");
|
||||||
|
debugExpr.Append("Returns:");
|
||||||
|
|
||||||
|
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||||
|
debugExpr.Append(scope $"{docParser.mReturnString}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue