Skip to content

Commit ba98661

Browse files
committed
javadoc work
1 parent eb937d1 commit ba98661

16 files changed

+138
-90
lines changed

include/mrdox/Corpus.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ get(
148148
Assert(t->IT == InfoType::IT_record);
149149
else if constexpr(std::is_same_v<T, FunctionInfo>)
150150
Assert(t->IT == InfoType::IT_function);
151-
else if constexpr(std::is_same_v<T, EnumInfo>)
152-
Assert(t->IT == InfoType::IT_enum);
153151
else if constexpr(std::is_same_v<T, TypedefInfo>)
154152
Assert(t->IT == InfoType::IT_typedef);
153+
else if constexpr(std::is_same_v<T, EnumInfo>)
154+
Assert(t->IT == InfoType::IT_enum);
155+
else if constexpr(std::is_same_v<T, VariableInfo>)
156+
Assert(t->IT == InfoType::IT_variable);
155157
return *t;
156158
}
157159

source/api/AST/ParseJavadoc.cpp

+24-5
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ class JavadocVisitor
138138
visit(*it);
139139
}
140140

141+
#if 0
142+
static void
143+
makeLeftAligned(
144+
List<Javadoc::Text>& list)
145+
{
146+
if(list.empty())
147+
return;
148+
// measure the left margin
149+
std::size_t n = std::size_t(-1);
150+
for(auto& text : list)
151+
{
152+
auto const space = text.string.size() -
153+
llvm::StringRef(text.string).ltrim().size();
154+
if( n > space)
155+
n = space;
156+
}
157+
// now left-justify
158+
for(auto& text : list)
159+
text.string.erase(0, n);
160+
}
161+
#endif
162+
141163
public:
142164
JavadocVisitor(
143165
RawComment const* RC,
@@ -170,16 +192,13 @@ class JavadocVisitor
170192
// paragraph has no doxygen command,
171193
// so we will trim the leading space.
172194
// Otherwise just trim trailing space
173-
#if 0
174195
if(para_->children.empty())
175196
s = s.ltrim().rtrim();
176197
else
177-
s = s.rtrim();
178-
//s = s.ltrim().rtrim();
179-
#endif
198+
s = s.rtrim(); //.ltrim()
180199

181200
// VFALCO Figure out why we get empty TextComment
182-
//if(! s.empty())
201+
if(! s.empty())
183202
Javadoc::append(*para_,
184203
Javadoc::Text(ensureUTF8(s.str())));
185204
}

source/api/CorpusImpl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ class CorpusImpl::
170170

171171
void postProcess(Info& I)
172172
{
173-
//I.javadoc.calculateBrief();
173+
if(I.javadoc)
174+
I.javadoc->calculateBrief();
174175
}
175176

176177
//--------------------------------------------

source/api/Metadata/Javadoc.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ Javadoc::
6060
operator==(
6161
Javadoc const& other) const noexcept
6262
{
63-
return blocks_ == other.blocks_;
63+
return
64+
std::tie(brief_, blocks_) ==
65+
std::tie(other.brief_, other.blocks_);
6466
}
6567

6668
bool
@@ -105,7 +107,6 @@ void
105107
Javadoc::
106108
calculateBrief()
107109
{
108-
return;
109110
Paragraph* brief = nullptr;
110111
for(auto& block : blocks_)
111112
{
@@ -125,6 +126,12 @@ return;
125126
return brief == &block;
126127
});
127128
}
129+
else
130+
{
131+
static std::shared_ptr<Paragraph const> empty_para =
132+
std::make_shared<Paragraph>();
133+
brief_ = empty_para;
134+
}
128135
}
129136

130137
} // mrdox

source/api/_adoc/AdocWriter.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ struct AdocWriter::TypeName
6060
os << t.I.Type.Name;
6161
return os;
6262
}
63-
if(t.corpus.exists(t.I.Type.id))
63+
// VFALCO This is broken
64+
#if 0
65+
if(auto J = t.corpus.find(t.I.Type.id))
6466
{
65-
auto const& J = t.corpus.get<RecordInfo>(t.I.Type.id);
6667
// VFALCO add namespace qualifiers if I is in
6768
// a different namesapce
68-
os << J.Name << "::" << J.Name;
69+
os << J->Name << "::" << T.Name;
6970
return os;
7071
}
72+
#endif
7173
auto const& T = t.I.Type;
7274
os << T.Name << "::" << T.Name;
7375
return os;
@@ -604,7 +606,9 @@ AdocWriter::
604606
writeNode(
605607
Javadoc::Text const& node)
606608
{
607-
os_ << node.string << '\n';
609+
// Text nodes must be left aligned or
610+
// else they can be rendered up as code.
611+
os_ << llvm::StringRef(node.string).ltrim() << '\n';
608612
}
609613

610614
void
@@ -653,7 +657,26 @@ writeNode(
653657
os_ <<
654658
"[,cpp]\n"
655659
"----\n";
656-
writeNodes(node.children);
660+
List<Javadoc::Text> const& list(node.children);
661+
if(! list.empty())
662+
{
663+
// measure the left margin
664+
std::size_t n = std::size_t(-1);
665+
for(auto& text : list)
666+
{
667+
auto const space = text.string.size() -
668+
llvm::StringRef(text.string).ltrim().size();
669+
if( n > space)
670+
n = space;
671+
}
672+
// now write left-aligned
673+
for(auto& text : list)
674+
{
675+
llvm::StringRef string(text.string);
676+
string = string.ltrim(n);
677+
os_ << string << "\n";
678+
}
679+
}
657680
os_ <<
658681
"----\n";
659682
}

test-files/old-tests/brief-1.xml

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
<function name="f6" id="NEkWCLiknLGzCD6JnXuBTSAAne8=">
66
<file path="brief-1.cpp" line="39"/>
77
<doc>
8+
<brief>
9+
<text>brief</text>
10+
</brief>
811
<para>
9-
<text> brief</text>
10-
</para>
11-
<para>
12-
<text> many lined</text>
13-
<text> </text>
12+
<text>many lined</text>
1413
<bold>bold</bold>
1514
<text> what will</text>
1615
<text> happen?</text>
@@ -20,12 +19,12 @@
2019
<function name="f5" id="RnDTZyCZuSqydMEPutN0yG4E/xg=">
2120
<file path="brief-1.cpp" line="30"/>
2221
<doc>
23-
<para>
24-
<text> brief </text>
22+
<brief>
23+
<text>brief</text>
2524
<bold>bold</bold>
2625
<text> it</text>
2726
<text>continues to the line.</text>
28-
</para>
27+
</brief>
2928
</doc>
3029
</function>
3130
</namespace>

test-files/old-tests/brief-2.xml

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@
55
<function name="f1" id="CnO51rIKTzfiVKHkR3TdPa0eo+8=">
66
<file path="brief-2.cpp" line="5"/>
77
<doc>
8-
<para>
9-
<text> brief</text>
10-
</para>
8+
<brief>
9+
<text>brief</text>
10+
</brief>
1111
</doc>
1212
</function>
1313
<function name="f6" id="NEkWCLiknLGzCD6JnXuBTSAAne8=">
1414
<file path="brief-2.cpp" line="34"/>
1515
<doc>
16-
<para>
17-
<text> br</text>
16+
<brief>
17+
<text>br</text>
1818
<text>ief</text>
19-
</para>
19+
</brief>
2020
<para>
21-
<text> desc</text>
21+
<text>desc</text>
2222
</para>
2323
</doc>
2424
</function>
2525
<function name="f5" id="RnDTZyCZuSqydMEPutN0yG4E/xg=">
2626
<file path="brief-2.cpp" line="27"/>
2727
<doc>
28-
<para>
29-
<text> br</text>
28+
<brief>
29+
<text>br</text>
3030
<text>ief</text>
31-
</para>
31+
</brief>
3232
</doc>
3333
</function>
3434
<function name="f3" id="khwJweIqd5FuWAg8T+l+GEljQVc=">
3535
<file path="brief-2.cpp" line="13"/>
3636
<doc>
37-
<para>
38-
<text>brief </text>
39-
</para>
37+
<brief>
38+
<text>brief</text>
39+
</brief>
4040
</doc>
4141
</function>
4242
<function name="f2" id="0MJUv5yGFR9nXWFLeYc+rjOY+iM=">
4343
<file path="brief-2.cpp" line="9"/>
4444
<doc>
45-
<para>
46-
<text> brief</text>
47-
</para>
45+
<brief>
46+
<text>brief</text>
47+
</brief>
4848
</doc>
4949
</function>
5050
<function name="f4" id="5wJFEWD4Ev/Vf3QN/mFlKhtbC6E=">
5151
<file path="brief-2.cpp" line="17"/>
5252
<file path="brief-2.cpp" line="22"/>
5353
<doc>
54-
<para>
54+
<brief>
5555
<text>brief x</text>
56-
</para>
56+
</brief>
5757
<para>
58-
<text> br</text>
58+
<text>br</text>
5959
<text>ief</text>
6060
</para>
6161
</doc>

test-files/old-tests/commands.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<function name="f1" id="CnO51rIKTzfiVKHkR3TdPa0eo+8=">
66
<file path="commands.cpp" line="8"/>
77
<doc>
8+
<brief>
9+
<text>brief</text>
10+
</brief>
811
<para>
9-
<text> brief</text>
10-
</para>
11-
<para>
12-
<text> mrdox hello</text>
12+
<text>mrdox hello</text>
1313
</para>
1414
</doc>
1515
</function>

test-files/old-tests/friend-1.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
1010
<file path="friend-1.cpp" line="4"/>
1111
<doc>
12-
<para>
13-
<text> f</text>
14-
</para>
12+
<brief>
13+
<text>f</text>
14+
</brief>
1515
</doc>
1616
</function>
1717
</namespace>

test-files/old-tests/friend-2.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<file path="friend-2.cpp" line="4"/>
1111
<file path="friend-2.cpp" line="7"/>
1212
<doc>
13-
<para>
14-
<text> f</text>
15-
</para>
13+
<brief>
14+
<text>f</text>
15+
</brief>
1616
</doc>
1717
</function>
1818
</namespace>

test-files/old-tests/friend-3.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<file path="friend-3.cpp" line="9"/>
1616
<file path="friend-3.cpp" line="12"/>
1717
<doc>
18-
<para>
19-
<text> T::f</text>
20-
</para>
18+
<brief>
19+
<text>T::f</text>
20+
</brief>
2121
</doc>
2222
</function>
2323
</namespace>

test-files/old-tests/friend-4.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<file path="friend-4.cpp" line="9"/>
1616
<file path="friend-4.cpp" line="12"/>
1717
<doc>
18-
<para>
19-
<text> U::f</text>
20-
</para>
18+
<brief>
19+
<text>U::f</text>
20+
</brief>
2121
</doc>
2222
</function>
2323
</namespace>

test-files/old-tests/friend-5.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<file path="friend-5.cpp" line="8"/>
1616
<file path="friend-5.cpp" line="12"/>
1717
<doc>
18-
<para>
19-
<text> f</text>
20-
</para>
18+
<brief>
19+
<text>f</text>
20+
</brief>
2121
</doc>
2222
</function>
2323
</namespace>

test-files/old-tests/para-1.xml

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@
88
<function name="f3" id="khwJweIqd5FuWAg8T+l+GEljQVc=">
99
<file path="para-1.cpp" line="17"/>
1010
<doc>
11+
<brief>
12+
</brief>
1113
</doc>
1214
</function>
1315
<function name="f2" id="0MJUv5yGFR9nXWFLeYc+rjOY+iM=">
1416
<file path="para-1.cpp" line="10"/>
1517
<doc>
18+
<brief>
19+
</brief>
1620
</doc>
1721
</function>
1822
<function name="f4" id="5wJFEWD4Ev/Vf3QN/mFlKhtbC6E=">
1923
<file path="para-1.cpp" line="27"/>
2024
<doc>
25+
<brief>
26+
<text>brief</text>
27+
</brief>
2128
<para>
22-
<text> brief</text>
29+
<text>a</text>
2330
</para>
2431
<para>
25-
<text> a</text>
32+
<text>b</text>
2633
</para>
2734
<para>
28-
<text> b </text>
29-
</para>
30-
<para>
31-
<text> c </text>
35+
<text>c</text>
3236
</para>
3337
</doc>
3438
</function>

0 commit comments

Comments
 (0)