parseComment

Undocumented in source.
Comment
parseComment
(
string text
,
string[string] macros
,
bool removeUnknown = true
)
out (retVal) { assert (retVal.sections.length >= 2); }

Examples

1 	import std.conv : text;
2 
3 	auto s1 = `Stop the world
4 
5 This function tells the Master to stop the world, taking effect immediately.
6 
7 Params:
8 reason = Explanation to give to the $(B Master)
9 duration = Time for which the world $(UNUSED)would be stopped (as time itself stop, this is always $(F double.infinity))
10 
11 ---
12 void main() {
13   import std.datetime : msecs;
14   import master.universe.control;
15   stopTheWorld("Too fast", 42.msecs);
16   assert(0); // Will never be reached.
17 }
18 ---
19 
20 Returns:
21 Nothing, because nobody can restart it.
22 
23 Macros:
24 F= $0`;
25 
26 	immutable expected = `<pre class="d_code"><font color=blue>void</font> main() {
27   <font color=blue>import</font> std.datetime : msecs;
28   <font color=blue>import</font> master.universe.control;
29   stopTheWorld(<font color=red>"Too fast"</font>, 42.msecs);
30   <font color=blue>assert</font>(0); <font color=green>// Will never be reached.</font>
31 }</pre>`;
32 
33 	auto c = parseComment(s1, null);
34 
35 	assert(c.sections.length == 6, text(c.sections.length));
36 	assert(c.sections[0].name is null, c.sections[0].name);
37 	assert(c.sections[0].content == "Stop the world", c.sections[0].content);
38 
39 	assert(c.sections[1].name is null, c.sections[1].name);
40 	assert(
41 		c.sections[1].content == `This function tells the Master to stop the world, taking effect immediately.`,
42 		c.sections[1].content);
43 
44 	assert(c.sections[2].name == "Params", c.sections[2].name);
45 	//	writeln(c.sections[2].mapping);
46 	assert(c.sections[2].mapping[0][0] == "reason", c.sections[2].mapping[0][0]);
47 	assert(c.sections[2].mapping[0][1] == "Explanation to give to the <b>Master</b>",
48 		c.sections[2].mapping[0][1]);
49 	assert(c.sections[2].mapping[1][0] == "duration", c.sections[2].mapping[0][1]);
50 	assert(
51 		c.sections[2].mapping[1][1] == "Time for which the world would be stopped (as time itself stop, this is always double.infinity)",
52 		c.sections[2].mapping[1][1]);
53 
54 	assert(c.sections[3].name == "Examples", c.sections[3].name);
55 	assert(c.sections[3].content == expected, c.sections[3].content);
56 
57 	assert(c.sections[4].name == "Returns", c.sections[4].name);
58 	assert(c.sections[4].content == `Nothing, because nobody can restart it.`,
59 		c.sections[4].content);
60 
61 	assert(c.sections[5].name == "Macros", c.sections[5].name);
62 	assert(c.sections[5].mapping[0][0] == "F", c.sections[5].mapping[0][0]);
63 	assert(c.sections[5].mapping[0][1] == "$0", c.sections[5].mapping[0][1]);

Meta