Mercurial > projects > dil
annotate trunk/src/dil/doc/Doc.d @ 754:c7a5499faa77
Improved DDoc related code.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Wed, 13 Feb 2008 17:10:55 +0100 |
parents | 8caf18892c1b |
children | 5e3ef1b2011c |
rev | line source |
---|---|
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
1 /++ |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
2 Author: Aziz Köksal |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
3 License: GPL3 |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
4 +/ |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
5 module dil.doc.Doc; |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
6 |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
7 import dil.doc.Parser; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
8 import dil.ast.Node; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
9 import dil.lexer.Funcs; |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
10 import dil.Unicode; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
11 import common; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
12 |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
745
diff
changeset
|
13 import tango.text.Ascii : icompare; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
14 |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
15 class DDocComment |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
16 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
17 Section[] sections; /// The sections of this comment. |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
18 Section summary; /// Optional summary section. |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
19 Section description; /// Optional description section. |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
20 |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
21 this(Section[] sections, Section summary, Section description) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
22 { |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
23 this.sections = sections; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
24 this.summary = summary; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
25 this.description = description; |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
26 } |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
27 |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
28 /// Removes the first copyright section and returns it. |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
29 Section takeCopyright() |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
30 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
31 foreach (i, section; sections) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
32 if (section.Is("copyright")) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
33 { |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
34 sections = sections[0..i] ~ sections[i+1..$]; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
35 return section; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
36 } |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
37 return null; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
38 } |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
39 |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
40 /// Returns: true if "ditto" is the only text in this comment. |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
41 bool isDitto() |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
42 { |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
43 if (summary && sections.length == 1 && |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
745
diff
changeset
|
44 icompare(strip(summary.text), "ditto") == 0) |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
45 return true; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
46 return false; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
47 } |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
48 |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
49 // MacrosSection[] getMacros() |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
50 // { |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
51 // MacrosSection[] macros; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
52 // foreach (section; sections) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
53 // if (section.Is("macros")) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
54 // macros ~= new MacrosSection(section.name, section.text); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
55 // return macros; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
56 // } |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
57 } |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
58 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
59 /// Returns a node's DDocComment. |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
60 DDocComment getDDocComment(Node node) |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
61 { |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
62 DDocParser p; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
63 p.parse(getDDocText(getDocTokens(node))); |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
64 if (p.sections.length) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
65 return new DDocComment(p.sections, p.summary, p.description); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
66 return null; |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
67 } |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
68 |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
69 /// Strips leading and trailing whitespace characters. |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
70 /// Whitespace: ' ', '\t', '\v', '\f' and '\n' |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
745
diff
changeset
|
71 /// Returns: a slice into str. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
72 char[] strip(char[] str) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
73 { |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
74 if (str.length == 0) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
75 return null; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
76 uint i; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
77 for (; i < str.length; i++) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
78 if (!isspace(str[i]) && str[i] != '\n') |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
79 break; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
80 if (str.length == i) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
81 return null; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
82 str = str[i..$]; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
83 assert(str.length); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
84 for (i = str.length; i; i--) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
85 if (!isspace(str[i-1]) && str[i-1] != '\n') |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
86 break; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
87 return str[0..i]; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
88 } |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
89 |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
90 /// Parses a DDoc comment string. |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
91 struct DDocParser |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
92 { |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
93 char* p; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
94 char* textEnd; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
95 Section[] sections; /// Parsed sections. |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
96 Section summary; /// Optional summary section. |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
97 Section description; /// Optional description section. |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
98 |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
99 /// Parses the DDoc text into sections. |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
100 Section[] parse(string text) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
101 { |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
102 if (!text.length) |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
103 return null; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
104 p = text.ptr; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
105 textEnd = p + text.length; |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
106 |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
107 char* summaryBegin; |
745 | 108 string ident, nextIdent; |
109 char* bodyBegin, nextBodyBegin; | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
110 |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
111 skipWhitespace(p); |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
112 summaryBegin = p; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
113 |
745 | 114 if (findNextIdColon(ident, bodyBegin)) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
115 { // Check that this is not an explicit section. |
745 | 116 if (summaryBegin != ident.ptr) |
117 scanSummaryAndDescription(summaryBegin, ident.ptr); | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
118 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
119 else // There are no explicit sections. |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
120 { |
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
121 scanSummaryAndDescription(summaryBegin, textEnd); |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
122 return sections; |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
123 } |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
124 |
745 | 125 assert(ident.length); |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
126 // Continue parsing. |
745 | 127 while (findNextIdColon(nextIdent, nextBodyBegin)) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
128 { |
745 | 129 sections ~= new Section(ident, textBody(bodyBegin, nextIdent.ptr)); |
130 ident = nextIdent; | |
131 bodyBegin = nextBodyBegin; | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
132 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
133 // Add last section. |
745 | 134 sections ~= new Section(ident, textBody(bodyBegin, textEnd)); |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
135 return sections; |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
136 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
137 |
745 | 138 /// Removes trailing whitespace characters from the text body. |
139 char[] textBody(char* begin, char* end) | |
140 { | |
141 // The body of A is empty, e.g.: | |
142 // A: | |
143 // B: some text | |
144 // ^- begin and end point to B (or to this.textEnd in the 2nd case.) | |
145 if (begin is end) | |
146 return ""; | |
147 // Remove trailing whitespace. | |
148 while (isspace(*--end) || *end == '\n') | |
149 {} | |
150 end++; | |
151 return makeString(begin, end); | |
152 } | |
153 | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
154 void scanSummaryAndDescription(char* p, char* end) |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
155 { |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
156 assert(p <= end); |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
157 char* sectionBegin = p; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
158 // Search for the end of the first paragraph. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
159 end--; // Decrement end, so we can look ahead one character. |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
160 while (p < end && !(*p == '\n' && p[1] == '\n')) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
161 p++; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
162 end++; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
163 if (p+1 >= end) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
164 p = end; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
165 assert(p == end || (*p == '\n' && p[1] == '\n')); |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
166 // The first paragraph is the summary. |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
167 summary = new Section("", makeString(sectionBegin, p)); |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
168 sections ~= summary; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
169 // The rest is the description section. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
170 if (p < end) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
171 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
172 skipWhitespace(p); |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
173 sectionBegin = p; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
174 if (p < end) |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
175 { |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
176 description = new Section("", makeString(sectionBegin, end)); |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
177 sections ~= description; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
178 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
179 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
180 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
181 |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
182 void skipWhitespace(ref char* p) |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
183 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
184 while (p < textEnd && (isspace(*p) || *p == '\n')) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
185 p++; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
186 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
187 |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
188 /// Find next "Identifier:". |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
189 /// Params: |
745 | 190 /// ident = set to the Identifier |
191 /// bodyBegin = set to the beginning of the text body (whitespace skipped.) | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
192 /// Returns: true if found |
745 | 193 bool findNextIdColon(ref char[] ident, ref char* bodyBegin) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
194 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
195 while (p < textEnd) |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
196 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
197 skipWhitespace(p); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
198 if (p >= textEnd) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
199 break; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
200 assert(isascii(*p) || isLeadByte(*p)); |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
201 auto idBegin = p; |
722
ceaac6a24258
Added isUnicodeAlpha() for DDocParser and MacroParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
718
diff
changeset
|
202 if (isidbeg(*p) || isUnicodeAlpha(p, textEnd)) // IdStart |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
203 { |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
204 do // IdChar* |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
205 p++; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
206 while (p < textEnd && (isident(*p) || isUnicodeAlpha(p, textEnd))) |
745 | 207 auto idEnd = p; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
208 if (p < textEnd && *p == ':') // : |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
209 { |
745 | 210 p++; |
211 skipWhitespace(p); | |
212 bodyBegin = p; | |
213 ident = makeString(idBegin, idEnd); | |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
214 return true; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
215 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
216 } |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
217 // Skip this line. |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
218 while (p < textEnd && *p != '\n') |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
219 p++; |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
220 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
221 return false; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
222 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
223 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
224 |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
225 class Section |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
226 { |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
227 string name; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
228 string text; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
229 this(string name, string text) |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
230 { |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
231 this.name = name; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
232 this.text = text; |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
233 } |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
234 |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
235 bool Is(char[] name2) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
236 { |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
745
diff
changeset
|
237 return icompare(name, name2) == 0; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
238 } |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
239 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
240 |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
241 class ParamsSection : Section |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
242 { |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
243 string[] paramNames; /// Parameter names. |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
244 string[] paramDescs; /// Parameter descriptions. |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
245 this(string name, string text) |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
246 { |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
247 super(name, text); |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
248 IdentValueParser parser; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
249 auto idvalues = parser.parse(text); |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
250 this.paramNames = new string[idvalues.length]; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
251 this.paramDescs = new string[idvalues.length]; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
252 foreach (i, idvalue; idvalues) |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
253 { |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
254 this.paramNames[i] = idvalue.ident; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
255 this.paramDescs[i] = idvalue.value; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
256 } |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
257 } |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
258 } |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
259 |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
260 class MacrosSection : Section |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
261 { |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
262 string[] macroNames; /// Macro names. |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
728
diff
changeset
|
263 string[] macroTexts; /// Macro texts. |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
264 this(string name, string text) |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
265 { |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
266 super(name, text); |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
267 IdentValueParser parser; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
268 auto idvalues = parser.parse(text); |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
269 this.macroNames = new string[idvalues.length]; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
270 this.macroTexts = new string[idvalues.length]; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
271 foreach (i, idvalue; idvalues) |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
272 { |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
273 this.macroNames[i] = idvalue.ident; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
274 this.macroTexts[i] = idvalue.value; |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
275 } |
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
276 } |
716
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
277 } |
08e6174a2e1c
Added class DDocComment.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
278 |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
279 bool isDoxygenComment(Token* token) |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
280 { // Doxygen: '/+!' '/*!' '//!' |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
281 return token.kind == TOK.Comment && token.start[2] == '!'; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
282 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
283 |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
284 bool isDDocComment(Token* token) |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
285 { // DDOC: '/++' '/**' '///' |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
286 return token.kind == TOK.Comment && token.start[1] == token.start[2]; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
287 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
288 |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
289 /++ |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
290 Returns the surrounding documentation comment tokens. |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
291 Note: this function works correctly only if |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
292 the source text is syntactically correct. |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
293 +/ |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
294 Token*[] getDocTokens(Node node, bool function(Token*) isDocComment = &isDDocComment) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
295 { |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
296 Token*[] comments; |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
297 auto isEnumMember = node.kind == NodeKind.EnumMemberDeclaration; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
298 // Get preceding comments. |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
299 auto token = node.begin; |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
300 // Scan backwards until we hit another declaration. |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
301 Loop: |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
302 while (1) |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
303 { |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
304 token = token.prev; |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
305 if (token.kind == TOK.LBrace || |
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
306 token.kind == TOK.RBrace || |
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
307 token.kind == TOK.Semicolon || |
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
308 token.kind == TOK.HEAD || |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
309 (isEnumMember && token.kind == TOK.Comma)) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
310 break; |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
311 |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
312 if (token.kind == TOK.Comment) |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
313 { // Check that this comment doesn't belong to the previous declaration. |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
314 switch (token.prev.kind) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
315 { |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
316 case TOK.Semicolon, TOK.RBrace, TOK.Comma: |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
317 break Loop; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
318 default: |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
319 if (isDocComment(token)) |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
320 comments = [token] ~ comments; |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
321 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
322 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
323 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
324 // Get single comment to the right. |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
325 token = node.end.next; |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
326 if (token.kind == TOK.Comment && isDocComment(token)) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
327 comments ~= token; |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
328 else if (isEnumMember) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
329 { |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
330 token = node.end.nextNWS; |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
331 if (token.kind == TOK.Comma) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
332 { |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
333 token = token.next; |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
334 if (token.kind == TOK.Comment && isDocComment(token)) |
676
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
335 comments ~= token; |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
336 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
337 } |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
338 return comments; |
c4e3a34e40f1
Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
339 } |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
340 |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
341 bool isLineComment(Token* t) |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
342 { |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
343 assert(t.kind == TOK.Comment); |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
344 return t.start[1] == '/'; |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
345 } |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
346 |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
347 /// Extracts the text body of the comment tokens. |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
348 string getDDocText(Token*[] tokens) |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
349 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
350 if (tokens.length == 0) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
351 return null; |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
352 string result; |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
353 foreach (token; tokens) |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
354 { |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
355 auto n = isLineComment(token) ? 0 : 2; // 0 for "//", 2 for "+/" and "*/". |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
356 result ~= sanitize(token.srcText[3 .. $-n], token.start[1]); |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
357 assert(token.next); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
358 if (token.next.kind == TOK.Newline) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
359 result ~= \n; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
360 else |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
361 result ~= ' '; |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
362 } |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
363 // Stdout.formatln("→{}←", result); |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
364 return result[0..$-1]; // Remove \n or ' ' |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
365 } |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
366 |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
367 /// Sanitizes a DDoc comment string. |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
712
diff
changeset
|
368 /// Leading "commentChar"s are removed from the lines. |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
369 /// The various newline types are converted to '\n'. |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
370 /// Params: |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
371 /// comment = the string to be sanitized. |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
372 /// commentChar = '/', '+', or '*' |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
373 string sanitize(string comment, char commentChar) |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
374 { |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
375 alias comment result; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
376 |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
377 bool newline = true; // True when at the beginning of a new line. |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
378 uint i, j; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
379 auto len = result.length; |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
380 for (; i < len; i++, j++) |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
381 { |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
382 if (newline) |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
383 { // Ignore commentChars at the beginning of each new line. |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
384 newline = false; |
754
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
385 auto begin = i; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
386 while (i < len && isspace(result[i])) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
387 i++; |
754
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
388 if (i < len && result[i] == commentChar) |
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
389 while (++i < len && result[i] == commentChar) |
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
390 {} |
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
391 else |
c7a5499faa77
Improved DDoc related code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
751
diff
changeset
|
392 i = begin; // Reset. No commentChar found. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
393 if (i >= len) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
394 break; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
395 } |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
396 // Check for Newline. |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
397 switch (result[i]) |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
398 { |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
399 case '\r': |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
400 if (i+1 < len && result[i+1] == '\n') |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
401 i++; |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
402 case '\n': |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
403 result[j] = '\n'; // Copy Newline as '\n'. |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
404 newline = true; |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
405 continue; |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
406 default: |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
407 if (!isascii(result[i]) && i+2 < len && isUnicodeNewline(result.ptr + i)) |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
408 { |
739
49fe21aa387c
Added sanitizeText() to dil.Converter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
409 i += 2; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
410 goto case '\n'; |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
411 } |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
412 } |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
413 // Copy character. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
414 result[j] = result[i]; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
415 } |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
416 result.length = j; // Adjust length. |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
417 // Lastly, strip trailing commentChars. |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
418 if (!result.length) |
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
419 return null; |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
420 i = result.length; |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
421 for (; i && result[i-1] == commentChar; i--) |
728
41cad5ca4863
Added ParamsSection and MacrosSection.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
722
diff
changeset
|
422 {} |
737
f88b5285b86b
Implemented DDocEmitter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
731
diff
changeset
|
423 result.length = i; |
712
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
424 return result; |
f8875ef9a66d
Added function sanitize() to dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
425 } |