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 (New 12 Dec 2021) You can also get a UDA's arguments as a source string with `$(UDA_STRING)`.
375 
376 ---
377 struct MyUDA { string s; }
378 
379 /// The uda says $(UDA_STRING MyUDA).
380 @MyUDA("cool") void foo() {}
381 ---
382 
383 Please note it does NOT actually perform any evaluations - it is just string lookup on the left side of the parenthesis to find the string that is inside the parenthesis. This might change at a later date.
384 
385 $(H2 Paragraph detection)
386 
387 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.)
388 
389 $(H2 Images)
390 
391 You can post images with `$(IMG source_url, alt text)`. The default CSS will put some reasonable size limits and margin on it.
392 
393 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).
394 
395 FIXME: implement and document `$(LEFT )`, `$(RIGHT )`, and `$(CENTERED )`.
396 
397 You may also use inline `$(SVG )` or `$(RAW_HTML)`. FIXME
398 
399 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).
400 
401 Note that if the parens are not there, it is normal![1] (code there: `normal![1]`)
402 
403 $(H2 Headers)
404 
405 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.
406 
407 Custom ddoc sections (see below) are translated into `<h3>` headers.
408 
409 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:
410 
411 $(LIST
412 	* The header must be preceded by a blank line
413 	* The `====` must be directly below the header
414 	* The `====` must be followed by a blank line
415 	* There must be at least 4 `=` on the line, and no other text (excluding whitespace).
416 )
417 
418 $(ADRDOX_SAMPLE
419 
420 	This is some text preceding the header.
421 
422 	This is the header
423 	==================
424 
425 	This is a paragraph under that header.
426 )
427 
428 Moreover, markdown style `## Header` are also supported. The number of `#` characters indicate the header level (1-6). Similar restrictions apply:
429 
430 $(LIST
431 	* The header must be preceded by and followed by a blank line
432 	* The `#` must be the first non-whitespace character on the line
433 	* There must be a space following the `#` characters.
434 )
435 
436 $(ADRDOX_SAMPLE
437 
438 	# H1
439 
440 	## H2
441 
442 	### H3
443 
444 	#not a header, missing space
445 
446 	a # is not a header
447 
448 	Nor is the following a header
449 	# because it is not preceded by a blank line
450 )
451 
452 $(H3 Ddoc sections)
453 
454 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.
455 
456 `Examples:` (or `Example:`) is special in that documented unit tests are appended here.
457 
458 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.
459 
460 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.
461 
462 $(ADRDOX_SAMPLE
463 	$(H2 A header)
464 		Some content
465 	$(H3 Another header)
466 		Some more content
467 
468 	A_Ddoc_Style_Header:
469 		And some content
470 )
471 
472 
473 $(H2 Content blocks)
474 
475 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.
476 
477 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:
478 
479 `$(TIP)` is a cool fact to help you make the most of the code.
480 
481 `$(NOTE)` is something the reader should be aware of, but they can get it wrong without major consequence.
482 
483 `$(WARNING)` is something they need to watch out for, such as potential crashes or memory leaks when using the function.
484 
485 `$(PITFALL)` is something that users very commonly get wrong and you want them to see it to avoid making the same mistake yet again.
486 
487 `$(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.
488 
489 $(H2 Fancier Formatting)
490 
491 $(SIDEBAR
492 	$(H3 Why use macro syntax to bracket it instead of trying to detect like Markdown does?)
493 
494 	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.
495 
496 	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.
497 )
498 
499 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.
500 
501 
502 $(H3 Blockquotes)
503 
504 Use the `$(BLOCKQUOTE)` macro to surround the quote. It will render as you expected.
505 
506 $(ADRDOX_SAMPLE
507 	$(BLOCKQUOTE
508 		This is a quote! You can write whatever you want in here.
509 
510 		Including paragraphs, and other content. Unlike markdown, you
511 		do not need to write `>` or spaces or anything else before every
512 		line, instead you just wrap the whole thing in `$(BLOCKQUOTE)`.
513 
514 		If it has unbalanced parenthesis, you can use `$(LPAREN)` or `$(RPAREN)`
515 		for them.
516 	)
517 )
518 
519 $(H3 Lists)
520 
521 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.
522 
523 Inside the magic list macros, a `*` character at the beginning of a line will create a new list item.
524 
525 $(WARNING
526 	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:
527 
528 	---
529 	/**
530 	  * one of these
531 	  */
532 	---
533 
534 	Since the preprocessor runs before analyzing brackets, it won't know that the star was intentional.
535 
536 	I recommend indenting your list stars by at least 4 spaces or one tab for best results.
537 )
538 
539 $(ADRDOX_SAMPLE
540 	$(LIST
541 		* List item
542 		* Another list item
543 	)
544 
545 	$(NUMBERED_LIST
546 		* One
547 		* Two
548 		* Three
549 	)
550 )
551 
552 Text inside the list items is processed normally. You may nest lists, have paragraphs inside them, or anything else.
553 
554 $(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.)
555 
556 You may also use `$(RAW_HTML)` for full control of the output, or legacy Ddoc style `$(UL $(LI ...))` macros to form lists as well.
557 
558 $(H3 Tables)
559 
560 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).
561 
562 $(H4 Compact Tables)
563 
564 A compact table consists of an optional one-line caption, a one-line header row, and any number of one-line data rows.
565 
566 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.
567 
568 The first row is always considered the header row. Columns without header text are also considered header columns.
569 
570 The minimal syntax to define a table is:
571 
572 $(ADRDOX_SAMPLE
573 	$(SMALL_TABLE
574 		Basic table caption (this line is optional)
575 		header 1|header 2
576 		data 1|data 2
577 		more data | more data
578 	)
579 )
580 
581 $(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:
582 
583 	$(ADRDOX_SAMPLE
584 	$(SMALL_TABLE
585 		h1|h2
586 		`d1|with pipe`|d2
587 	)
588 	)
589 )
590 
591 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.
592 
593 The result is you can style it how you like. The following code will render the same way as the above table:
594 
595 $(ADRDOX_SAMPLE
596 $(SMALL_TABLE
597 	Basic table caption (this line is optional)
598 	+-----------+-----------+
599 	| header 1  | header 2  |
600 	+===========+===========+
601 	| data 1    | data 2    |
602 	| more data | more data |
603 	+-----------+-----------+
604 )
605 )
606 
607 $(H5 Two-dimensional tabular data)
608 
609 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.
610 
611 Here is a two-dimensional table with and without the optional ascii art.
612 
613 $(ADRDOX_SAMPLE
614 $(SMALL_TABLE
615 
616 	XOR Truth Table
617 	+-----------+
618 	|   | 0 | 1 |
619 	+===|===|===+
620 	| 0 | F | T |
621 	| 1 | T | F |
622 	+-----------+
623 )
624 
625 $(SMALL_TABLE
626 	Alternative XOR
627 	||0|1
628 	0|F|T
629 	1|T|F
630 )
631 )
632 
633 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.
634 
635 $(TIP
636 	If you want to make a feature table, you can do it as a compact
637 	table with any entry for yes, and no data for no.
638 
639 	$(ADRDOX_SAMPLE
640 	$(SMALL_TABLE
641 		Features
642 		|| x | y
643 		a| * |
644 		b|   | *
645 		c| * | *
646 	)
647 	)
648 
649 	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.
650 )
651 
652 $(H4 Longer tables)
653 
654 I also support a list table format, inspired by restructuredText.
655 
656 	$(ADRDOX_SAMPLE
657 	$(TABLE_ROWS
658 		Caption
659 		* + Header 1
660 		  + Header 2
661 		* - Data 1
662 		  - Data 2
663 		* - Data 1
664 		  - Data 2
665 	)
666 	)
667 
668 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.
669 
670 adrdox will also detect if you put a header on the left side of later rows, and format the table accordingly:
671 
672 	$(ADRDOX_SAMPLE
673 	$(TABLE_ROWS
674 		Caption
675 		* + Header 1
676 		  + Header 2
677 		  + Header 3
678 		* + 2D Header
679 		  - Data 1.2
680 		  - Data 1.3
681 		* + Again
682 		  - Data 1.2
683 		  - Data 2.3
684 	)
685 	)
686 
687 
688 
689 $(H4 Formatting tables)
690 
691 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.
692 
693 	$(ADRDOX_SAMPLE
694 	$(RAW_HTML
695 		<style>
696 		.my-yellow-table {
697 			background-color: yellow;
698 		}
699 		</style>
700 	)
701 	$(TABLE_ROWS
702 		$(CLASS my-yellow-table)
703 		Caption
704 		* + Header 1
705 		  + Header 2
706 		* - Data 1
707 		  - Data 2
708 		* - Data 1
709 		  - Data 2
710 	)
711 	)
712 
713 
714 $(H4 More advanced tables)
715 
716 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.
717 
718 If you need something, and all else fails, you can always use the `$(RAW_HTML)` escape hatch and write the code yourself.
719 
720 $(H2 Mathematics)
721 
722 The doc generator can also render LaTeX formulas, if latex and dvipng is installed on your system.
723 
724 $(ADRDOX_SAMPLE
725 	$(MATH \int_{1}^{\pi} \cos(x) dx )
726 )
727 
728 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.
729 
730 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.
731 
732 $(H2 Ddoc Macro to HTML Tag reference)
733 
734 $(LIST
735 	* `$(IMG source_url, alt text)`
736 	* `$(B bold text)`
737 	* `$(I italic text)`
738 	* `$(U underlined text)`
739 	* `$(SUPERSCRIPT superscript text)`
740 	* `$(SUB subscript text)`
741 )
742 
743 $(H3 Adding ID and class attributes to HTML)
744 
745 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.
746 
747 $(H2 Ddoc Sections)
748 
749 $(H3 List of supported DDoc Sections)
750 
751 $(LIST
752 	* `Examples:` or `Example:` gives usage examples. Documented unittests, if present and not embedded (see [#documented-unittests]), will also appear here.
753 	* `Bugs:`
754 	* `See_Also:`
755 	* `Returns:`
756 	* `Throws:`
757 	* `Deprecated:`
758 	* `Params:` uses a special `name = comment` syntax, just like ddoc, where only param names detected are printed.
759 	* `Macros:` are read, but ignored.
760 )
761 
762 Note that as an extension to ddoc, I also support doc comments on params as if it was written in the `Params:` section.
763 
764 $(H3 Meta subsections)
765 
766 The following sections, if present, will be grouped under the `Meta` header:
767 
768 $(LIST
769 	* `Authors:` or `Author:`
770 	* `Date`
771 	* `License:`
772 	* `Source:`
773 	* `History:`
774 	* `Credits:`
775 	* `Standards:`
776 	* `Copyright:`
777 	* `Version:`
778 )
779 
780 $(H3 Adrdox extension sections)
781 
782 $(LIST
783 	* `Diagnostics:` is a place to describe common errors you will see while trying to use the function, and explain how to fix them.
784 	* `Link_References:` does name=value. See [#footnotes].
785 	$(COMMENT * `Adrdox_Meta:` intrduces metadata for the generator. See [#metadata] )
786 )
787 
788 $(H3 Custom sections)
789 
790 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.
791 
792 $(COMMENT
793 $(H2 Metadata)
794 
795 FIXME: NOT IMPLEMENTED
796 
797 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).
798 
799 It can define:
800 $(LINK
801 	* Project name
802 	* Project logo image
803 	* Project homepage
804 	* Project color scheme: light or dark and accent color
805 	* Scripts for the project
806 )
807 )
808 
809 $(H2 Footnotes)
810 
811 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:
812 
813 ```
814 Link_References:
815 	1 = https://en.wikipedia.org/wiki/Footnote
816 	2 = This note will popup inline.
817 ```
818 
819 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.
820 
821 $(NOTE Text references must always be contained to a single line in the current implementation.)
822 
823 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:
824 
825 ---
826 /++
827 	This huge complex function needs a complex footnote[1].
828 
829 	$(H2 Footnotes)
830 
831 	$(DIV $(ID note-1)
832 		This can be arbitrarily complex.
833 	)
834 
835 	Link_References:
836 		1 = [a_huge_complex_function#note-1]
837 +/
838 void a_huge_complex_function() {}
839 ---
840 
841 See that live [a_huge_complex_function|here].
842 
843 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:
844 
845 ```
846 Link_References:
847 	dlang = http://dlang.org/
848 	dlogo = $(IMG /d-logo.png, The D Logo)
849 	dmotto = Modern convenience. Modeling power. Native efficiency.
850 ```
851 
852 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.
853 
854 $(NOTE
855 	Link references will override D name lookup. Be aware of name clashes that might
856 	break convenient access to in-scope symbol names.
857 )
858 
859 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.
860 
861 Additionally, the pipe character can be used in the reference definition to change the default display text:
862 
863 ```
864 Link_References:
865 	input_range = [std.range.primitives.isInputRange|input range]
866 ```
867 
868 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].
869 
870 $(TIP
871 	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.
872 )
873 
874 $(WARNING
875 	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.
876 )
877 
878 Unrecognized refs are forwarded to regular lookups.
879 
880 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.
881 
882 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:
883 
884 ```
885 	name = value
886 	othername = other value
887 ```
888 
889 Yes, the same as the `Link_References:` section inside a comment, but with no surrounding decoration.
890 
891 $(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.)
892 
893 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.
894 
895 Link_References:
896 	1 = http://dpldocs.info/
897 	2 = Popup notes are done as <abbr> tags with title attributes.
898 	input_range = [std.range.primitives.isInputRange|input range]
899 	dlang = http://dlang.org/
900 	dlogo = $(IMG /d-logo.png, The D Logo)
901 	dmotto = Modern convenience. Modeling power. Native efficiency.
902 
903 $(H2 Side-by-side comparisons)
904 
905 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:
906 
907 $(ADRDOX_SAMPLE
908 	$(SIDE_BY_SIDE
909 		$(COLUMN
910 			```php
911 			<?php
912 				$foo = $_POST["foo"];
913 			?>
914 			```
915 		)
916 		$(COLUMN
917 			---
918 			import arsd.cgi;
919 			string foo = cgi.post["foo"];
920 			---
921 		)
922 	)
923 )
924 
925 Try to keep your columns as narrow as reasonable, so they can actually be read side-by-side!
926 
927 $(H2 Commenting stuff out in comments)
928 
929 The macro `$(COMMENT ...)` is removed from the generated document. You can use it to comment
930 stuff out of your comment. Of course, you can also just use regular `/*` comments instead of
931 `/**`.
932 
933 $(H2 Always Documenting Something)
934 
935 If you want something to always be documented, even if it is private, add `$(ALWAYS_DOCUMENT)` to its comment somewhere.
936 
937 $(H2 Never Documenting Something)
938 
939 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.
940 
941 $(H2 Documentable Constructs)
942 
943 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!
944 
945 +/
946 module adrdox.syntax;
947 
948 /+
949 /// first
950 struct A {
951 	/// second
952 	union {
953 		/// third
954 		int a;
955 		/// fourth
956 		int b;
957 	}
958 }
959 +/
960 
961 
962 /*
963 
964 $(H3 Code with output)
965 
966 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.
967 
968 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.
969 
970 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.
971 
972 */
973 /++
974 	This huge complex function needs a complex footnote[1].
975 
976 	$(H2 Footnotes)
977 
978 	$(DIV $(ID note-1)
979 		This can be arbitrarily complex.
980 	)
981 
982 	Link_References:
983 		1 = [a_huge_complex_function#note-1]
984 +/
985 void a_huge_complex_function() {}
986 
987 ///
988 void test() {}