1 // just docs: adrdox syntax
2 /++
3 This document describes the syntax recognized by my documentation generator. It uses a hybrid of ddoc and markdown syntax, with some customizations and pre-defined styles I like, while not supporting things I feel aren't worth the hassle.
4 
5 It has support for enough legacy ddoc that Phobos still works, but is really a different language - I think ddoc made a lot of mistakes (and markdown made mistakes too).
6 
7 $(ADRDOX_SAMPLE
8 	Paragraphs just work.
9 
10 	Automatically.
11 
12 	$(LIST
13 		* Lists can be displayed
14 		* in bracketed markdown style
15 	)
16 
17 	$(SMALL_TABLE
18 		markdown | style
19 		tables   | work (if bracketed)
20 	)
21 
22 	---
23 	void d_code() {
24 	  is formatted brilliantly;
25 	}
26 	---
27 
28 	```
29 	Markdown-style code blocks work too for other languages
30 	or convenient <pre> blocks.
31 	```
32 
33 	```java
34 	public static void Main() {
35 		return "With some syntax highlighting."
36 	}
37 	```
38 
39 	We also have `inline code`.
40 
41 	$(TIP and various content boxes.)
42 
43 	$(MATH \int \text{LaTeX} too! dx)
44 )
45 
46 
47 $(H2 Document outline)
48 
49 Your comment consists of three parts: the first paragraph, which is meant to be a stand-alone summary which is shown out-of-context in search results, the synopsis, which is displayed "above the fold" - before the function prototype, member list, or automatically generated table of contents, and finally, the rest of the documentation.
50 
51 The fold is inserted at the first "\n\n\n" it finds in your comment (the first time it sees two blank lines:
52 
53 $(ADRDOX_SAMPLE
54 
55 	This is the summary. It is shown in search results and
56 	at the top of your generated document.
57 
58 	This is the synopsis, still displayed above the fold.
59 
60 	So is this.
61 
62 
63 	The two blank lines above is the placeholder where the
64 	table of contents is inserted. This paragraph, and
65 	everything below it, is the bulk body of the page.
66 
67 	Line breaks in the middle of a paragraph, except in code
68 	blocks, are ignored. You can format your comments however you like.
69 )
70 
71 $(H3 Symbol grouping)
72 
73 You can optionally group symbols together by defining groups in a special section in your module definition comment, then tagging the doc comments on the items.
74 
75 ---
76 /++
77 	This demos symbol grouping.
78 
79 	Symbol_groups:
80 
81 	group_name =
82 		Introductory and explanatory text for the group. It may
83 		include any kind of 
84 
85 	drawing =
86 		## Drawing
87 
88 		This library supports several drawing functions. You
89 		draw them all on a "surface" of sorts, derived from
90 		[Drawable].
91 +/
92 module test;
93 
94 /++ Group: group_name
95 	Introductory text
96 
97 	and paragraphs like normal.
98 
99 
100 	This goes below the fold.
101 +/
102 void foo() {}
103 
104 /++
105 	This is in the [drawing] group.
106 
107 	Group: drawing
108 +/
109 interface Drawable {
110 	/// Group: group_name
111 	void whatever() {}
112 }
113 ---
114 
115 The `Symbol_groups:` section should only appear on the module commment. The `Group: name` line MUST be the first thing to appear in a comment, or be on the very last line of the comment. It can only appear once. Putting a function in multiple groups is not current supported.
116 
117 If there is no header at the start of the group definition, one will be automatically inserted based on the group name.
118 
119 For cross referencing purposes, the groups are considered pseudo-symbols at module scope. This means you can refer to them with the shortcut `[symbol]` syntax from anywhere in the module, or from outside the module if used with a fully-qualified name.
120 
121 However, for best results, it should not conflict with any real names in the module, nor with any [#footnotes|link references], which also introduce pseudo-symbols. If there is a conflict, the reference result is currently undefined (it may be any one of them, in no particular order). I will define that precedence order at some other time - so for now, avoid name conflicts!
122 
123 $(H2 Macros)
124 
125 adrdox inherits ddoc's macro syntax, but uses it differently than ddoc: it does not support user-defined macros, and sometimes uses them to bracket special syntax.
126 
127 Any time you see me show ddoc macro syntax, `$(NAME )`, be aware that you can also use `${NAME }`. For example, if you have unbalanced parenthesis inside the thing, you may prefer to use `${}`.
128 
129 ${ADRDOX_SAMPLE
130 	$(B this is bold)
131 	${B so is this}
132 	${I this has unbalanced paren :) }
133 }
134 
135 $(H3 List of supported simple formatting macros)
136 
137 ${ADRDOX_SAMPLE
138     $(B Bold text)
139     $(I Italic text)
140     $(HIGHLIGHT Highlighted text)
141     $(SUPERSCRIPT Superscript)
142     $(SUBSCRIPT Subscript)
143     $(DIV HTML division, intended for using
144           ID and CLASS for more
145           flexible css customization)
146 }
147 
148 Others may or may not work due to legacy compatibility, but I may remove them without notice so you should not use any not explicitly listed somewhere in this document.
149 
150 $(H2 Code snippets)
151 
152 $(H3 Inline code)
153 
154 Inline code can be marked with Markdown (and Ddoc) style ``code here ``, which will render as `code here`. Text inside the backticks suppress all other documentation generator processing - it will just be escaped for literal output.
155 
156 $(TIP If you need to display a literal ``, use the `$(BACKTICK)` macro or a doubled backtick: ````.)
157 
158 Code inside backticks may only span one line. If a line has an unmatched backtick, it is not processed as code.
159 
160 If you want syntax-highlighted inline D code, use `$(D d code here)`, such as `$(D if(a is true))` will result in $(D if(a is true)) - notice the syntax highlighting on the D keywords.
161 
162 $(H3 Block code)
163 
164 There are three syntaxes for code blocks: Markdown style $(BACKTICK)$(BACKTICK)$(BACKTICK), ddoc style ---, and a magic macro called `$(CONSOLE)`.
165 
166 All code blocks are outdented and leading and trailing blank lines are removed, but all other whitespace is left intact. This means you may indent it as much as you like inside your comments without breaking the output.
167 
168 $(H4 Markdown style - for generic code)
169 
170 The Markdown style block is meant to be used with generic code or preformatted text that is not D.
171 
172 $(ADRDOX_SAMPLE
173 	```
174 	Code here 	which preserves
175 	   whitespace
176 	```
177 )
178 
179 You can optionally include a language name after the opening ticks and it will label and attempt syntax highlighting (the syntax highlighter is not as precise as the D highlighter, but often should be good enough):
180 
181 $(ADRDOX_SAMPLE
182 	```javascript
183 	/* This is highlighted Javascript! */
184 	window.onload = function() {
185 		var a = "hello, world!";
186 		var b = 5;
187 	};
188 	```
189 
190 	```c
191 	/* Highlighted C */
192 	#include<stdio.h>
193 	typedef struct {
194 		int a;
195 	} test;
196 	```
197 
198 	```php
199 	<?php
200 		# highlighted PHP
201 		function foo($a) {
202 			$a = 'hello';
203 			return $a;
204 		}
205 	?>
206 	```
207 
208 	```python
209 	# highlighted python
210 	class test:
211 		""" docstring """
212 		def myfunc():
213 			if True or 1 > 0:
214 				print "hello"
215 			else
216 				print test
217 	```
218 
219 	```html
220 	<span class="foo">
221 		<!-- try hovering over the entity! -->
222 		HTML &amp;
223 	</span>
224 	```
225 
226 	```css
227 	/* This also highlights */
228 	span[data-test="foo"] > .bar {
229 		color: red;
230 	}
231 	```
232 
233 	```sdlang
234 	// dub.sdl can contain comments!
235 	name "somepackage"
236 	description "A little web service of mine."
237 	authors "Peter Parker"
238 	homepage "http://myproject.example.com"
239 	license "GPL-2.0"
240 	dependency "vibe-d" version="~>0.7.23"
241 	configuration "metro-app" {
242 		platforms "windows"
243 		targetType "executable"
244 		versions "MetroApp"
245 		libs "d3d11"
246 	}
247 	configuration "desktop-app" {
248 		platforms "windows"
249 		targetType "executable"
250 		versions "DesktopApp"
251 		libs "d3d9"
252 	}
253 	configuration "glut-app" {
254 		// works on any platform
255 		targetType "executable"
256 		versions "GlutApp"
257 	}
258 	```
259 )
260 
261 Currently supported languages for highlighting include: C, C++, Javascript, PHP, Java, C#, CSS, HTML, XML, Python, Ruby, [arsd.script|adrscript] and D. Though, for D, you should use ddoc style `---` delimiters to get the full-featured D highlighter instead of using the simpler one here. This simple highlighter aims for good enough to help visually on simple examples rather than being perfect on each target language.
262 
263 Use the language name in all lower case when tagging the language, like `php` or `c++`.
264 
265 $(TIP If you ever want to document the syntax of a Markdown code block itself, I added a magic $(BACKTICK)$(BACKTICK)$(BACKTICK){ code }$(BACKTICK)$(BACKTICK)$(BACKTICK) syntax. As long as the braces are nested, everything inside will be considered part of the literal code block, including other code blocks.)
266 
267 The generator MAY syntax highlight the language using `span` with class names, but might not (really depends on if I implement it). You may use the language as a target in CSS using the `data-language` attribute to customize the appearance.
268 
269 $(H4 Ddoc style - for D code)
270 
271 The ddoc style block only works with D code. It runs the sample through the D lexer, so it understands things like nested documentation comments and will properly skip them while syntax highlighting the output.
272 
273 $(ADRDOX_SAMPLE
274 ---
275 /**
276 	Ddoc style code blocks understand D deeply.
277 
278 	---
279 	if(example.nested)
280 		stillWorks!();
281 	---
282 */
283 void main() {}
284 ---
285 )
286 
287 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).
288 
289 $(ADRDOX_SAMPLE
290 ---
291 // I will demo highlight below for the `main` function
292 /* adrdox_highlight{ */void main() {
293 
294 }/* }adrdox_highlight */
295 // and now we are done.
296 ---
297 )
298 
299 $(H4 Console macro - for console output)
300 
301 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.
302 
303 $(ADRDOX_SAMPLE
304 $(CONSOLE
305 	$ dmd hello.d
306 	$ ./hello
307 	Hello, $(B world)!
308 )
309 )
310 
311 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.
312 
313 In particular, using the `$(HIGHLIGHT)` macro inside CONSOLE may be helpful.
314 
315 $(H3 Documented unittests)
316 
317 $(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.)
318 
319 I also implemented the feature from ddoc where unittests with a documentation comment are appended to the examples section of the previous documented declaration. They will appear in an `Examples` section (together with any others you manually write in `Examples:`), or inline in the documentation if you give them an `$(ID some_unique_name)` in the doc comment of the unittest, and write `$(EMBED_UNITTEST some_unique_name)` somewhere in your body text. Both the test and its associated comment will be moved to that location instead of being put in the examples section.
320 
321 If you have a line that must be in the test to be useful, but should not appear in the documentation, you can simply comment it: `// exclude from docs`. But the line must end with that exact string.
322 
323 ---
324 /// The assert inside will not appear in the generated docs
325 unittest {
326    int a;
327    assert(a == 2); // exclude from docs
328    writeln(a);
329 }
330 ---
331 
332 $(H2 Cross-referencing)
333 
334 Many tasks of cross-referencing are done automatically. Inheritance and function signatures use semantic data from the D source to link themselves. URLs in the raw text, such as http://dpldocs.info/ are detected and hyperlinked automatically. Tables of contents are created, as needed, by scanning for headers.
335 
336 However, in your text, you may also want to reference names and links that are not automatically detected.
337 
338 $(SIDEBAR It does not attempt to pick out D symbol names automatically from the text, since this leads to a great many false positives. ddoc's attempt to do this failed miserably.)
339 
340 Since this is such a common task, I dedicated a short, special syntax to it: square brackets. Write a name or URL inside brackets and it will linkify it, as specifically as it can from the index built from semantic D data. For example: `[arsd.color]` will yield [arsd.color], a link to my color module.
341 
342 When documenting code, it will first try to detect a URL. If so, it treats it as a link. Next, it will try to look up the D identifier in the current scope. If it finds it, it will link to the most local variable, following the import graph. If all else fails, it will just assume it is a relative filename and link that way.
343 
344 $(NOTE
345 	If you want to load modules for name lookup, but not generate documentation for them, pass
346 	the file or the directory containing to `adrdox` with `--load`.
347 )
348 
349 In most cases, putting a D name inside brackets should link as you expect.
350 
351 You can also change the display name by putting a pipe after the link, followed by text: `[arsd.color|my color module]` gives [arsd.color|my color module].
352 
353 Local sections can be referenced with `[#cross-referencing]`: [#cross-referencing].
354 
355 $(H3 Markdown-style links)
356 
357 Markdown-style `[text](url)` links are also supported. There must be no space between the `]` and `(` and it must all appear on the same line. [My link here](http://dpldocs.info). Markdown-style links do $(B not) attempt name lookups like adrdox native `[links]`.
358 
359 $(H3 User-defined attribues)
360 
361 If you want a UDA to document its uses, you can add the magic macro `$(UDA_USES)` to it somewhere. This will list links to each symbol possessing the uda.
362 
363 ---
364 /++
365 	This is used on:
366 
367 	$(UDA_USES)
368 +/
369 enum MyUDA;
370 
371 @MyUDA void foo() {}
372 ---
373 
374 $(H2 Paragraph detection)
375 
376 The generator will automatically handle paragraph tags by looking for blank lines and other separators. Just write and trust it to do the right thing. (If it doesn't, email me a bug report, please.)
377 
378 $(H2 Images)
379 
380 You can post images with `$(IMG source_url, alt text)`. The default CSS will put some reasonable size limits and margin on it.
381 
382 The image will typically be hosted elsewhere, `IMG` simply takes a URL (though it can be a data url, you need to manage that yourself too).
383 
384 FIXME: implement and document `$(LEFT )`, `$(RIGHT )`, and `$(CENTERED )`.
385 
386 You may also use inline `$(SVG )` or `$(RAW_HTML)`. FIXME
387 
388 Markdown-style `![alt text](url)` images are also supported, iff there are no spaces between the symbols and all appear on the same line. ![d logo](/d-logo.png).
389 
390 Note that if the parens are not there, it is normal![1] (code there: `normal![1]`)
391 
392 $(H2 Headers)
393 
394 You can use ddoc-style macros for headers: `$(H1 Name of header)`, `$(H2 Subheader)`, and so on through `$(H6)`. Linking will be added automatically by the generator.
395 
396 Custom ddoc sections (see below) are translated into `<h3>` headers.
397 
398 You can also use a markdown style `====` under a line to trigger a header. These will render as `<h3>` if at top level, and `<h4>` if under a custom ddoc section (FIXME: that details is not yet implemented). For this to work:
399 
400 $(LIST
401 	* The header must be preceded by a blank line
402 	* The `====` must be directly below the header
403 	* The `====` must be followed by a blank line
404 	* There must be at least 4 `=` on the line, and no other text (excluding whitespace).
405 )
406 
407 $(ADRDOX_SAMPLE
408 
409 	This is some text preceding the header.
410 
411 	This is the header
412 	==================
413 
414 	This is a paragraph under that header.
415 )
416 
417 Moreover, markdown style `## Header` are also supported. The number of `#` characters indicate the header level (1-6). Similar restrictions apply:
418 
419 $(LIST
420 	* The header must be preceded by and followed by a blank line
421 	* The `#` must be the first non-whitespace character on the line
422 	* There must be a space following the `#` characters.
423 )
424 
425 $(ADRDOX_SAMPLE
426 
427 	# H1
428 
429 	## H2
430 
431 	### H3
432 
433 	#not a header, missing space
434 
435 	a # is not a header
436 
437 	Nor is the following a header
438 	# because it is not preceded by a blank line
439 )
440 
441 $(H3 Ddoc sections)
442 
443 Most the Ddoc sections are supported too, and should be used where appropriate to document your code. I also added one called `diagnostics:`, where you can list common compile errors seen with the function.
444 
445 `Examples:` (or `Example:`) is special in that documented unit tests are appended here.
446 
447 You may define custom ddoc sections as long as they are all one word and includes at least one underscore in the name. They will be translated to `H3` headers, since they typically go under the `Detailed Description` H2-level header.
448 
449 Be sure to correctly nest headers - put H3 under H2, and H4 under H3, etc. Failure to do so may break your table of contents.
450 
451 $(ADRDOX_SAMPLE
452 	$(H2 A header)
453 		Some content
454 	$(H3 Another header)
455 		Some more content
456 
457 	A_Ddoc_Style_Header:
458 		And some content
459 )
460 
461 
462 $(H2 Content blocks)
463 
464 There are a few content blocks to add boxes to your documentation: `$(TIP)`, `$(NOTE)`, `$(WARNING)`, `$(PITFALL)`, and `$(SIDEBAR)`. Inside these, you may write any content.
465 
466 Use these boxes to make certain content stand out so the reader pays attention to something special (or, in the case of `SIDEBAR`, get out of the way so the reader can skip it). The intended semantics are:
467 
468 `$(TIP)` is a cool fact to help you make the most of the code.
469 
470 `$(NOTE)` is something the reader should be aware of, but they can get it wrong without major consequence.
471 
472 `$(WARNING)` is something they need to watch out for, such as potential crashes or memory leaks when using the function.
473 
474 `$(PITFALL)` is something that users very commonly get wrong and you want them to see it to avoid making the same mistake yet again.
475 
476 `$(SIDEBAR)` will be typically displayed outside the flow of the text. It should be used when you want to expand on some details, but it isn't something the user strictly needs to know.
477 
478 $(H2 Fancier Formatting)
479 
480 $(SIDEBAR
481 	$(H3 Why use macro syntax to bracket it instead of trying to detect like Markdown does?)
482 
483 	Basically, I have to support at least some of ddoc macro syntax anyway for compatibility with existing documents like Phobos, so it is a convenient thing to simplify my parser.
484 
485 	But, beyond that, it also gives me a chance to accept metadata, like class names to add to the HTML by putting them inside the block too.
486 )
487 
488 There are several magic macros that use domain-specific syntaxes for common formatting tasks, like lists and tables. The ddoc-style macro brackets the text, which is laid out in a particular way to make writing, reading, and editing the data most easy.
489 
490 
491 $(H3 Blockquotes)
492 
493 Use the `$(BLOCKQUOTE)` macro to surround the quote. It will render as you expected.
494 
495 $(ADRDOX_SAMPLE
496 	$(BLOCKQUOTE
497 		This is a quote! You can write whatever you want in here.
498 
499 		Including paragraphs, and other content. Unlike markdown, you
500 		do not need to write `>` or spaces or anything else before every
501 		line, instead you just wrap the whole thing in `$(BLOCKQUOTE)`.
502 
503 		If it has unbalanced parenthesis, you can use `$(LPAREN)` or `$(RPAREN)`
504 		for them.
505 	)
506 )
507 
508 $(H3 Lists)
509 
510 There are two types of list: `$(LIST)` and `$(NUMBERED_LIST)`. Both work the same way. The only difference is `$(LIST)` generates a `<ul>` tag, while `$(NUMBERED_LIST)` generates a `<ol>` tag.
511 
512 Inside the magic list macros, a `*` character at the beginning of a line will create a new list item.
513 
514 $(WARNING
515 	Make sure the leading `*` does not line up with your comment marker, or the preprocessor may strip it thinking it is a comment in the style of:
516 
517 	---
518 	/**
519 	  * one of these
520 	  */
521 	---
522 
523 	Since the preprocessor runs before analyzing brackets, it won't know that the star was intentional.
524 
525 	I recommend indenting your list stars by at least 4 spaces or one tab for best results.
526 )
527 
528 $(ADRDOX_SAMPLE
529 	$(LIST
530 		* List item
531 		* Another list item
532 	)
533 
534 	$(NUMBERED_LIST
535 		* One
536 		* Two
537 		* Three
538 	)
539 )
540 
541 Text inside the list items is processed normally. You may nest lists, have paragraphs inside them, or anything else.
542 
543 $(TIP You can add a class name to the list element in the HTML by using the `$(CLASS)` magic macro before opening your first list item. Use this class, along with CSS, to apply custom style to the list and its items.)
544 
545 You may also use `$(RAW_HTML)` for full control of the output, or legacy Ddoc style `$(UL $(LI ...))` macros to form lists as well.
546 
547 $(H3 Tables)
548 
549 I support two table syntaxes: list tables (by row and by column, inspired by reStructuredText) and compact tables, with optional ASCII art (inspired by Markdown).
550 
551 $(H4 Compact Tables)
552 
553 A compact table consists of an optional one-line caption, a one-line header row, and any number of one-line data rows.
554 
555 Cells are separated with the `|` character. Empty cells at the beginning or end of the table are ignored, allowing you to draw an ASCII art border around the table if you like.
556 
557 The first row is always considered the header row. Columns without header text are also considered header columns.
558 
559 The minimal syntax to define a table is:
560 
561 $(ADRDOX_SAMPLE
562 	$(SMALL_TABLE
563 		Basic table caption (this line is optional)
564 		header 1|header 2
565 		data 1|data 2
566 		more data | more data
567 	)
568 )
569 
570 $(TIP Since the ddoc-style macro bracketing the table must have balanced parenthesis, any unbalanced parenthesis character inside should be put inside a $(BACKTICK)code block$(BACKTICK). You can also put pipe characters inside code blocks:
571 
572 	$(ADRDOX_SAMPLE
573 	$(SMALL_TABLE
574 		h1|h2
575 		`d1|with pipe`|d2
576 	)
577 	)
578 )
579 
580 ASCII art inside the compact table is allowed, but not required. Any line that consists only of the characters `+-=|` is assumed to be decorative and ignored by the parser. Empty lines are also ignored. White space around your cells are also ignored.
581 
582 The result is you can style it how you like. The following code will render the same way as the above table:
583 
584 $(ADRDOX_SAMPLE
585 $(SMALL_TABLE
586 	Basic table caption (this line is optional)
587 	+-----------+-----------+
588 	| header 1  | header 2  |
589 	+===========+===========+
590 	| data 1    | data 2    |
591 	| more data | more data |
592 	+-----------+-----------+
593 )
594 )
595 
596 $(H5 Two-dimensional tabular data)
597 
598 If a table has an empty upper-left cell, it is assumed to have two axes. Cells under the column with the empty header are also rendered as headers.
599 
600 Here is a two-dimensional table with and without the optional ascii art.
601 
602 $(ADRDOX_SAMPLE
603 $(SMALL_TABLE
604 
605 	XOR Truth Table
606 	+-----------+
607 	|   | 0 | 1 |
608 	+===|===|===+
609 	| 0 | F | T |
610 	| 1 | T | F |
611 	+-----------+
612 )
613 
614 $(SMALL_TABLE
615 	Alternative XOR
616 	||0|1
617 	0|F|T
618 	1|T|F
619 )
620 )
621 
622 Notice that even without the ascii art, the outer pipe is necessary to indicate that an empty cell was intended in the upper left corner.
623 
624 $(TIP
625 	If you want to make a feature table, you can do it as a compact
626 	table with any entry for yes, and no data for no.
627 
628 	$(ADRDOX_SAMPLE
629 	$(SMALL_TABLE
630 		Features
631 		|| x | y
632 		a| * |
633 		b|   | *
634 		c| * | *
635 	)
636 	)
637 
638 	You can then style these with CSS rules like `td:empty` in lieu of adding a class to each element. The empty cell on the right did not require an extra `|` because all data rows are assumed to have equal number of cells as the header row.
639 )
640 
641 $(H4 Longer tables)
642 
643 I also support a list table format, inspired by restructuredText.
644 
645 	$(ADRDOX_SAMPLE
646 	$(TABLE_ROWS
647 		Caption
648 		* + Header 1
649 		  + Header 2
650 		* - Data 1
651 		  - Data 2
652 		* - Data 1
653 		  - Data 2
654 	)
655 	)
656 
657 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.
658 
659 adrdox will also detect if you put a header on the left side of later rows, and format the table accordingly:
660 
661 	$(ADRDOX_SAMPLE
662 	$(TABLE_ROWS
663 		Caption
664 		* + Header 1
665 		  + Header 2
666 		  + Header 3
667 		* + 2D Header
668 		  - Data 1.2
669 		  - Data 1.3
670 		* + Again
671 		  - Data 1.2
672 		  - Data 2.3
673 	)
674 	)
675 
676 
677 
678 $(H4 Formatting tables)
679 
680 To format tables, including aligning text inside a column, add a class name to the tag using the magic `$(CLASS name)` macro right inside the table backeting, then target that with CSS rules in your stylesheet.
681 
682 	$(ADRDOX_SAMPLE
683 	$(RAW_HTML
684 		<style>
685 		.my-yellow-table {
686 			background-color: yellow;
687 		}
688 		</style>
689 	)
690 	$(TABLE_ROWS
691 		$(CLASS my-yellow-table)
692 		Caption
693 		* + Header 1
694 		  + Header 2
695 		* - Data 1
696 		  - Data 2
697 		* - Data 1
698 		  - Data 2
699 	)
700 	)
701 
702 
703 $(H4 More advanced tables)
704 
705 To avoid complicating the syntax in more common cases, I do not attempt to support everything possible. Notably, most cases of colspan and rowspan cannot be expressed in any of my syntaxes.
706 
707 If you need something, and all else fails, you can always use the `$(RAW_HTML)` escape hatch and write the code yourself.
708 
709 $(H2 Mathematics)
710 
711 The doc generator can also render LaTeX formulas, if latex and dvipng is installed on your system.
712 
713 $(ADRDOX_SAMPLE
714 	$(MATH \int_{1}^{\pi} \cos(x) dx )
715 )
716 
717 Note that generating these images is kinda slow. You must balance parenthesis inside the macro, and all the output images will be rendered inline, packed in the html file.
718 
719 If you can use a plain text or html character btw, you should. Don't break out MATH just for an $(INF) symbol, for example.
720 
721 $(H2 Ddoc Macro to HTML Tag reference)
722 
723 $(LIST
724 	* `$(IMG source_url, alt text)`
725 	* `$(B bold text)`
726 	* `$(I italic text)`
727 	* `$(U underlined text)`
728 	* `$(SUPERSCRIPT superscript text)`
729 	* `$(SUB subscript text)`
730 )
731 
732 $(H3 Adding ID and class attributes to HTML)
733 
734 You can add an ID or class attribute to an HTML tag by putting `$(ID id_here)` or `$(CLASS class_here)` inside a ddoc macro. It must be inside a `$(ddoc_style)` macro to be recognized.
735 
736 $(H2 Ddoc Sections)
737 
738 $(H3 List of supported DDoc Sections)
739 
740 $(LIST
741 	* `Examples:` or `Example:` gives usage examples. Documented unittests, if present and not embedded (see [#documented-unittests]), will also appear here.
742 	* `Bugs:`
743 	* `See_Also:`
744 	* `Returns:`
745 	* `Throws:`
746 	* `Deprecated:`
747 	* `Params:` uses a special `name = comment` syntax, just like ddoc, where only param names detected are printed.
748 	* `Macros:` are read, but ignored.
749 )
750 
751 Note that as an extension to ddoc, I also support doc comments on params as if it was written in the `Params:` section.
752 
753 $(H3 Meta subsections)
754 
755 The following sections, if present, will be grouped under the `Meta` header:
756 
757 $(LIST
758 	* `Authors:` or `Author:`
759 	* `Date`
760 	* `License:`
761 	* `Source:`
762 	* `History:`
763 	* `Credits:`
764 	* `Standards:`
765 	* `Copyright:`
766 	* `Version:`
767 )
768 
769 $(H3 Adrdox extension sections)
770 
771 $(LIST
772 	* `Diagnostics:` is a place to describe common errors you will see while trying to use the function, and explain how to fix them.
773 	* `Link_References:` does name=value. See [#footnotes].
774 	$(COMMENT * `Adrdox_Meta:` intrduces metadata for the generator. See [#metadata] )
775 )
776 
777 $(H3 Custom sections)
778 
779 If you start a line with `some_section:`, it will become a custom section in the document. It must have at least one underscore to be recognizes as a custom section.
780 
781 $(COMMENT
782 $(H2 Metadata)
783 
784 FIXME: NOT IMPLEMENTED
785 
786 You can add metadata about your project to a `Adrdox_Meta:` section in the doc comment attached to the module declaration. These are inherited by submodules in your project as long as the package.d with the definition is loaded (see `--load` or passed as command line arg to be generated).
787 
788 It can define:
789 $(LINK
790 	* Project name
791 	* Project logo image
792 	* Project homepage
793 	* Project color scheme: light or dark and accent color
794 	* Scripts for the project
795 )
796 )
797 
798 $(H2 Footnotes)
799 
800 adrdox supports footnotes[1] and popup notes[2], scoped to the declaration attached to the comment. The syntax is to simply write `[n]`, such as `[1]`, where you want it to be displayed, then later in the comment, write a `Link_References:` section at the end of your comment, like so:
801 
802 ```
803 Link_References:
804 	1 = https://en.wikipedia.org/wiki/Footnote
805 	2 = This note will popup inline.
806 ```
807 
808 Undefined footnote references output the plain text without modification, like [3]. Numeric footnotes can only be used locally, they must be used and defined inside the same comment.
809 
810 $(NOTE Text references must always be contained to a single line in the current implementation.)
811 
812 If you need something more complex than a single link or line of text, write a section for your notes inside your comment and use the `[n]` Link_References to link to it:
813 
814 ---
815 /++
816 	This huge complex function needs a complex footnote[1].
817 
818 	$(H2 Footnotes)
819 
820 	$(DIV $(ID note-1)
821 		This can be arbitrarily complex.
822 	)
823 
824 	Link_References:
825 		1 = [a_huge_complex_function#note-1]
826 +/
827 void a_huge_complex_function() {}
828 ---
829 
830 See that live [a_huge_complex_function|here].
831 
832 You can also do custom links, images, or popup text via the shortcut `[reference]` syntax. You can define them with a symbol name in the Link_References section:
833 
834 ```
835 Link_References:
836 	dlang = http://dlang.org/
837 	dlogo = $(IMG /d-logo.png, The D Logo)
838 	dmotto = Modern convenience. Modeling power. Native efficiency.
839 ```
840 
841 You can now reference those with `[dlang], [dlogo], and [dmotto]`, which will render thusly: [dlang], [dlogo], [dmotto]. Be aware that ONLY a single line of plain text, a single `$(IMG)`, or a single link (url or convenience reference, see below) are allowed in the `Link_References` section.
842 
843 $(NOTE
844 	Link references will override D name lookup. Be aware of name clashes that might
845 	break convenient access to in-scope symbol names.
846 )
847 
848 Like with other convenience links, you can change the displayed text by using a pipe character, like `[dlang|The D Website]`. It will continue to link to the same place or pop up the same text. If the name references an image, the text after the pipe will locally change the `alt` text on the image tag.
849 
850 Additionally, the pipe character can be used in the reference definition to change the default display text:
851 
852 ```
853 Link_References:
854 	input_range = [std.range.primitives.isInputRange|input range]
855 ```
856 
857 will always show "input range" when you write `[input_range]`, but can still be overridden by local text after the pipe, like `[input_range|an input range]`. Those will render: [input_range] and [input_range|an input range].
858 
859 $(TIP
860 	Yes, you can define link references in terms of a D reference. It will look up the name using the normal scoping rules for the attached declaration.
861 )
862 
863 $(WARNING
864 	If you use a reference in a global reference definition, it will look up the name in the scope at the *usage point*. This may change in the future.
865 )
866 
867 Unrecognized refs are forwarded to regular lookups.
868 
869 While numeric link references are strictly scoped to the declaration of the attached comment, text link references are inherited by child declarations. Thus, you can define shortcuts at module scope and use them throughout the module. You can even define one in a package and use it throughout the package, without explicitly importing the `package.d` inside the module. Link references, however, are $(I not) imported like normal D symbols. They follow a strict parent->child inheritance.
870 
871 If you need a link reference to be used over and over across packages, you may also define global link references in a text file you pass to adrdox with the `--link-references` option. The format of this text file is as follows:
872 
873 ```
874 	name = value
875 	othername = other value
876 ```
877 
878 Yes, the same as the `Link_References:` section inside a comment, but with no surrounding decoration.
879 
880 $(PITFALL Be especially careful when defining global textual link macros, because they will override normal name lookups when doing `[convenient]` cross references across the entire current documentation build set.)
881 
882 You may want to give unique, yet convenient names to common concepts used throughout your library and define them as Link_References for easy use.
883 
884 Link_References:
885 	1 = http://dpldocs.info/
886 	2 = Popup notes are done as <abbr> tags with title attributes.
887 	input_range = [std.range.primitives.isInputRange|input range]
888 	dlang = http://dlang.org/
889 	dlogo = $(IMG /d-logo.png, The D Logo)
890 	dmotto = Modern convenience. Modeling power. Native efficiency.
891 
892 $(H2 Side-by-side comparisons)
893 
894 You might want to show two things side by side to emphasize how the user's existing knowledge can be shared. You can do that with the `$(SIDE_BY_SIDE $(COLUMN))` syntax:
895 
896 $(ADRDOX_SAMPLE
897 	$(SIDE_BY_SIDE
898 		$(COLUMN
899 			```php
900 			<?php
901 				$foo = $_POST["foo"];
902 			?>
903 			```
904 		)
905 		$(COLUMN
906 			---
907 			import arsd.cgi;
908 			string foo = cgi.post["foo"];
909 			---
910 		)
911 	)
912 )
913 
914 Try to keep your columns as narrow as reasonable, so they can actually be read side-by-side!
915 
916 $(H2 Commenting stuff out in comments)
917 
918 The macro `$(COMMENT ...)` is removed from the generated document. You can use it to comment
919 stuff out of your comment. Of course, you can also just use regular `/*` comments instead of
920 `/**`.
921 
922 $(H2 Always Documenting Something)
923 
924 If you want something to always be documented, even if it is private, add `$(ALWAYS_DOCUMENT)` to its comment somewhere.
925 
926 $(H2 Never Documenting Something)
927 
928 If you want something to NEVER be documented, even if adrdox is run with --document-undocumented and other switches, add `$(NEVER_DOCUMENT)` to its comment somewhere. You should use this very rarely.
929 
930 $(H2 Documentable Constructs)
931 
932 adrdox allows documenting more language constructs than ddoc. It lets you document public imports, postblits, destructors, anonymous enums, and more. Try putting a doc comment on almost anything and see what happens!
933 
934 +/
935 module adrdox.syntax;
936 
937 /+
938 /// first
939 struct A {
940 	/// second
941 	union {
942 		/// third
943 		int a;
944 		/// fourth
945 		int b;
946 	}
947 }
948 +/
949 
950 
951 /*
952 
953 $(H3 Code with output)
954 
955 The magic macro `$(CODE_WITH_OUTPUT)` is used to pair a block of code with a block of output, side-by-side. The first code block in the macro is considered the code, and the rest of the content is the output.
956 
957 As a special case, if the code is of the `adrdox` language, you do not need to provide output; it will render automatically. (I added that feature to make writing this document easer.) I might add other language filters too, probably by piping it out to some command line, if there's demand for it.
958 
959 I intend for this to be used to show syntax translations, but any time where a side-by-side view may be useful you can give it a try.
960 
961 */
962 /++
963 	This huge complex function needs a complex footnote[1].
964 
965 	$(H2 Footnotes)
966 
967 	$(DIV $(ID note-1)
968 		This can be arbitrarily complex.
969 	)
970 
971 	Link_References:
972 		1 = [a_huge_complex_function#note-1]
973 +/
974 void a_huge_complex_function() {}
975 
976 ///
977 void test() {}