Skip to content
Permalink
Browse files

lol that broke nav

  • Loading branch information
adamdruppe committed Jan 20, 2019
1 parent cb1d9c6 commit 27f39ac9a2e730677d52d33d0428bc28653a0810
Showing with 84 additions and 7 deletions.
  1. +32 −0 adrdox_docs/syntax.d
  2. +25 −5 comment.d
  3. +2 −1 doc2.d
  4. +25 −1 style.css
@@ -242,6 +242,18 @@ void main() {}
---
)
Ddoc style code samples are special in one way: you can highlight code inside it by using `/* adrdox_highlight{ */ code here would be highlighted /* }adrdox_highlight */` comments in the sample. Note that it matches those strings $(I exactly), meaning you must use `/* */` comments and must have the same spacing. `/* adrdox_highlight{ */` turns it on, `/* }adrdox_highlight */` turns it off. Note that if you don't turn it off, you may cause invalid html to be generated (the implementation just opens and closes a `span` element right now).

$(ADRDOX_SAMPLE
---
// I will demo highlight below for the `main` function
/* adrdox_highlight{ */void main() {

}/* }adrdox_highlight */
// and now we are done.
---
)

$(H4 Console macro - for console output)

The `$(CONSOLE)` macro is for copy/pasting text out of your console, such as showing command lines or program output. You MAY nest macros inside it for additional formatting, and thus, you should escape any `$` followed by `(` in the text.
@@ -254,6 +266,8 @@ $(CONSOLE
)
)

Note that most special syntax works inside `$(CONSOLE)`, but Ddoc-style code samples, delimited with `---`, does not. This is because that breaks things more often than it is useful.

$(H3 Documented unittests)

$(SIDEBAR Why does it allow inline examples? I often write full examples that I want to present in the prose, but I also like the compile check the unittests provide. So to get best of both worlds, I had to do it myself.)
@@ -598,6 +612,24 @@ I also support a list table format, inspired by restructuredText.

In this format, the text before any `*` is the caption. Then, a leading `*` indicates a new row, a leading `+` starts a new table header, and a leading `-` starts a new table cell. The cells can be as long as you like.

adrdox will also detect if you put a header on the left side of later rows, and format the table accordingly:

$(ADRDOX_SAMPLE
$(TABLE_ROWS
Caption
* + Header 1
+ Header 2
+ Header 3
* + 2D Header
- Data 1.2
- Data 1.3
* + Again
- Data 1.2
- Data 2.3
)
)



$(H4 Formatting tables)

@@ -1694,6 +1694,9 @@ static this() {

"HR" : "<hr />",

"DASH" : "&#45;",
"NOTHING" : "", // used to escape magic syntax sometimes

// DDoc just expects these.
"AMP" : "&",
"LT" : "<",
@@ -2105,6 +2108,7 @@ Element expandDdocMacros2(string txt, Decl decl) {

if(name == "CONSOLE") {
awesome = outdent(txt[idx + info.macroNameEndingOffset .. idx + info.terminatingOffset - dzeroAdjustment]).strip;
awesome = awesome.replace("\n---", "\n$(NOTHING)---"); // disable ddoc embedded D code as it breaks for D exception messages
}


@@ -2259,11 +2263,24 @@ string highlight(string sourceCode)
writeSpan("type", t.text);
else if (isKeyword(t.type))
writeSpan("kwrd", str(t.type));
else if (t.type == tok!"comment")
writeSpan("com", t.text);
else if (isStringLiteral(t.type) || t.type == tok!"characterLiteral")
writeSpan("str", t.text);
else if (isNumberLiteral(t.type))
else if (t.type == tok!"comment") {
auto txt = t.text;
if(txt == "/* adrdox_highlight{ */")
ret ~= "<span class=\"specially-highlighted\">";
else if(txt == "/* }adrdox_highlight */")
ret ~= "</span>";
else
writeSpan("com", t.text);
} else if (isStringLiteral(t.type) || t.type == tok!"characterLiteral") {
auto txt = t.text;
if(txt.startsWith("q{")) {
ret ~= "<span class=\"token-string-literal\"><span class=\"str\">q{</span>";
ret ~= highlight(txt[2 .. $ - 1]);
ret ~= "<span class=\"str\">}</span></span>";
} else {
writeSpan("str", txt);
}
} else if (isNumberLiteral(t.type))
writeSpan("num", t.text);
else if (isOperator(t.type))
//writeSpan("op", str(t.type));
@@ -3015,6 +3032,9 @@ Element translateListTable(string text, Decl decl) {
else {}
} while(text.length);

if(holder.querySelector("th:first-child + td"))
holder.addClass("two-axes");

return holder;
}

3 doc2.d
@@ -1307,6 +1307,7 @@ Document writeHtml(Decl decl, bool forReal, bool gzip, string headerTitle, Heade
}

foreach(child; iterate) {
if(cast(ImportDecl) child) continue; // do not document public imports here, they belong only on the inside
if(child.docsShouldBeOutputted) {
// strip overloads from sidebar
if(child.name !in inNavArray) {
@@ -1698,7 +1699,7 @@ abstract class Decl {

if(this.parent !is null) {
foreach(child; this.parent.children) {
if(child.name == this.name && child.docsShouldBeOutputted())
if(((cast(ImportDecl) child) is null) && child.name == this.name && child.docsShouldBeOutputted())
ret ~= child;
}
if(auto t = cast(TemplateDecl) this.parent)
@@ -1211,7 +1211,7 @@ pre.d_code,
border-collapse: collapse;
}

.user-table th {
.user-table tr:nth-of-type(1) th {
border-bottom: solid 1px black;
text-align: left;
}
@@ -1221,6 +1221,18 @@ pre.d_code,
vertical-align: top;
padding: 4px;
}
.user-table th {
padding: 4px;
}

.user-table.two-axes tr + tr th:first-child {
border-bottom: solid 1px #ccc;
}

.user-table.two-axes th:first-child {
border-right: solid 1px black;
text-align: right;
}

.allocator-table td:first-child tt {
background-color: transparent;
@@ -1295,3 +1307,15 @@ tt.D.highlighted a {
font-size: 90%;
font-style: italic;
}

.token-string-literal {
font-style: italic;
}
.token-string-literal:hover {
background-color: rgba(255, 0, 0, 0.05);
}

.specially-highlighted {
background-color: yellow;
background-color: rgba(255, 255, 0, 0.5);
}

0 comments on commit 27f39ac

Please sign in to comment.
You can’t perform that action at this time.