Mercurial > projects > ldc
comparison dmd/doc.c @ 159:5acec6b2eef8 trunk
[svn r175] merged dmd 1.029
author | ChristianK |
---|---|
date | Thu, 01 May 2008 15:15:28 +0200 |
parents | a7dfa0ed966c |
children | aaade6ded589 |
comparison
equal
deleted
inserted
replaced
158:287540c5f05e | 159:5acec6b2eef8 |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | 2 // Compiler implementation of the D programming language |
3 // Copyright (c) 1999-2006 by Digital Mars | 3 // Copyright (c) 1999-2008 by Digital Mars |
4 // All Rights Reserved | 4 // All Rights Reserved |
5 // written by Walter Bright | 5 // written by Walter Bright |
6 // http://www.digitalmars.com | 6 // http://www.digitalmars.com |
7 // License for redistribution is by either the Artistic License | 7 // License for redistribution is by either the Artistic License |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | 8 // in artistic.txt, or the GNU General Public License in gnu.txt. |
100 int icmp(char *stringz, void *s, size_t slen); | 100 int icmp(char *stringz, void *s, size_t slen); |
101 int isDitto(unsigned char *comment); | 101 int isDitto(unsigned char *comment); |
102 unsigned char *skipwhitespace(unsigned char *p); | 102 unsigned char *skipwhitespace(unsigned char *p); |
103 unsigned skiptoident(OutBuffer *buf, unsigned i); | 103 unsigned skiptoident(OutBuffer *buf, unsigned i); |
104 unsigned skippastident(OutBuffer *buf, unsigned i); | 104 unsigned skippastident(OutBuffer *buf, unsigned i); |
105 unsigned skippastURL(OutBuffer *buf, unsigned i); | |
105 void highlightText(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); | 106 void highlightText(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); |
106 void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); | 107 void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); |
107 void highlightCode2(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); | 108 void highlightCode2(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset); |
108 Argument *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len); | 109 Argument *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len); |
109 | 110 |
112 <META http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\n\ | 113 <META http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\n\ |
113 <title>$(TITLE)</title>\n\ | 114 <title>$(TITLE)</title>\n\ |
114 </head><body>\n\ | 115 </head><body>\n\ |
115 <h1>$(TITLE)</h1>\n\ | 116 <h1>$(TITLE)</h1>\n\ |
116 $(BODY)\n\ | 117 $(BODY)\n\ |
117 <hr>$(SMALL Page generated by $(LINK2 http://www.digitalmars.com/d/ddoc.html, Ddoc). $(COPYRIGHT))\n\ | 118 <hr>$(SMALL Page generated by $(LINK2 http://www.digitalmars.com/d/1.0/ddoc.html, Ddoc). $(COPYRIGHT))\n\ |
118 </body></html>\n\ | 119 </body></html>\n\ |
119 \n\ | 120 \n\ |
120 B = <b>$0</b>\n\ | 121 B = <b>$0</b>\n\ |
121 I = <i>$0</i>\n\ | 122 I = <i>$0</i>\n\ |
122 U = <u>$0</u>\n\ | 123 U = <u>$0</u>\n\ |
369 * Emit doc comment to documentation file | 370 * Emit doc comment to documentation file |
370 */ | 371 */ |
371 | 372 |
372 void Dsymbol::emitDitto(Scope *sc) | 373 void Dsymbol::emitDitto(Scope *sc) |
373 { | 374 { |
375 //printf("Dsymbol::emitDitto() %s %s\n", kind(), toChars()); | |
374 OutBuffer *buf = sc->docbuf; | 376 OutBuffer *buf = sc->docbuf; |
375 unsigned o; | 377 unsigned o; |
376 OutBuffer b; | 378 OutBuffer b; |
377 | 379 |
378 b.writestring("$(DDOC_DITTO "); | 380 b.writestring("$(DDOC_DITTO "); |
379 o = b.offset; | 381 o = b.offset; |
380 toDocBuffer(&b); | 382 toDocBuffer(&b); |
381 highlightCode(sc, this, &b, o); | 383 //printf("b: '%.*s'\n", b.offset, b.data); |
384 /* If 'this' is a function template, then highlightCode() was | |
385 * already run by FuncDeclaration::toDocbuffer(). | |
386 */ | |
387 TemplateDeclaration *td; | |
388 if (parent && | |
389 (td = parent->isTemplateDeclaration()) != NULL && | |
390 td->onemember == this) | |
391 { | |
392 } | |
393 else | |
394 highlightCode(sc, this, &b, o); | |
382 b.writeByte(')'); | 395 b.writeByte(')'); |
383 buf->spread(sc->lastoffset, b.offset); | 396 buf->spread(sc->lastoffset, b.offset); |
384 memcpy(buf->data + sc->lastoffset, b.data, b.offset); | 397 memcpy(buf->data + sc->lastoffset, b.data, b.offset); |
385 sc->lastoffset += b.offset; | 398 sc->lastoffset += b.offset; |
386 } | 399 } |
433 buf->printf("%s ", p); | 446 buf->printf("%s ", p); |
434 } | 447 } |
435 | 448 |
436 void Dsymbol::emitComment(Scope *sc) { } | 449 void Dsymbol::emitComment(Scope *sc) { } |
437 void InvariantDeclaration::emitComment(Scope *sc) { } | 450 void InvariantDeclaration::emitComment(Scope *sc) { } |
451 //void PostBlitDeclaration::emitComment(Scope *sc) { } | |
438 void DtorDeclaration::emitComment(Scope *sc) { } | 452 void DtorDeclaration::emitComment(Scope *sc) { } |
439 void StaticCtorDeclaration::emitComment(Scope *sc) { } | 453 void StaticCtorDeclaration::emitComment(Scope *sc) { } |
440 void StaticDtorDeclaration::emitComment(Scope *sc) { } | 454 void StaticDtorDeclaration::emitComment(Scope *sc) { } |
441 void ClassInfoDeclaration::emitComment(Scope *sc) { } | 455 void ClassInfoDeclaration::emitComment(Scope *sc) { } |
442 void ModuleInfoDeclaration::emitComment(Scope *sc) { } | 456 void ModuleInfoDeclaration::emitComment(Scope *sc) { } |
633 void Dsymbol::toDocBuffer(OutBuffer *buf) | 647 void Dsymbol::toDocBuffer(OutBuffer *buf) |
634 { | 648 { |
635 //printf("Dsymbol::toDocbuffer() %s\n", toChars()); | 649 //printf("Dsymbol::toDocbuffer() %s\n", toChars()); |
636 HdrGenState hgs; | 650 HdrGenState hgs; |
637 | 651 |
652 hgs.ddoc = 1; | |
638 toCBuffer(buf, &hgs); | 653 toCBuffer(buf, &hgs); |
639 } | 654 } |
640 | 655 |
641 void prefix(OutBuffer *buf, Dsymbol *s) | 656 void prefix(OutBuffer *buf, Dsymbol *s) |
642 { | 657 { |
736 prefix(buf, td); | 751 prefix(buf, td); |
737 tf->next->toCBuffer(buf, NULL, &hgs); | 752 tf->next->toCBuffer(buf, NULL, &hgs); |
738 buf->writeByte(' '); | 753 buf->writeByte(' '); |
739 buf->writestring(ident->toChars()); | 754 buf->writestring(ident->toChars()); |
740 buf->writeByte('('); | 755 buf->writeByte('('); |
741 for (int i = 0; i < td->parameters->dim; i++) | 756 for (int i = 0; i < td->origParameters->dim; i++) |
742 { | 757 { |
743 TemplateParameter *tp = (TemplateParameter *)td->parameters->data[i]; | 758 TemplateParameter *tp = (TemplateParameter *)td->origParameters->data[i]; |
744 if (i) | 759 if (i) |
745 buf->writeByte(','); | 760 buf->writeByte(','); |
746 tp->toCBuffer(buf, &hgs); | 761 tp->toCBuffer(buf, &hgs); |
747 } | 762 } |
748 buf->writeByte(')'); | 763 buf->writeByte(')'); |
1489 } | 1504 } |
1490 return i; | 1505 return i; |
1491 } | 1506 } |
1492 | 1507 |
1493 | 1508 |
1509 /************************************************ | |
1510 * Scan forward past URL starting at i. | |
1511 * We don't want to highlight parts of a URL. | |
1512 * Returns: | |
1513 * i if not a URL | |
1514 * index just past it if it is a URL | |
1515 */ | |
1516 | |
1517 unsigned skippastURL(OutBuffer *buf, unsigned i) | |
1518 { unsigned length = buf->offset - i; | |
1519 unsigned char *p = &buf->data[i]; | |
1520 unsigned j; | |
1521 unsigned sawdot = 0; | |
1522 | |
1523 if (length > 7 && memicmp((char *)p, "http://", 7) == 0) | |
1524 { | |
1525 j = 7; | |
1526 } | |
1527 else if (length > 8 && memicmp((char *)p, "https://", 8) == 0) | |
1528 { | |
1529 j = 8; | |
1530 } | |
1531 else | |
1532 goto Lno; | |
1533 | |
1534 for (; j < length; j++) | |
1535 { unsigned char c = p[j]; | |
1536 if (isalnum(c)) | |
1537 continue; | |
1538 if (c == '-' || c == '_' || c == '?' || | |
1539 c == '=' || c == '%' || c == '&' || | |
1540 c == '/' || c == '+' || c == '#' || | |
1541 c == '~') | |
1542 continue; | |
1543 if (c == '.') | |
1544 { | |
1545 sawdot = 1; | |
1546 continue; | |
1547 } | |
1548 break; | |
1549 } | |
1550 if (sawdot) | |
1551 return i + j; | |
1552 | |
1553 Lno: | |
1554 return i; | |
1555 } | |
1556 | |
1557 | |
1494 /**************************************************** | 1558 /**************************************************** |
1495 */ | 1559 */ |
1496 | 1560 |
1497 int isKeyword(unsigned char *p, unsigned len) | 1561 int isKeyword(unsigned char *p, unsigned len) |
1498 { | 1562 { |
1733 { unsigned j; | 1797 { unsigned j; |
1734 | 1798 |
1735 j = skippastident(buf, i); | 1799 j = skippastident(buf, i); |
1736 if (j > i) | 1800 if (j > i) |
1737 { | 1801 { |
1802 unsigned k = skippastURL(buf, i); | |
1803 if (k > i) | |
1804 { i = k - 1; | |
1805 break; | |
1806 } | |
1807 | |
1738 if (buf->data[i] == '_') // leading '_' means no highlight | 1808 if (buf->data[i] == '_') // leading '_' means no highlight |
1739 { | 1809 { |
1740 buf->remove(i, 1); | 1810 buf->remove(i, 1); |
1741 i = j - 1; | 1811 i = j - 1; |
1742 } | 1812 } |