root/trunk/docsrc/ddoc.dd

Revision 2209, 26.4 kB (checked in by walter, 1 year ago)

update documentation

  • Property svn:eol-style set to native
Line 
1 Ddoc
2
3 $(SPEC_S Embedded Documentation,
4
5 $(P
6 The D programming language enables embedding both contracts and test
7 code along side the actual code, which helps to keep them all
8 consistent with each other. One thing lacking is the documentation,
9 as ordinary comments are usually unsuitable for automated extraction
10 and formatting into manual pages.
11 Embedding the user documentation into the source code has important
12 advantages, such as not having to write the documentation twice, and
13 the likelihood of the documentation staying consistent with the code.
14 )
15
16 $(P
17 Some existing approaches to this are:
18 )
19
20 $(UL
21 $(LI <a href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a> which already has some support for D)
22 $(LI Java's <a href="http://java.sun.com/j2se/javadoc/">Javadoc</a>,
23  probably the most well-known)
24 $(LI C#'s <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcoriXMLDocumentation.asp">embedded XML</a>)
25 $(LI Other <a href="http://www.python.org/sigs/doc-sig/otherlangs.html">documentation tools</a>)
26 )
27
28 $(P
29 D's goals for embedded documentation are:
30 )
31
32 $(OL
33     $(LI It looks good as embedded documentation, not just after it
34     is extracted and processed.)
35     $(LI It's easy and natural to write,
36     i.e. minimal reliance on &lt;tags&gt; and other clumsy forms one
37     would never see in a finished document.)
38     $(LI It does not repeat information that the compiler already
39     knows from parsing the code.)
40     $(LI It doesn't rely on embedded HTML, as such will impede
41     extraction and formatting for other purposes.)
42     $(LI It's based on existing D comment forms, so it
43     is completely independent of parsers only interested in D code.)
44     $(LI It should look and feel different from code, so it won't
45     be visually confused with code.)
46     $(LI It should be possible for the user to use Doxygen or other
47     documentation extractor if desired.)
48 )
49
50 <h2>Specification</h2>
51
52 $(P
53 The specification for the form of embedded documentation comments only
54 specifies how information is to be presented to the compiler.
55 It is implementation-defined how that information is used and the form
56 of the final presentation. Whether the final presentation form is an
57 HTML web page, a man page, a PDF file, etc. is not specified as part of the
58 D Programming Language.
59 )
60
61 <h3>Phases of Processing</h3>
62
63 $(P
64 Embedded documentation comments are processed in a series of phases:
65 )
66
67 $(OL
68     $(LI Lexical - documentation comments are identified and attached
69     to tokens.)
70     $(LI Parsing - documentation comments are associated with
71     specific declarations and combined.)
72     $(LI Sections - each documentation comment is divided up into
73     a sequence of sections.)
74     $(LI Special sections are processed.)
75     $(LI Highlighting of non-special sections is done.)
76     $(LI All sections for the module are combined.)
77     $(LI Macro text substitution is performed to produce the final result.)
78 )
79
80 <h3>Lexical</h3>
81
82 $(P
83 Embedded documentation comments are one of the following forms:
84 )
85
86 $(OL
87     $(LI $(D_COMMENT /** ... */) The two *'s after the opening /)
88     $(LI $(D_COMMENT /++ ... +/) The two +'s after the opening /)
89     $(LI $(D_COMMENT ///) The three slashes)
90 )
91
92 $(P The following are all embedded documentation comments:)
93
94 ---------------------------
95 /// This is a one line documentation comment.
96
97 /** So is this. */
98
99 /++ And this. +/
100
101 /**
102    This is a brief documentation comment.
103  */
104
105 /**
106  * The leading * on this line is not part of the documentation comment.
107  */
108
109 /*********************************
110    The extra *'s immediately following the /** are not
111    part of the documentation comment.
112  */
113
114 /++
115    This is a brief documentation comment.
116  +/
117
118 /++
119  + The leading + on this line is not part of the documentation comment.
120  +/
121
122 /+++++++++++++++++++++++++++++++++
123    The extra +'s immediately following the / ++ are not
124    part of the documentation comment.
125  +/
126
127 /**************** Closing *'s are not part *****************/
128 ---------------------------
129
130 $(P
131 The extra *'s and +'s on the comment opening, closing and left margin are
132 ignored and are not part
133 of the embedded documentation.
134 Comments not following one of those forms are not documentation comments.
135 )
136
137 <h3>Parsing</h3>
138
139 $(P
140 Each documentation comment is associated with a declaration.
141 If the documentation comment is on a line by itself or with only whitespace
142 to the left, it refers to the next
143 declaration.
144 Multiple documentation comments applying to the same declaration
145 are concatenated.
146 Documentation comments not associated with a declaration are ignored.
147 Documentation comments preceding the $(I ModuleDeclaration) apply to the
148 entire module.
149 If the documentation comment appears on the same line to the right of a
150 declaration, it applies to that.
151 )
152
153 $(P
154 If a documentation comment for a declaration consists only of the
155 identifier $(TT ditto)
156 then the documentation comment for the previous declaration at the same
157 declaration scope is applied to this declaration as well.
158 )
159
160 $(P
161 If there is no documentation comment for a declaration, that declaration
162 may not appear in the output. To ensure it does appear in the output,
163 put an empty declaration comment for it.
164 )
165
166 ------------------------------------
167 int a;  /// documentation for a; b has no documentation
168 int b;
169
170 /** documentation for c and d */
171 /** more documentation for c and d */
172 int c;
173 /** ditto */
174 int d;
175
176 /** documentation for e and f */ int e;
177 int f;  /// ditto
178
179 /** documentation for g */
180 int g; /// more documentation for g
181
182 /// documentation for C and D
183 class C {
184     int x;    /// documentation for C.x
185
186     /** documentation for C.y and C.z */
187     int y;
188     int z;    /// ditto
189 }
190
191 /// ditto
192 class D { }
193 ------------------------------------
194
195 <h3>Sections</h3>
196
197 $(P
198 The document comment is a series of $(I Section)s.
199 A $(I Section) is a name that is the first non-blank character on
200 a line immediately followed by a ':'. This name forms the section name.
201 The section name is not case sensitive.
202 )
203
204 <h4>Summary</h4>
205
206 $(P
207 The first section is the $(I Summary), and does not have a section name.
208 It is first paragraph, up to a blank line or a section name.
209 While the summary can be any length, try to keep it to one line.
210 The $(I Summary) section is optional.
211 )
212
213 <h4>Description</h4>
214
215 $(P
216 The next unnamed section is the $(I Description).
217 It consists of all the paragraphs following the $(I Summary) until
218 a section name is encountered or the end of the comment.
219 )
220
221 $(P
222 While the $(I Description) section is optional,
223 there cannot be a $(I Description) without a $(I Summary) section.
224 )
225
226 ------------------------------------
227 /***********************************
228  * Brief summary of what
229  * myfunc does, forming the summary section.
230  *
231  * First paragraph of synopsis description.
232  *
233  * Second paragraph of
234  * synopsis description.
235  */
236
237 void myfunc() { }
238 ------------------------------------
239
240 $(P
241 Named sections follow the $(I Summary) and $(I Description) unnamed sections.
242 )
243
244 <h3>Standard Sections</h3>
245
246 $(P
247 For consistency and predictability, there are several standard sections.
248 None of these are required to be present.
249 )
250
251 <dl>
252
253 <dt> $(B Authors:)
254 <dd> Lists the author(s) of the declaration.
255 ------------------------------------
256 /**
257  * Authors: Melvin D. Nerd, melvin@mailinator.com
258  */
259 ------------------------------------
260
261 <dt> $(B Bugs:)
262 <dd> Lists any known bugs.
263 ------------------------------------
264 /**
265  * Bugs: Doesn't work for negative values.
266  */
267 ------------------------------------
268
269 <dt> $(B Date:)
270 <dd> Specifies the date of the current revision. The date should be in a form
271      parseable by std.date.
272
273 ------------------------------------
274 /**
275  * Date: March 14, 2003
276  */
277 ------------------------------------
278
279 <dt> $(B Deprecated:)
280 <dd> Provides an explanation for and corrective action to take if the associated
281      declaration is marked as deprecated.
282
283 ------------------------------------
284 /**
285  * Deprecated: superseded by function bar().
286  */
287
288 deprecated void foo() { ... }
289 ------------------------------------
290
291 <dt> $(B Examples:)
292 <dd> Any usage examples
293 ------------------------------------
294 /**
295  * Examples:
296  * --------------------
297  * writefln("3"); // writes '3' to stdout
298  * --------------------
299  */
300 ------------------------------------
301
302 <dt> $(B History:)
303 <dd> Revision history.
304 ------------------------------------
305 /**
306  * History:
307  *  V1 is initial version
308  *
309  *  V2 added feature X
310  */
311 ------------------------------------
312
313 <dt> $(B License:)
314 <dd> Any license information for copyrighted code.
315 ------------------------------------
316 /**
317  * License: use freely for any purpose
318  */
319
320 void bar() { ... }
321 ------------------------------------
322
323 <dt> $(B Returns:)
324 <dd> Explains the return value of the function.
325      If the function returns $(B void), don't redundantly document it.
326 ------------------------------------
327 /**
328  * Read the file.
329  * Returns: The contents of the file.
330  */
331
332 void[] readFile(char[] filename) { ... }
333 ------------------------------------
334
335 <dt> $(B See_Also:)
336 <dd> List of other symbols and URL's to related items.
337 ------------------------------------
338 /**
339  * See_Also:
340  *    foo, bar, http://www.digitalmars.com/d/phobos/index.html
341  */
342 ------------------------------------
343
344 <dt> $(B Standards:)
345 <dd> If this declaration is compliant with any particular standard,
346 the description of it goes here.
347 ------------------------------------
348 /**
349  * Standards: Conforms to DSPEC-1234
350  */
351 ------------------------------------
352
353 <dt> $(B Throws:)
354 <dd> Lists exceptions thrown and under what circumstances they are thrown.
355 ------------------------------------
356 /**
357  * Write the file.
358  * Throws: WriteException on failure.
359  */
360
361 void writeFile(char[] filename) { ... }
362 ------------------------------------
363
364 <dt> $(B Version:)
365 <dd> Specifies the current version of the declaration.
366 ------------------------------------
367 /**
368  * Version: 1.6a
369  */
370 ------------------------------------
371 </dl>
372
373 <h3>Special Sections</h3>
374
375 $(P
376 Some sections have specialized meanings and syntax.
377 )
378
379 <dl>
380
381 <dt> $(B Copyright:)
382 <dd> This contains the copyright notice. The macro COPYRIGHT is set to
383      the contents of the section when it documents the module declaration.
384      The copyright section only gets this special treatment when it
385      is for the module declaration.
386
387 ------------------------------------
388 /** Copyright: Public Domain */
389
390 module foo;
391 ------------------------------------
392
393 <dt> $(B Params:)
394 <dd> Function parameters can be documented by listing them in a params
395      section. Each line that starts with an identifier followed by
396      an '=' starts a new parameter description. A description can
397      span multiple lines.
398
399 ------------------------
400 /***********************************
401  * foo does this.
402  * Params:
403  *  x = is for this
404  *      and not for that
405  *  y = is for that
406  */
407
408 void foo(int x, int y)
409 {
410 }
411 -------------------------
412
413 <dt> $(B Macros:) </dt>
414 <dd> The macros section follows the same syntax as the $(B Params:) section.
415      It's a series of $(I NAME)=$(I value) pairs.
416      The $(I NAME) is the macro name, and $(I value) is the replacement
417      text.
418 ------------------------------------
419 /**
420  * Macros:
421  *  FOO =   now is the time for
422  *      all good men
423  *  BAR =   bar
424  *  MAGENTA =   &lt;font color=magenta&gt;$0&lt;/font&gt;
425  */
426 ------------------------------------
427 </dl>
428
429 <h2>Highlighting</h2>
430
431 <h4>Embedded Comments</h4>
432
433 $(P
434     The documentation comments can themselves be commented using
435     the &#36;(DDOC_COMMENT comment text) syntax. These comments do not
436     nest.
437 )
438
439 <h4>Embedded Code</h4>
440
441 $(P
442     D code can be embedded using lines with at least three hyphens
443     in them to delineate the code section:
444 )
445
446 ------------------------------------
447  /++++++++++++++++++++++++
448   + Our function.
449   + Example:
450   + --------------------------
451   +  import std.stdio;
452   +
453   +  void foo()
454   +  {
455   + writefln("foo!");  /* print the string */
456   +  }
457   + --------------------------
458   +/
459 ------------------------------------
460
461 $(P
462     Note that the documentation comment uses the $(D_COMMENT /++ ... +/)
463     form
464     so that $(D_COMMENT /* ... */) can be used inside the code section.
465 )
466
467 <h4>Embedded HTML</h4>
468
469 $(P
470 HTML can be embedded into the documentation comments, and it will
471 be passed through to the HTML output unchanged.
472 However, since it is not necessarily true that HTML will be the desired
473 output format of the embedded documentation comment extractor, it is
474 best to avoid using it where practical.
475 )
476
477 ------------------------------------
478 /** Example of embedded HTML:
479  *   $(OL
480  *      <li> <a href="http://www.digitalmars.com">Digital Mars</a> </li>
481  *      <li> <a href="http://www.classicempire.com">Empire</a> </li>
482  *   )
483  */
484 ------------------------------------
485
486 <h4>Emphasis</h4>
487
488 $(P
489 Identifiers in documentation comments that are function parameters or are
490 names that are in scope at the associated declaration are emphasized in
491 the output.
492 This emphasis can take the form of italics, boldface, a hyperlink, etc.
493 How it is emphasized depends on what it is - a function parameter, type,
494 D keyword, etc.
495 To prevent unintended emphasis of an identifier, it can be preceded by
496 an underscore (_). The underscore will be stripped from the output.
497 )
498
499 <h4>Character Entities</h4>
500
501 $(P
502     Some characters have special meaning
503     to the documentation processor, to avoid confusion it can be best
504     to replace them with their corresponding character entities:
505 )
506
507     $(TABLE2 Characters and Entities,
508     $(TR $(TH Character) $(TH Entity))
509     $(TR $(TD &lt;  )$(TD &amp;lt; ))
510     $(TR $(TD &gt;  )$(TD &amp;gt; ))
511     $(TR $(TD &amp; )$(TD &amp;amp; ))
512     )
513
514 $(P
515     It is not necessary to do this inside a code section, or if the
516     special character is not immediately followed by a # or a letter.
517 )
518
519 <h4>No Documentation<h4>
520
521 $(P
522     No documentation is generated for the following constructs,
523     even if they have a documentation comment:
524 )
525
526     $(UL
527     $(LI Invariants)
528 $(V2    $(LI Postblits))
529     $(LI Destructors)
530     $(LI Static constructors and static destructors)
531     $(LI Class info, type info, and module info)
532     )
533
534 <h2>Macros</h2>
535
536 $(P
537     The documentation comment processor includes a simple macro
538     text preprocessor.
539     When a &#36;($(I NAME)) appears
540     in section text it is replaced with $(I NAME)'s corresponding
541     replacement text.
542     The replacement text is then recursively scanned for more macros.
543     If a macro is recursively encountered, with no argument or with
544     the same argument text as the enclosing macro, it is replaced
545     with no text.
546     Macro invocations that cut across replacement text boundaries are
547     not expanded.
548     If the macro name is undefined, the replacement text has no characters
549     in it.
550     If a &#36;(NAME) is desired to exist in the output without being
551     macro expanded, the $ should be replaced with &amp;#36;.
552 )
553
554 $(P
555     Macros can have arguments. Any text from the end of the identifier
556     to the closing $(SINGLEQUOTE $(RPAREN)) is the &#36;0 argument.
557     A &#36;0 in the replacement text is
558     replaced with the argument text.
559     If there are commas in the argument text, &#36;1 will represent the
560     argument text up to the first comma, &#36;2 from the first comma to
561     the second comma, etc., up to &#36;9.
562     &#36;+ represents the text from the first comma to the closing $(SINGLEQUOTE $(RPAREN)).
563     The argument text can contain nested parentheses, "" or '' strings,
564     <!-- ... --> comments, or tags.
565     If stray, unnested parentheses are used, they can be replaced with
566     the entity &amp;#40; for ( and &amp;#41; for ).
567 )
568
569 $(P
570     Macro definitions come from the following sources,
571     in the specified order:
572 )
573
574     $(OL
575     $(LI Predefined macros.)
576     $(LI Definitions from file specified by $(LINK2 dmd-windows.html#sc_ini, sc.ini)'s
577     or $(LINK2 dmd-linux.html#dmd_conf, dmd.conf) DDOCFILE setting.)
578     $(LI Definitions from *.ddoc files specified on the command line.)
579     $(LI Runtime definitions generated by Ddoc.)
580     $(LI Definitions from any Macros: sections.)
581     )
582
583 $(P
584     Macro redefinitions replace previous definitions of the same name.
585     This means that the sequence of macro definitions from the various
586     sources forms a hierarchy.
587 )
588
589 $(P
590     Macro names beginning with "D_" and "DDOC_" are reserved.
591 )
592
593 <h3>Predefined Macros</h3>
594
595 $(P
596     These are hardwired into Ddoc, and represent the
597     minimal definitions needed by Ddoc to format and highlight
598     the presentation.
599     The definitions are for simple HTML.
600 )
601
602 $(DDOCCODE
603 B = &lt;b&gt;&#36;0&lt;/b&gt;
604 I = &lt;i&gt;&#36;0&lt;/i&gt;
605 U = &lt;u&gt;&#36;0&lt;/u&gt;
606 P = &lt;p&gt;&#36;0&lt;/p&gt;
607 DL =    &lt;dl&gt;&#36;0&lt;/dl&gt;
608 DT =    &lt;dt&gt;&#36;0&lt;/dt&gt;
609 DD =    &lt;dd&gt;&#36;0&lt;/dd&gt;
610 TABLE = &lt;table&gt;&#36;0&lt;/table&gt;
611 TR =    &lt;tr&gt;&#36;0&lt;/tr&gt;
612 TH =    &lt;th&gt;&#36;0&lt;/th&gt;
613 TD =    &lt;td&gt;&#36;0&lt;/td&gt;
614 OL =    &lt;ol&gt;&#36;0&lt;/ol&gt;
615 UL =    &lt;ul&gt;&#36;0&lt;/ul&gt;
616 LI =    &lt;li&gt;&#36;0&lt;/li&gt;
617 BIG =   &lt;big&gt;&#36;0&lt;/big&gt;
618 SMALL = &lt;small&gt;&#36;0&lt;/small&gt;
619 BR =    &lt;br&gt;
620 LINK =  &lt;a href="&#36;0"&gt;&#36;0&lt;/a&gt;
621 LINK2 = &lt;a href="&#36;1"&gt;&#36;+&lt;/a&gt;
622 LPAREN= $(LPAREN)
623 RPAREN= $(RPAREN)
624
625 RED =   &lt;font color=red&gt;&#36;0&lt;/font&gt;
626 BLUE =  &lt;font color=blue&gt;&#36;0&lt;/font&gt;
627 GREEN = &lt;font color=green&gt;&#36;0&lt;/font&gt;
628 YELLOW =&lt;font color=yellow&gt;&#36;0&lt;/font&gt;
629 BLACK = &lt;font color=black&gt;&#36;0&lt;/font&gt;
630 WHITE = &lt;font color=white&gt;&#36;0&lt;/font&gt;
631
632 D_CODE = &lt;pre class="d_code"&gt;&#36;0&lt;/pre&gt;
633 D_COMMENT = &#36;(GREEN &#36;0)
634 D_STRING  = &#36;(RED &#36;0)
635 D_KEYWORD = &#36;(BLUE &#36;0)
636 D_PSYMBOL = &#36;(U &#36;0)
637 D_PARAM   = &#36;(I &#36;0)
638
639 DDOC =  &lt;html&gt;&lt;head&gt;
640     &lt;META http-equiv="content-type" content="text/html; charset=utf-8"&gt;
641     &lt;title&gt;&#36;(TITLE)&lt;/title&gt;
642     &lt;/head&gt;&lt;body&gt;
643     &lt;h1&gt;&#36;(TITLE)&lt;/h1&gt;
644     &#36;(BODY)
645     &lt;/body&gt;&lt;/html&gt;
646
647 DDOC_COMMENT   = &lt;!-- &#36;0 --&gt;
648 DDOC_DECL      = &#36;(DT &#36;(BIG &#36;0))
649 DDOC_DECL_DD   = &#36;(DD &#36;0)
650 DDOC_DITTO     = &#36;(BR)&#36;0
651 DDOC_SECTIONS  = &#36;0
652 DDOC_SUMMARY   = &#36;0&#36;(BR)&#36;(BR)
653 DDOC_DESCRIPTION = &#36;0&#36;(BR)&#36;(BR)
654 DDOC_AUTHORS   = &#36;(B Authors:)&#36;(BR)
655         &#36;0&#36;(BR)&#36;(BR)
656 DDOC_BUGS      = &#36;(RED BUGS:)&#36;(BR)
657         &#36;0&#36;(BR)&#36;(BR)
658 DDOC_COPYRIGHT = &#36;(B Copyright:)&#36;(BR)
659         &#36;0&#36;(BR)&#36;(BR)
660 DDOC_DATE      = &#36;(B Date:)&#36;(BR)
661         &#36;0&#36;(BR)&#36;(BR)
662 DDOC_DEPRECATED = &#36;(RED Deprecated:)&#36;(BR)
663         &#36;0&#36;(BR)&#36;(BR)
664 DDOC_EXAMPLES  = &#36;(B Examples:)&#36;(BR)
665         &#36;0&#36;(BR)&#36;(BR)
666 DDOC_HISTORY   = &#36;(B History:)&#36;(BR)
667         &#36;0&#36;(BR)&#36;(BR)
668 DDOC_LICENSE   = &#36;(B License:)&#36;(BR)
669         &#36;0&#36;(BR)&#36;(BR)
670 DDOC_RETURNS   = &#36;(B Returns:)&#36;(BR)
671         &#36;0&#36;(BR)&#36;(BR)
672 DDOC_SEE_ALSO  = &#36;(B See Also:)&#36;(BR)
673         &#36;0&#36;(BR)&#36;(BR)
674 DDOC_STANDARDS = &#36;(B Standards:)&#36;(BR)
675         &#36;0&#36;(BR)&#36;(BR)
676 DDOC_THROWS    = &#36;(B Throws:)&#36;(BR)
677         &#36;0&#36;(BR)&#36;(BR)
678 DDOC_VERSION   = &#36;(B Version:)&#36;(BR)
679         &#36;0&#36;(BR)&#36;(BR)
680 DDOC_SECTION_H = &#36;(B &#36;0)&#36;(BR)&#36;(BR)
681 DDOC_SECTION   = &#36;0&#36;(BR)&#36;(BR)
682 DDOC_MEMBERS   = &#36;(DL &#36;0)
683 DDOC_MODULE_MEMBERS   = &#36;(DDOC_MEMBERS &#36;0)
684 DDOC_CLASS_MEMBERS    = &#36;(DDOC_MEMBERS &#36;0)
685 DDOC_STRUCT_MEMBERS   = &#36;(DDOC_MEMBERS &#36;0)
686 DDOC_ENUM_MEMBERS     = &#36;(DDOC_MEMBERS &#36;0)
687 DDOC_TEMPLATE_MEMBERS = &#36;(DDOC_MEMBERS &#36;0)
688 DDOC_PARAMS    = &#36;(B Params:)&#36;(BR)\n&#36;(TABLE &#36;0)&#36;(BR)
689 DDOC_PARAM_ROW = &#36;(TR &#36;0)
690 DDOC_PARAM_ID  = &#36;(TD &#36;0)
691 DDOC_PARAM_DESC  = &#36;(TD &#36;0)
692 DDOC_BLANKLINE  = &#36;(BR)&#36;(BR)
693
694 DDOC_PSYMBOL    = &#36;(U &#36;0)
695 DDOC_KEYWORD    = &#36;(B &#36;0)
696 DDOC_PARAM  = &#36;(I &#36;0)
697 )
698
699 $(P
700     Ddoc does not generate HTML code. It formats into the basic
701     formatting macros, which (in their predefined form)
702     are then expanded into HTML.
703     If output other than HTML is desired, then these macros
704     need to be redefined.
705 )
706
707     $(TABLE2 Basic Formatting Macros,
708     $(TR $(TD $(B B)) $(TD boldface the argument))
709     $(TR $(TD $(B I)) $(TD italicize the argument))
710     $(TR $(TD $(B U)) $(TD underline the argument))
711     $(TR $(TD $(B P)) $(TD argument is a paragraph))
712     $(TR $(TD $(B DL)) $(TD argument is a definition list))
713     $(TR $(TD $(B DT)) $(TD argument is a definition in a definition list))
714     $(TR $(TD $(B DD)) $(TD argument is a description of a definition))
715     $(TR $(TD $(B TABLE)) $(TD argument is a table))
716     $(TR $(TD $(B TR)) $(TD argument is a row in a table))
717     $(TR $(TD $(B TH)) $(TD argument is a header entry in a row))
718     $(TR $(TD $(B TD)) $(TD argument is a data entry in a row))
719     $(TR $(TD $(B OL)) $(TD argument is an ordered list))
720     $(TR $(TD $(B UL)) $(TD argument is an unordered list))
721     $(TR $(TD $(B LI)) $(TD argument is an item in a list))
722     $(TR $(TD $(B BIG)) $(TD argument is one font size bigger))
723     $(TR $(TD $(B SMALL)) $(TD argument is one font size smaller))
724     $(TR $(TD $(B BR)) $(TD start new line))
725     $(TR $(TD $(B LINK)) $(TD generate clickable link on argument))
726     $(TR $(TD $(B LINK2)) $(TD generate clickable link, first arg is address))
727     $(TR $(TD $(B RED)) $(TD argument is set to be red))
728     $(TR $(TD $(B BLUE)) $(TD argument is set to be blue))
729     $(TR $(TD $(B GREEN)) $(TD argument is set to be green))
730     $(TR $(TD $(B YELLOW)) $(TD argument is set to be yellow))
731     $(TR $(TD $(B BLACK)) $(TD argument is set to be black))
732     $(TR $(TD $(B WHITE)) $(TD argument is set to be white))
733     $(TR $(TD $(B D_CODE)) $(TD argument is D code))
734     $(TR $(TD $(B DDOC)) $(TD overall template for output))
735     )
736
737 $(P
738     $(B DDOC) is special in that it specifies the boilerplate into
739     which the entire generated text is inserted (represented by the
740     Ddoc generated macro $(B BODY)). For example, in order
741     to use a style sheet, $(B DDOC) would be redefined as:
742 )
743
744 $(DDOCCODE
745 DDOC =  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
746     &lt;html&gt;&lt;head&gt;
747     &lt;META http-equiv="content-type" content="text/html; charset=utf-8"&gt;
748     &lt;title&gt;&#36;(TITLE)&lt;/title&gt;
749     &lt;link rel="stylesheet" type="text/css" href="$(B style.css)"&gt;
750     &lt;/head&gt;&lt;body&gt;
751     &lt;h1&gt;&#36;(TITLE)&lt;/h1&gt;
752     &#36;(BODY)
753     &lt;/body&gt;&lt;/html&gt;
754 )
755
756 $(P
757     $(B DDOC_COMMENT) is used to insert comments into the output
758     file.
759 )
760
761 $(P
762     Highlighting of D code is performed by the following macros:
763 )
764
765     $(TABLE2 D Code Formatting Macros,
766     $(TR $(TD $(B D_COMMENT)) $(TD Highlighting of comments))
767     $(TR $(TD $(B D_STRING)) $(TD Highlighting of string literals))
768     $(TR $(TD $(B D_KEYWORD)) $(TD Highlighting of D keywords))
769     $(TR $(TD $(B D_PSYMBOL)) $(TD Highlighting of current declaration name))
770     $(TR $(TD $(B D_PARAM)) $(TD Highlighting of current function declaration parameters))
771     )
772
773 $(P
774     The highlighting macros start with $(B DDOC_).
775     They control the formatting of individual parts of the presentation.
776 )
777
778     $(TABLE2 Ddoc Section Formatting Macros,
779     $(TR $(TD $(B DDOC_DECL)) $(TD Highlighting of the declaration.))
780     $(TR $(TD $(B DDOC_DECL_DD)) $(TD Highlighting of the description of a declaration.))
781     $(TR $(TD $(B DDOC_DITTO)) $(TD Highlighting of ditto declarations.))
782     $(TR $(TD $(B DDOC_SECTIONS)) $(TD Highlighting of all the sections.))
783     $(TR $(TD $(B DDOC_SUMMARY)) $(TD Highlighting of the summary section.))
784     $(TR $(TD $(B DDOC_DESCRIPTION)) $(TD Highlighting of the description section.))
785     $(TR $(TD $(B DDOC_AUTHORS .. DDOC_VERSION)) $(TD Highlighting of the corresponding standard section.))
786     $(TR $(TD $(B DDOC_SECTION_H)) $(TD Highlighting of the section name of a non-standard section.))
787     $(TR $(TD $(B DDOC_SECTION)) $(TD Highlighting of the contents of a non-standard section.))
788     $(TR $(TD $(B DDOC_MEMBERS)) $(TD Default highlighting of all the members of a class, struct, etc.))
789     $(TR $(TD $(B DDOC_MODULE_MEMBERS)) $(TD Highlighting of all the members of a module.))
790     $(TR $(TD $(B DDOC_CLASS_MEMBERS)) $(TD Highlighting of all the members of a class.))
791     $(TR $(TD $(B DDOC_STRUCT_MEMBERS)) $(TD Highlighting of all the members of a struct.))
792     $(TR $(TD $(B DDOC_ENUM_MEMBERS)) $(TD Highlighting of all the members of an enum.))
793     $(TR $(TD $(B DDOC_TEMPLATE_MEMBERS)) $(TD Highlighting of all the members of a template.))
794     $(TR $(TD $(B DDOC_PARAMS)) $(TD Highlighting of a function parameter section.))
795     $(TR $(TD $(B DDOC_PARAM_ROW)) $(TD Highlighting of a name=value function parameter.))
796     $(TR $(TD $(B DDOC_PARAM_ID)) $(TD Highlighting of the parameter name.))
797     $(TR $(TD $(B DDOC_PARAM_DESC)) $(TD Highlighting of the parameter value.))
798     $(TR $(TD $(B DDOC_PSYMBOL)) $(TD Highlighting of declaration name to which a particular section is referring.))
799     $(TR $(TD $(B DDOC_KEYWORD)) $(TD Highlighting of D keywords.))
800     $(TR $(TD $(B DDOC_PARAM)) $(TD Highlighting of function parameters.))
801     $(TR $(TD $(B DDOC_BLANKLINE)) $(TD Inserts a blank line.))
802     )
803
804 $(P
805     For example, one could redefine $(B DDOC_SUMMARY):
806 )
807
808 $(DDOCCODE
809 DDOC_SUMMARY = &#36;(GREEN &#36;0)
810 )
811
812 $(P
813     And all the summary sections will now be green.
814 )
815
816 <h3>Macro Definitions from $(LINK2 dmd-windows.html#sc_ini, $(TT sc.ini))'s DDOCFILE</h3>
817
818 $(P
819     A text file of macro definitions can be created,
820     and specified in $(TT sc.ini):
821 )
822
823 $(DDOCCODE
824 DDOCFILE=myproject.ddoc
825 )
826
827 <h3>Macro Definitions from .ddoc Files on the Command Line</h3>
828
829 $(P
830     File names on the DMD command line with the extension
831     .ddoc are text files that are read and processed in order.
832 )
833
834 <h3>Macro Definitions Generated by Ddoc</h3>
835
836     $(TABLE2 Generated Macro Definitions,
837     $(TR
838     $(TH Macro Name)
839     $(TH Contents)
840     )
841     $(TR
842     $(TD $(B BODY))
843     $(TD Set to the generated document text.)
844     )
845     $(TR
846     $(TD $(B TITLE))
847     $(TD Set to the module name.)
848     )
849     $(TR
850     $(TD $(B DATETIME))
851     $(TD Set to the current date and time.)
852     )
853     $(TR
854     $(TD $(B YEAR))
855     $(TD Set to the current year.)
856     )
857     $(TR
858     $(TD $(B COPYRIGHT))
859     $(TD Set to the contents of any $(B Copyright:) section that is part
860     of the module comment.)
861     )
862     $(TR
863     $(TD $(B DOCFILENAME))
864     $(TD Set to the name of the generated output file.)
865     )
866     )
867
868 <h2>Using Ddoc for other Documentation</h2>
869
870 $(P
871     Ddoc is primarily designed for use in producing documentation
872     from embedded comments. It can also, however, be used for
873     processing other general documentation.
874     The reason for doing this would be to take advantage of the
875     macro capability of Ddoc and the D code syntax highlighting
876     capability.
877 )
878
879 $(P
880     If the .d source file starts with the string "Ddoc" then it
881     is treated as general purpose documentation, not as a D
882     code source file. From immediately after the "Ddoc" string
883     to the end of the file or any "Macros:" section forms
884     the document. No automatic highlighting is done to that text,
885     other than highlighting of D code embedded between lines
886     delineated with --- lines. Only macro processing is done.
887 )
888
889 $(P
890     Much of the D documentation itself is generated this way,
891     including this page.
892     Such documentation is marked at the bottom as being
893     generated by Ddoc.
894 )
895
896 <h2>References</h2>
897
898 $(P
899     $(LINK2 http://www.dsource.org/projects/helix/wiki/CandyDoc, CandyDoc)
900     is a very nice example of how
901     one can customize the Ddoc results with macros
902     and style sheets.
903 )
904
905 )
906
907 Macros:
908     TITLE=Documentation Generator
909     WIKI=Ddoc
910     RPAREN=)
Note: See TracBrowser for help on using the browser.