Properly handle destructors as methods for autodoc and fix some stray newlines

This commit is contained in:
Alec Woods 2019-01-25 22:00:57 -05:00
commit 98023054c6
3 changed files with 20 additions and 1 deletions

View file

@ -1810,6 +1810,7 @@ public:
String *make_autodoc(Node *n, autodoc_t ad_type, bool low_level = false) {
int extended = 0;
bool first_func = true;
// If the function is overloaded then this function is called
// for the last one. Rewind to the first so the docstrings are
// in order.
@ -1861,6 +1862,9 @@ public:
continue;
}
if (! first_func)
Append(doc, "\n");
if (type) {
if (Strcmp(type, "void") == 0) {
type_str = NULL;
@ -1877,6 +1881,13 @@ public:
ad_type = AUTODOC_METHOD;
}
}
/* Treat destructors as methods for documentation purposes */
String *nodeType = Getattr(n, "nodeType");
if (nodeType && Strcmp(nodeType, "destructor") == 0) {
if (ad_type == AUTODOC_FUNC) {
ad_type = AUTODOC_METHOD;
}
}
switch (ad_type) {
case AUTODOC_CLASS:
@ -1980,7 +1991,7 @@ public:
// if it's overloaded then get the next decl and loop around again
n = Getattr(n, "sym:nextSibling");
if (n)
Append(doc, "\n");
first_func = false;
}
return doc;