Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"dependencies": {
"vibe-d": "~>0.7.22",
"libdparse": {"optional": true, "version": "~>0.2.0"},
"libdparse": "~>0.4.0",
"hyphenate": "~>1.1.0"
},
"versions": ["JsonLineNumbers"],
Expand Down
5 changes: 3 additions & 2 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"libevent": "2.0.1+2.0.16",
"libev": "5.0.0+4.04",
"openssl": "1.1.4+1.0.1g",
"libdparse": "0.2.1",
"memutils": "0.4.3",
"experimental_allocator": "2.70.0-b1",
"libdparse": "0.4.0",
"memutils": "0.4.4",
"vibe-d": "0.7.26",
"hyphenate": "1.1.0",
"libasync": "0.7.5"
Expand Down
10 changes: 6 additions & 4 deletions public/prettify/prettify.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

/* SPAN elements with the classes below are added by prettyprint. */
.pln { color: #222 } /* plain text */
pre .pln, .prototype .pln { color: #ffffff } /* plain text */
pre .pln, div.prototype .pln { color: #fff } /* plain text */

@media screen {
pre .str { color: #ffe7b6 } /* string content */
pre .typ { color: #9ad452 } /* a type name */
pre .lit { color: #ffe7b6 } /* a literal value */
pre .pun, .prototype .pun, .opn, .clo { color: #ddd }
pre .pun, div.prototype .pun { color: #fff }

.spc { color: #a0a } /* special token sequence */
.str { color: #842 } /* string content */
.kwd { color: #ffaa00 } /* a keyword */
.com { color: #888 } /* a comment */
.typ { color: #693 } /* a type name */
.lit { color: #875 } /* a literal value */
/* punctuation, lisp open bracket, lisp close bracket */
.pun, .opn, .clo { color: #333 }
.pun, .opn, .clo { color: #222 }
.tag { color: #ffaa00 } /* a markup tag name */
.atn { color: #9ad452 } /* a markup attribute name */
.atv { color: #ffe7b6 } /* a markup attribute value */
Expand All @@ -26,6 +27,7 @@ pre .pln, .prototype .pln { color: #ffffff } /* plain text */

/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.spc { color: #606 } /* special token sequence */
.str { color: #060 }
.kwd { color: #006; font-weight: bold }
.com { color: #600; font-style: italic }
Expand All @@ -38,7 +40,7 @@ pre .pln, .prototype .pln { color: #ffffff } /* plain text */
}

/* Put a border around prettyprinted code snippets. */
pre.prettyprint, pre.code, .prototype {
pre.prettyprint, pre.code, div.prototype {
padding: 1em 0;
background-color: #222;
border: 1px solid black;
Expand Down
1 change: 0 additions & 1 deletion public/prettify/prettify.js

This file was deleted.

38 changes: 21 additions & 17 deletions source/ddox/api.d
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,29 @@ string formatType()(Type type, string delegate(Entity) link_to, bool include_cod

void formatType(R)(ref R dst, Type type, string delegate(Entity) link_to, bool include_code_tags = true)
{
import ddox.highlight;

if (include_code_tags) dst.put("<code class=\"prettyprint lang-d\">");
foreach( att; type.attributes){
dst.put(att);
dst.highlightDCode(att);
dst.put(' ');
}
if( type.kind != TypeKind.Function && type.kind != TypeKind.Delegate ){
foreach( att; type.modifiers ){
dst.put(att);
dst.put('(');
dst.highlightDCode(att);
dst.highlightDCode("(");
}
}
switch( type.kind ){
switch (type.kind) {
default:
case TypeKind.Primitive:
if (type.typeDecl && !cast(TemplateParameterDeclaration)type.typeDecl) {
auto mn = type.typeDecl.module_.qualifiedName;
auto qn = type.typeDecl.nestedName;
if( qn.startsWith(mn~".") ) qn = qn[mn.length+1 .. $];
formattedWrite(dst, "<a href=\"%s\">%s</a>", link_to(type.typeDecl), qn.replace(".", ".<wbr/>")); // TODO: avoid allocating replace
formattedWrite(dst, "<a href=\"%s\">%s</a>", link_to(type.typeDecl), highlightDCode(qn).replace(".", ".<wbr/>")); // TODO: avoid allocating replace
} else {
dst.put(type.typeName.replace(".", ".<wbr/>")); // TODO: avoid allocating replace
dst.highlightDCode(type.typeName);
}
if( type.templateArgs.length ){
dst.put('!');
Expand All @@ -230,47 +232,49 @@ void formatType(R)(ref R dst, Type type, string delegate(Entity) link_to, bool i
case TypeKind.Delegate:
formatType(dst, type.returnType, link_to, false);
dst.put(' ');
dst.put(type.kind == TypeKind.Function ? "function" : "delegate");
dst.put('(');
dst.highlightDCode(type.kind == TypeKind.Function ? "function" : "delegate");
dst.highlightDCode("(");
foreach( size_t i, pt; type.parameterTypes ){
if( i > 0 ) dst.put(", ");
if( i > 0 ) dst.highlightDCode(", ");
formatType(dst, pt, link_to, false);
if( type._parameterNames[i].length ){
dst.put(' ');
dst.put(type._parameterNames[i]);
}
if( type._parameterDefaultValues[i] ){
dst.put(" = ");
dst.highlightDCode(" = ");
dst.put(type._parameterDefaultValues[i].valueString);
}
}
dst.put(')');
dst.highlightDCode(")");
foreach( att; type.modifiers ){
dst.put(' ');
dst.put(att);
}
break;
case TypeKind.Pointer:
formatType(dst, type.elementType, link_to, false);
dst.put('*');
dst.highlightDCode("*");
break;
case TypeKind.Array:
formatType(dst, type.elementType, link_to, false);
dst.put("[]");
dst.highlightDCode("[]");
break;
case TypeKind.StaticArray:
formatType(dst, type.elementType, link_to, false);
formattedWrite(dst, "[%s]", type.arrayLength);
dst.highlightDCode("[");
dst.highlightDCode(type.arrayLength.to!string);
dst.highlightDCode("]");
break;
case TypeKind.AssociativeArray:
formatType(dst, type.elementType, link_to, false);
dst.put('[');
dst.highlightDCode("[");
formatType(dst, type.keyType, link_to, false);
dst.put(']');
dst.highlightDCode("]");
break;
}
if( type.kind != TypeKind.Function && type.kind != TypeKind.Delegate ){
foreach( att; type.modifiers ) dst.put(')');
foreach( att; type.modifiers ) dst.highlightDCode(")");
}
if (include_code_tags) dst.put("</code>");
}
Expand Down
Loading