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

Go to the source code of this file.

Functions

static void generateHtmlOutput (const QCString &fileName, const QCString &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 44 of file singlecomment.cpp.

45{
46 QCString fileName(fn);
47 std::shared_ptr<Entry> root = std::make_shared<Entry>();
48
49 // 1. Pass input through commentcnv
50 std::string convBuf;
51 convBuf.reserve(text.size()+1024);
52 convertCppComments(text,convBuf,fn);
53
54 // 2. Pass result through commentscan
55 MarkdownOutlineParser markdownParser;
56 CommentScanner scanner;
57 int lineNr=1;
58 scanner.enterFile(fileName,lineNr);
59 int pos=0;
60 bool needsEntry=false;
62 Markdown markdown(fileName,1,0);
63 QCString processedDocs = markdown.process(convBuf.data(),lineNr,true);
64 std::shared_ptr<Entry> current = std::make_shared<Entry>();
65 current->lang = SrcLangExt::Markdown;
66 current->fileName = fileName;
67 current->docFile = fileName;
68 current->docLine = 1;
69 auto prot = Protection::Public;
70 while (scanner.parseCommentBlock(&markdownParser,
71 current.get(),
72 processedDocs,
73 fileName,lineNr,
74 false, // isBrief
75 false, // isAutoBriefOn
76 false, // isInbody
77 prot,
78 pos,
79 needsEntry,
80 true, // markdownSupport
81 &guards))
82 {
83 if (needsEntry)
84 {
85 QCString docFile = current->docFile;
86 root->moveToSubEntryAndRefresh(current);
87 current->lang = SrcLangExt::Markdown;
88 current->docFile = docFile;
89 current->docLine = lineNr;
90 }
91 }
92 root->moveToSubEntryAndKeep(current);
93 scanner.leaveFile(fileName,lineNr);
94
95 // 3. Pass result through docparser
96 for (const auto &child : root->children())
97 {
98 if (!child->brief.isEmpty())
99 {
100 generateHtmlOutput(fileName,child->brief);
101 }
102 if (!child->doc.isEmpty())
103 {
104 generateHtmlOutput(fileName,child->doc);
105 }
106 }
107}
bool parseCommentBlock(OutlineParserInterface *parser, Entry *curEntry, const QCString &comment, const QCString &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.
void enterFile(const QCString &fileName, int lineNr)
void leaveFile(const QCString &fileName, int lineNr)
Helper class to process markdown formatted text.
Definition markdown.h:32
This is an alternative implementation of QCString.
Definition qcstring.h:101
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 QCString &fileName, const QCString &doc)
@ Public
Definition types.h:26
@ Markdown
Definition types.h:57

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

Referenced by parseInput().

◆ generateHtmlOutput()

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

Definition at line 25 of file singlecomment.cpp.

26{
27 //printf("------\n%s\n------\n",qPrint(doc));
28 auto parser { createDocParser() };
29 auto ast { validatingParseDoc(*parser.get(),
30 fileName, 1, nullptr, nullptr, doc, false, false,
31 QCString(), false, false, true) };
32 const DocNodeAST *astImpl = dynamic_cast<const DocNodeAST*>(ast.get());
33 if (astImpl)
34 {
35 TextStream t;
36 OutputCodeList codeList;
37 codeList.add<HtmlCodeGenerator>(&t);
38 HtmlDocVisitor visitor(t,codeList,nullptr,fileName);
39 std::visit(visitor,astImpl->root);
40 printf("%s\n",qPrint(t.str()));
41 }
42}
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1460
DocNodeVariant root
Definition docnode.h:1481
Generator for HTML code fragments.
Definition htmlgen.h:25
Concrete visitor implementation for HTML output.
Class representing a list of different code generators.
Definition outputlist.h:164
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:194
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:229
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:54
IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf, const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &input, bool indexWords, bool isExample, const QCString &exampleName, bool singleLine, bool linkFromIndex, bool markdownSupport)
const char * qPrint(const char *s)
Definition qcstring.h:672

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

Referenced by generateHtmlForComment().