Doxygen
Loading...
Searching...
No Matches
singlecomment.cpp File Reference
#include "singlecomment.h"
#include "commentcnv.h"
#include "commentscan.h"
#include "docnode.h"
#include "entry.h"
#include "htmldocvisitor.h"
#include "markdown.h"
#include "outputlist.h"
Include dependency graph for singlecomment.cpp:

Go to the source code of this file.

Functions

static void generateHtmlOutput (const DString &fileName, const DString &doc)
void generateHtmlForComment (const std::string &fn, const std::string &text)
 Helper for implemented the -c option of doxygen, which produces HTML output for a given doxygen formatted string.

Function Documentation

◆ generateHtmlForComment()

void generateHtmlForComment ( const std::string & fn,
const std::string & text )

Helper for implemented the -c option of doxygen, which produces HTML output for a given doxygen formatted string.

Definition at line 55 of file singlecomment.cpp.

56{
57 DString fileName = "index.html";
58 std::shared_ptr<Entry> root = std::make_shared<Entry>();
59
60 // 1. Pass input through commentcnv
61 std::string convBuf;
62 convBuf.reserve(text.size()+1024);
63 convertCppComments(text,convBuf,"input.md");
64
65 // 2. Pass result through commentscan
66 MarkdownOutlineParser markdownParser;
67 CommentScanner scanner;
68 int lineNr=1;
69 scanner.enterFile(fileName,lineNr);
70 int pos=0;
71 bool needsEntry=false;
73 Markdown markdown(fileName,1,0);
74 DString processedDocs = markdown.process(convBuf.data(),lineNr,true);
75 std::shared_ptr<Entry> current = std::make_shared<Entry>();
76 current->lang = SrcLangExt::Markdown;
77 current->fileName = fn;
78 current->docFile = fn;
79 current->docLine = 1;
80 auto prot = Protection::Public;
81 while (scanner.parseCommentBlock(&markdownParser,
82 current.get(),
83 processedDocs,
84 fileName,lineNr,
85 false, // isBrief
86 false, // isAutoBriefOn
87 false, // isInbody
88 prot,
89 pos,
90 needsEntry,
91 true, // markdownSupport
92 &guards))
93 {
94 if (needsEntry)
95 {
96 DString docFile = current->docFile;
97 root->moveToSubEntryAndRefresh(current);
98 current->lang = SrcLangExt::Markdown;
99 current->docFile = docFile;
100 current->docLine = lineNr;
101 }
102 }
103 root->moveToSubEntryAndKeep(current);
104 scanner.leaveFile(fileName,lineNr);
105
106 // 3. Pass result through docparser
107 for (const auto &child : root->children())
108 {
109 if (!child->brief.empty())
110 {
111 generateHtmlOutput(fn,child->brief);
112 }
113 if (!child->doc.empty())
114 {
115 generateHtmlOutput(fn,child->doc);
116 }
117 }
118}
void enterFile(const DString &fileName, int lineNr)
void leaveFile(const DString &fileName, int lineNr)
bool parseCommentBlock(OutlineParserInterface *parser, Entry *curEntry, const DString &comment, const DString &fileName, int &lineNr, bool isBrief, bool isJavadocStyle, bool isInbody, Protection &prot, int &position, bool &newEntryNeeded, bool markdownEnabled, GuardedSectionStack *guards)
Invokes the comment block parser with the request to parse a single comment block.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
Helper class to process markdown formatted text.
Definition markdown.h:33
void convertCppComments(const std::string &inBuf, std::string &outBuf, const std::string &fn)
Converts the comments in a file.
std::stack< GuardedSection > GuardedSectionStack
Definition commentscan.h:48
static void generateHtmlOutput(const DString &fileName, const DString &doc)

References convertCppComments(), CommentScanner::enterFile(), generateHtmlOutput(), CommentScanner::leaveFile(), CommentScanner::parseCommentBlock(), and Markdown::process().

Referenced by parseInput().

◆ generateHtmlOutput()

void generateHtmlOutput ( const DString & fileName,
const DString & doc )
static

Definition at line 28 of file singlecomment.cpp.

29{
30 //printf("------\n%s\n------\n",qPrint(doc));
31 auto parser { createDocParser() };
32 auto ast { validatingParseDoc(*parser.get(),
33 fileName,
34 1,
35 nullptr,
36 nullptr,
37 doc,
39 .setMarkdownSupport(true)
40 .setAutolinkSupport(true))
41 };
42 const DocNodeAST *astImpl = dynamic_cast<const DocNodeAST*>(ast.get());
43 if (astImpl)
44 {
45 TextStream t;
46 OutputCodeList codeList;
47 codeList.add<HtmlCodeGenerator>(&t);
48 HtmlDocVisitor visitor(t,codeList,nullptr,fileName);
49 std::visit(visitor,astImpl->root);
50 std::string content = t.str()+"\n";
51 fwrite(content.c_str(),content.length(),1,stdout);
52 }
53}
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1471
DocNodeVariant root
Definition docnode.h:1496
Generator for HTML code fragments.
Definition htmlgen.h:23
Concrete visitor implementation for HTML output.
Class representing a list of different code generators.
Definition outputlist.h:162
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:192
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:59
IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf, const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &input, const DocOptions &options)
Helper class to pass options when calling OutputList::generateDoc().
Definition docoptions.h:24

References OutputCodeList::add(), createDocParser(), DocNodeAST::root, TextStream::str(), and validatingParseDoc().

Referenced by generateHtmlForComment().