- Implemented parsing for the `@return`
This commit is contained in:
Tristan B. Velloza Kildaire 2024-04-16 20:48:58 +02:00
parent ad67ce6309
commit 87ddafe304
1 changed files with 60 additions and 0 deletions

View File

@ -24,6 +24,11 @@ public struct ParamDoc
public struct ReturnsDoc
{
string description;
public string getDescription()
{
return this.description;
}
}
public struct ExceptionDoc
@ -233,6 +238,28 @@ private class CommentParser
}
}
bool parseReturn(ref string returnDescription)
{
string gotDescription;
bool foundDescription;
while(getch(c))
{
gotDescription ~= c;
prog;
foundDescription = true;
}
if(foundDescription)
{
returnDescription = gotDescription;
return true;
}
else
{
return false;
}
}
while(getch(c))
{
@ -268,6 +295,24 @@ private class CommentParser
return false;
}
}
// @return
else if (paramType == "return")
{
string returnDescr;
if(parseReturn(returnDescr))
{
DEBUG("hool");
DocStr tmp;
tmp.type = DocType.RETURNS;
tmp.content.returns = ReturnsDoc(returnDescr);
ds = tmp;
return true;
}
else
{
return false;
}
}
// Unknown @<thing>
else
{
@ -394,4 +439,19 @@ public final class Comment
return d;
}
public bool getReturnDoc(ref ReturnsDoc retDoc)
{
// TODO: Use niknaks flter
foreach(DocStr d; getDocStrings())
{
if(d.type == DocType.RETURNS)
{
retDoc = d.content.returns;
return true;
}
}
return false;
}
}