11#include "clang/Basic/CommentOptions.h"
12#include "llvm/ADT/StringRef.h"
13#include "gtest/gtest.h"
18TEST(SymbolDocumentation, DetailedDocToMarkup) {
20 CommentOptions CommentOpts;
23 llvm::StringRef Documentation;
24 llvm::StringRef ExpectedRenderEscapedMarkdown;
25 llvm::StringRef ExpectedRenderMarkdown;
26 llvm::StringRef ExpectedRenderPlainText;
35 "brief\n\nfoo\nbar\n",
41 "brief\n\nfoo\n\nbar\n",
47 "brief\n\nfoo \\p bar baz",
53 "brief\n\nfoo \\e bar baz",
59 "brief\n\nfoo \\b bar baz",
60 "foo \\*\\*bar\\*\\* baz",
65 "brief\n\nfoo \\ref bar baz",
66 "foo \\*\\*\\\\ref\\*\\* `bar` baz",
67 "foo **\\ref** `bar` baz",
68 "foo **\\ref** bar baz",
71 "brief\n\nfoo @ref bar baz",
72 "foo \\*\\*@ref\\*\\* `bar` baz",
73 "foo **@ref** `bar` baz",
74 "foo **@ref** bar baz",
77 "\\brief this is a \\n\nbrief description",
83 "brief\n\n\\throw exception foo",
84 "\\*\\*\\\\throw\\*\\* `exception` foo",
85 "**\\throw** `exception` foo",
86 "**\\throw** exception foo",
89 R
"(\brief this is a brief description
111 "brief\n\n\\defgroup mygroup this is a group\nthis is not a group "
113 "\\*\\*@defgroup\\*\\* `mygroup this is a group`\n\nthis is not a "
116 "**@defgroup** `mygroup this is a group`\n\nthis is not a group "
118 "**@defgroup** `mygroup this is a group`\n\nthis is not a group "
126verbatim block containing
133verbatim block containing
137\*\*@endverbatim\*\*)",
142verbatim block containing
150verbatim block containing
156 "brief\n\n@param foo this is a parameter\n@param bar this is another "
165@param foo this is a parameter
169\details these are details
173 R"(\*\*\\brief\*\* another brief?
179 R"(**\brief** another brief?
185 R"(**\brief** another brief?
189More description documentation)",
194<b>this is a bold text</b>
195normal text<i>this is an italic text</i>
196<code>this is a code block</code>)",
197 R"(<b>this is a bold text</b>
198normal text<i>this is an italic text</i>
199<code>this is a code block</code>)",
200 R"(<b>this is a bold text</b>
201normal text<i>this is an italic text</i>
202<code>this is a code block</code>)",
203 "<b>this is a bold text</b> normal text<i>this is an italic text</i> "
204 "<code>this is a code block</code>",
206 {
"brief\n\n@note This is a note",
237 {"brief\n\n@warning This is a warning",
247@warning This is a warning
268 {R"(@note this is not treated as brief
270@brief this is the brief
274this is not treated as brief
278this is not treated as brief
282this is not treated as brief
294 for (
const auto &C : Cases) {
295 markup::Document Doc;
298 SymbolDoc.detailedDocToMarkup(Doc);
300 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
301 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
302 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
306TEST(SymbolDocumentation, RetvalCommand) {
308 CommentOptions CommentOpts;
311 llvm::StringRef Documentation;
312 llvm::StringRef ExpectedRenderEscapedMarkdown;
313 llvm::StringRef ExpectedRenderMarkdown;
314 llvm::StringRef ExpectedRenderPlainText;
316 {
"@retval",
"",
"",
""},
317 {R
"(@retval MyReturnVal
318@retval MyOtherReturnVal)",
320- `MyOtherReturnVal`)",
322- `MyOtherReturnVal`)",
324- MyOtherReturnVal)"},
325 {R"(@retval MyReturnVal if foo
326@retval MyOtherReturnVal if bar)",
327 R"(- `MyReturnVal` - if foo
328- `MyOtherReturnVal` - if bar)",
329 R"(- `MyReturnVal` - if foo
330- `MyOtherReturnVal` - if bar)",
331 R"(- MyReturnVal - if foo
332- MyOtherReturnVal - if bar)"},
334 for (
const auto &C : Cases) {
335 markup::Document Doc;
338 SymbolDoc.retvalsToMarkup(Doc);
340 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
341 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
342 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
346TEST(SymbolDocumentation, DoxygenCodeBlocks) {
347 CommentOptions CommentOpts;
350 llvm::StringRef Documentation;
351 llvm::StringRef ExpectedRenderEscapedMarkdown;
352 llvm::StringRef ExpectedRenderMarkdown;
353 llvm::StringRef ExpectedRenderPlainText;
356int code() { return 0; }
359int code_lang() { return 0; }
362int code_lang_plus() { return 0; }
373int code() { return 0; }
377int code_lang() { return 0; }
381int code_lang_plus() { return 0; }
394int code() { return 0; }
398int code_lang() { return 0; }
402int code_lang_plus() { return 0; }
414 R"(int code() { return 0; }
416int code_lang() { return 0; }
418int code_lang_plus() { return 0; }
426 for (
const auto &C : Cases) {
427 markup::Document Doc;
430 SymbolDoc.detailedDocToMarkup(Doc);
432 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
433 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
434 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
438TEST(SymbolDocumentation, MarkdownCodeBlocks) {
439 CommentOptions CommentOpts;
442 llvm::StringRef Documentation;
443 llvm::StringRef ExpectedRenderEscapedMarkdown;
444 llvm::StringRef ExpectedRenderMarkdown;
445 llvm::StringRef ExpectedRenderPlainText;
448int backticks() { return 0; }
451int backticks_lang() { return 0; }
454int backticks_lang_plus() { return 0; }
457int tilde() { return 0; }
459~~~~~~~~~~~~~~~~~~~~~~~~
460int tilde_many() { return 0; }
461~~~~~~~~~~~~~~~~~~~~~~~~
462~~~~~~~~~~~~~~~~~~~~~~~~{.c++}
463int tilde_many_lang() { return 0; }
464~~~~~~~~~~~~~~~~~~~~~~~~
479int backticks() { return 0; }
483int backticks_lang() { return 0; }
487int backticks_lang_plus() { return 0; }
491int tilde() { return 0; }
495int tilde_many() { return 0; }
499int tilde_many_lang() { return 0; }
517int backticks() { return 0; }
521int backticks_lang() { return 0; }
525int backticks_lang_plus() { return 0; }
529int tilde() { return 0; }
533int tilde_many() { return 0; }
537int tilde_many_lang() { return 0; }
554 R"(int backticks() { return 0; }
556int backticks_lang() { return 0; }
558int backticks_lang_plus() { return 0; }
560int tilde() { return 0; }
562int tilde_many() { return 0; }
564int tilde_many_lang() { return 0; }
575// this code block is missing end backticks
579// this code block is missing end backticks
582// this code block is missing end backticks
584 R"(// this code block is missing end backticks)"},
586 for (
const auto &C : Cases) {
587 markup::Document Doc;
590 SymbolDoc.detailedDocToMarkup(Doc);
592 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
593 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
594 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
598TEST(SymbolDocumentation, MarkdownCodeBlocksSeparation) {
599 CommentOptions CommentOpts;
602 llvm::StringRef Documentation;
603 llvm::StringRef ExpectedRenderEscapedMarkdown;
604 llvm::StringRef ExpectedRenderMarkdown;
605 llvm::StringRef ExpectedRenderPlainText;
607 {R
"(@note Show that code blocks are correctly separated
613int function() { return 0; }
616Show that code blocks are correctly separated
623int function() { return 0; }
626Show that code blocks are correctly separated
633int function() { return 0; }
636Show that code blocks are correctly separated
642int function() { return 0; })"},
643 {R
"(@note Show that code blocks are correctly separated
649int function() { return 0; }
652Show that code blocks are correctly separated
659int function() { return 0; }
662Show that code blocks are correctly separated
669int function() { return 0; }
672Show that code blocks are correctly separated
678int function() { return 0; })"},
680 for (
const auto &C : Cases) {
681 markup::Document Doc;
684 SymbolDoc.detailedDocToMarkup(Doc);
686 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
687 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
688 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
692TEST(SymbolDocumentation, MarkdownCodeSpans) {
693 CommentOptions CommentOpts;
696 llvm::StringRef Documentation;
697 llvm::StringRef ExpectedRenderEscapedMarkdown;
698 llvm::StringRef ExpectedRenderMarkdown;
699 llvm::StringRef ExpectedRenderPlainText;
701 {R
"(`this is a code span with @p and \c inside`)",
702 R"(\`this is a code span with @p and \\c inside\`)",
703 R"(`this is a code span with @p and \c inside`)",
704 R"(`this is a code span with @p and \c inside`)"},
705 {R"(<escaped> `<not-escaped>`)", R"(<escaped> \`<not-escaped>\`)",
706 R"(<escaped> `<not-escaped>`)", R"(<escaped> `<not-escaped>`)"},
707 {R"(<escaped> \`<escaped> doxygen commands not parsed @p, \c, @note, \warning \`)",
708 R"(<escaped> \\\`<escaped> doxygen commands not parsed @p, \\c, @note, \\warning \\\`)",
709 R"(<escaped> \`<escaped> doxygen commands not parsed @p, \c, @note, \warning \`)",
710 R"(<escaped> \`<escaped> doxygen commands not parsed @p, \c, @note, \warning \`)"},
723 for (
const auto &C : Cases) {
724 markup::Document Doc;
727 SymbolDoc.briefToMarkup(Doc.addParagraph());
729 EXPECT_EQ(Doc.asPlainText(),
C.ExpectedRenderPlainText);
730 EXPECT_EQ(Doc.asMarkdown(),
C.ExpectedRenderMarkdown);
731 EXPECT_EQ(Doc.asEscapedMarkdown(),
C.ExpectedRenderEscapedMarkdown);
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//