Skip to content

Commit

Permalink
fully qualified names for anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdruppe committed Feb 19, 2012
1 parent 763f118 commit 654d39f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/doc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ DDOC_PARAM_ID = $(TD $0)\n\
DDOC_PARAM_DESC = $(TD $0)\n\ DDOC_PARAM_DESC = $(TD $0)\n\
DDOC_BLANKLINE = $(BR)$(BR)\n\ DDOC_BLANKLINE = $(BR)$(BR)\n\
\n\ \n\
DDOC_PSYMBOL = $(U $0)\n\ DDOC_PSYMBOL = $(U $1)\n\
DDOC_KEYWORD = $(B $0)\n\ DDOC_KEYWORD = $(B $0)\n\
DDOC_PARAM = $(I $0)\n\ DDOC_PARAM = $(I $0)\n\
\n\ \n\
Expand Down Expand Up @@ -929,7 +929,7 @@ void AggregateDeclaration::toDocBuffer(OutBuffer *buf)
#if 0 #if 0
emitProtection(buf, protection); emitProtection(buf, protection);
#endif #endif
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars()); buf->printf("%s $(DDOC_PSYMBOL %s, %s)", kind(), toChars(), toPrettyChars());
buf->writestring(";\n"); buf->writestring(";\n");
} }
} }
Expand All @@ -953,7 +953,7 @@ void StructDeclaration::toDocBuffer(OutBuffer *buf)
} }
else else
{ {
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars()); buf->printf("%s $(DDOC_PSYMBOL %s, %s)", kind(), toChars(), toPrettyChars());
} }
buf->writestring(";\n"); buf->writestring(";\n");
} }
Expand All @@ -980,7 +980,7 @@ void ClassDeclaration::toDocBuffer(OutBuffer *buf)
{ {
if (isAbstract()) if (isAbstract())
buf->writestring("abstract "); buf->writestring("abstract ");
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars()); buf->printf("%s $(DDOC_PSYMBOL %s, %s)", kind(), toChars(), toPrettyChars());
} }
int any = 0; int any = 0;
for (size_t i = 0; i < baseclasses->dim; i++) for (size_t i = 0; i < baseclasses->dim; i++)
Expand Down Expand Up @@ -1017,7 +1017,7 @@ void EnumDeclaration::toDocBuffer(OutBuffer *buf)
{ {
if (ident) if (ident)
{ {
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars()); buf->printf("%s $(DDOC_PSYMBOL %s, %s)", kind(), toChars(), toPrettyChars());
buf->writestring(";\n"); buf->writestring(";\n");
} }
} }
Expand Down Expand Up @@ -1975,6 +1975,15 @@ void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset)
char *sid = s->ident->toChars(); char *sid = s->ident->toChars();
FuncDeclaration *f = s->isFuncDeclaration(); FuncDeclaration *f = s->isFuncDeclaration();


const char *fullyQualifiedName = s->toPrettyChars();
int total = strlen(fullyQualifiedName);
char *terminator = (char*) malloc(total + 3);
terminator[0] = ','; // end the first argument
strncpy(terminator + 1, fullyQualifiedName, total);
++total; // because of the comma
terminator[total] = ')'; // to close the DDOC_PSYMBOL macro
terminator[total + 1] = 0; // terminate the string

//printf("highlightCode(s = '%s', kind = %s)\n", sid, s->kind()); //printf("highlightCode(s = '%s', kind = %s)\n", sid, s->kind());
for (unsigned i = offset; i < buf->offset; i++) for (unsigned i = offset; i < buf->offset; i++)
{ unsigned char c = buf->data[i]; { unsigned char c = buf->data[i];
Expand All @@ -1988,7 +1997,7 @@ void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset)
{ {
if (cmp(sid, buf->data + i, j - i) == 0) if (cmp(sid, buf->data + i, j - i) == 0)
{ {
i = buf->bracket(i, "$(DDOC_PSYMBOL ", j, ")") - 1; i = buf->bracket(i, "$(DDOC_PSYMBOL ", j, terminator) - 1;
continue; continue;
} }
else if (f) else if (f)
Expand All @@ -2004,6 +2013,8 @@ void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset)
} }
} }
} }

free(terminator);
} }


/**************************************** /****************************************
Expand Down

0 comments on commit 654d39f

Please sign in to comment.