Skip to content

Commit 75fff0b

Browse files
authored
impl(docfx): use and test simplesect support (#10882)
I should have connected `simplesect` to `para` when I introduced it. At least we got better tests out of my mistake.
1 parent 3df984d commit 75fff0b

2 files changed

Lines changed: 67 additions & 2 deletions

File tree

docfx/doxygen2markdown.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ bool AppendIfDocCmdGroup(std::ostream& os, MarkdownContext const& ctx,
330330
// Unexpected: hruler, preformatted, programlisting, verbatim, indexentry
331331
// Unexpected: orderedlist
332332
if (AppendIfItemizedList(os, ctx, node)) return true;
333-
// Unexpected: simplesect, title, variablelist, table, header
333+
if (AppendIfSimpleSect(os, ctx, node)) return true;
334+
// Unexpected: title, variablelist, table, header
334335
// Unexpected: dotfile, mscfile,diafile, toclist, language, parameterlist
335336
// Unexpected: xrefsect, copydoc, blockquote, parblock
336337
return false;

docfx/doxygen2markdown_test.cc

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ TEST(Doxygen2Markdown, ParagraphWithUnknownOutput) {
273273
std::runtime_error);
274274
}
275275

276-
TEST(Doxygen2Markdown, ParagraphContents) {
276+
TEST(Doxygen2Markdown, ParagraphSimpleContents) {
277277
auto constexpr kXml = R"xml(<?xml version="1.0" standalone="yes"?>
278278
<doxygen version="1.9.1" xml:lang="en-US">
279279
<para id='test-000'>The answer is 42.</para>
@@ -307,6 +307,70 @@ TEST(Doxygen2Markdown, ParagraphContents) {
307307
}
308308
}
309309

310+
TEST(Doxygen2Markdown, ParagraphSimpleSect) {
311+
auto constexpr kXml = R"xml(<?xml version="1.0" standalone="yes"?>
312+
<doxygen version="1.9.1" xml:lang="en-US">
313+
<para id='test-node'>
314+
<simplesect kind="remark">
315+
<para>First remark paragraph.</para>
316+
<para>Second remark paragraph.</para>
317+
</simplesect>
318+
<simplesect kind="warning">
319+
<para>First warning paragraph.</para>
320+
<para>Second warning paragraph.</para>
321+
</simplesect>
322+
</para>
323+
</doxygen>)xml";
324+
325+
auto constexpr kExpected = R"md(
326+
327+
328+
329+
> Remark:
330+
> First remark paragraph.
331+
> Second remark paragraph.
332+
333+
> **Warning:**
334+
> First warning paragraph.
335+
> Second warning paragraph.)md";
336+
337+
pugi::xml_document doc;
338+
doc.load_string(kXml);
339+
auto selected = doc.select_node("//*[@id='test-node']");
340+
std::ostringstream os;
341+
ASSERT_TRUE(AppendIfParagraph(os, {}, selected.node()));
342+
EXPECT_EQ(kExpected, os.str());
343+
}
344+
345+
TEST(Doxygen2Markdown, ParagraphItemizedList) {
346+
auto constexpr kXml = R"xml(<?xml version="1.0" standalone="yes"?>
347+
<doxygen version="1.9.1" xml:lang="en-US">
348+
<para id='test-node'>
349+
<itemizedlist>
350+
<listitem><para>First item.</para></listitem>
351+
<listitem>
352+
<para>Second item.</para><para>With a second paragraph.</para>
353+
</listitem>
354+
</itemizedlist>
355+
</para>
356+
</doxygen>)xml";
357+
358+
auto constexpr kExpected = R"md(
359+
360+
361+
- First item.
362+
- Second item.
363+
364+
With a second paragraph.)md";
365+
366+
pugi::xml_document doc;
367+
doc.load_string(kXml);
368+
auto selected = doc.select_node("//*[@id='test-node']");
369+
std::ostringstream os;
370+
ASSERT_TRUE(AppendIfParagraph(os, {}, selected.node()));
371+
EXPECT_EQ(kExpected, os.str());
372+
}
373+
310374
TEST(Doxygen2Markdown, ItemizedListSimple) {
311375
pugi::xml_document doc;
312376
doc.load_string(R"xml(<?xml version="1.0" standalone="yes"?>

0 commit comments

Comments
 (0)