Skip to main content

The MarkdownOutlineParser Class Reference

Declaration

class MarkdownOutlineParser { ... }

Included Headers

#include <src/markdown.h>

Base class

classOutlineParserInterface

Abstract interface for outline parsers. More...

Public Constructors Index

MarkdownOutlineParser ()

Public Destructor Index

~MarkdownOutlineParser () override

Public Member Functions Index

voidparseInput (const QCString &fileName, const char *fileBuf, const std::shared_ptr< Entry > &root, ClangTUParser *clangParser) override

Parses a single input file with the goal to build an Entry tree. More...

boolneedsPreprocessing (const QCString &) const override

Returns TRUE if the language identified by extension needs the C preprocessor to be run before feed the result to the input parser. More...

voidparsePrototype (const QCString &text) override

Callback function called by the comment block scanner. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Definition at line 46 of file markdown.h.

Public Constructors

MarkdownOutlineParser()

MarkdownOutlineParser::MarkdownOutlineParser ()

Declaration at line 49 of file markdown.h, definition at line 3621 of file markdown.cpp.

3622{
3623}

Reference p.

Public Destructor

~MarkdownOutlineParser()

MarkdownOutlineParser::~MarkdownOutlineParser ()

Declaration at line 50 of file markdown.h, definition at line 3625 of file markdown.cpp.

Public Member Functions

needsPreprocessing()

bool MarkdownOutlineParser::needsPreprocessing (const QCString & extension)
inline virtual

Returns TRUE if the language identified by extension needs the C preprocessor to be run before feed the result to the input parser.

See Also

parseInput()

Definition at line 56 of file markdown.h.

56 bool needsPreprocessing(const QCString &) const override { return FALSE; }

Reference FALSE.

parseInput()

void MarkdownOutlineParser::parseInput (const QCString & fileName, const char * fileBuf, const std::shared_ptr< Entry > & root, ClangTUParser * clangParser)
virtual

Parses a single input file with the goal to build an Entry tree.

Parameters
[in] fileName

The full name of the file.

[in] fileBuf

The contents of the file (zero terminated).

[inout] root

The root of the tree of Entry *nodes representing the information extracted from the file.

[in] clangParser

The clang translation unit parser object or nullptr if disabled.

Declaration at line 52 of file markdown.h, definition at line 3629 of file markdown.cpp.

3630 const char *fileBuf,
3631 const std::shared_ptr<Entry> &root,
3632 ClangTUParser* /*clangParser*/)
3633{
3634 std::shared_ptr<Entry> current = std::make_shared<Entry>();
3635 int prepend = 0; // number of empty lines in front
3636 current->lang = SrcLangExt::Markdown;
3637 current->fileName = fileName;
3638 current->docFile = fileName;
3639 current->docLine = 1;
3640 QCString docs = stripIndentation(fileBuf);
3641 if (!docs.stripWhiteSpace().size()) return;
3642 Debug::print(Debug::Markdown,0,"======== Markdown =========\n---- input ------- \n{}\n",fileBuf);
3643 QCString id;
3644 Markdown markdown(fileName,1,0);
3645 bool isIdGenerated = false;
3646 QCString title = markdown.extractPageTitle(docs, id, prepend, isIdGenerated).stripWhiteSpace();
3647 QCString generatedId;
3648 if (isIdGenerated)
3649 {
3650 generatedId = id;
3651 id = "";
3652 }
3653 int indentLevel=title.isEmpty() ? 0 : -1;
3654 markdown.setIndentLevel(indentLevel);
3655 FileInfo fi(fileName.str());
3656 QCString fn = fi.fileName();
3658 QCString mdfileAsMainPage = Config_getString(USE_MDFILE_AS_MAINPAGE);
3659 QCString mdFileNameId = markdownFileNameToId(fileName);
3660 bool wasEmpty = id.isEmpty();
3661 if (wasEmpty) id = mdFileNameId;
3662 QCString relFileName = stripFromPath(fileName);
3663 bool isSubdirDocs = Config_getBool(IMPLICIT_DIR_DOCS) && relFileName.lower().endsWith("/readme.md");
3664 switch (isExplicitPage(docs))
3665 {
3667 if (!mdfileAsMainPage.isEmpty() &&
3668 (fi.absFilePath()==FileInfo(mdfileAsMainPage.str()).absFilePath()) // file reference with path
3669 )
3670 {
3671 docs.prepend("@ianchor{" + title + "} " + id + "\\ilinebr ");
3672 docs.prepend("@mainpage "+title+"\\ilinebr ");
3673 }
3674 else if (id=="mainpage" || id=="index")
3675 {
3676 if (title.isEmpty()) title = titleFn;
3677 docs.prepend("@ianchor{" + title + "} " + id + "\\ilinebr ");
3678 docs.prepend("@mainpage "+title+"\\ilinebr ");
3679 }
3680 else if (isSubdirDocs)
3681 {
3682 if (!generatedId.isEmpty() && !title.isEmpty())
3683 {
3684 docs.prepend("@section " + generatedId + " " + title + "\\ilinebr ");
3685 }
3686 docs.prepend("@dir\\ilinebr ");
3687 }
3688 else
3689 {
3690 if (title.isEmpty())
3691 {
3692 title = titleFn;
3693 prepend = 0;
3694 }
3695 if (!wasEmpty)
3696 {
3697 docs.prepend("@ianchor{" + title + "} " + id + "\\ilinebr @ianchor{" + relFileName + "} " + mdFileNameId + "\\ilinebr ");
3698 }
3699 else if (!generatedId.isEmpty())
3700 {
3701 docs.prepend("@ianchor " + generatedId + "\\ilinebr ");
3702 }
3703 else if (Config_getEnum(MARKDOWN_ID_STYLE)==MARKDOWN_ID_STYLE_t::GITHUB)
3704 {
3706 docs.prepend("@ianchor{" + title + "} " + autoId + "\\ilinebr ");
3707 }
3708 docs.prepend("@page "+id+" "+title+"\\ilinebr ");
3709 }
3710 for (int i = 0; i < prepend; i++) docs.prepend("\n");
3711 break;
3713 {
3714 // look for `@page label My Title\n` and capture `label` (match[1]) and ` My Title` (match[2])
3715 static const reg::Ex re(R"([ ]*[\\@]page\s+(\a[\w-]*)(\s*[^\n]*)\n)");
3716 reg::Match match;
3717 std::string s = docs.str();
3718 if (reg::search(s,match,re))
3719 {
3720 QCString orgLabel = match[1].str();
3721 QCString orgTitle = match[2].str();
3722 orgTitle = orgTitle.stripWhiteSpace();
3723 QCString newLabel = markdownFileNameToId(fileName);
3724 docs = docs.left(match[1].position())+ // part before label
3725 newLabel+ // new label
3726 match[2].str()+ // part between orgLabel and \n
3727 "\\ilinebr @ianchor{" + orgTitle + "} "+orgLabel+"\n"+ // add original anchor plus \n of above
3728 docs.right(docs.length()-match.length()); // add remainder of docs
3729 }
3730 }
3731 break;
3733 break;
3735 break;
3736 }
3737 int lineNr=1;
3738
3739 p->commentScanner.enterFile(fileName,lineNr);
3740 Protection prot = Protection::Public;
3741 bool needsEntry = false;
3742 int position=0;
3743 GuardedSectionStack guards;
3744 QCString processedDocs = markdown.process(docs,lineNr,true);
3745 while (p->commentScanner.parseCommentBlock(
3746 this,
3747 current.get(),
3748 processedDocs,
3749 fileName,
3750 lineNr,
3751 FALSE, // isBrief
3752 FALSE, // javadoc autobrief
3753 FALSE, // inBodyDocs
3754 prot, // protection
3755 position,
3756 needsEntry,
3757 true,
3758 &guards
3759 ))
3760 {
3761 if (needsEntry)
3762 {
3763 QCString docFile = current->docFile;
3764 root->moveToSubEntryAndRefresh(current);
3765 current->lang = SrcLangExt::Markdown;
3766 current->docFile = docFile;
3767 current->docLine = lineNr;
3768 }
3769 }
3770 if (needsEntry)
3771 {
3772 root->moveToSubEntryAndKeep(current);
3773 }
3774 p->commentScanner.leaveFile(fileName,lineNr);
3775}

References FileInfo::absFilePath, Config_getBool, Config_getEnum, Config_getString, QCString::endsWith, explicitMainPage, explicitOtherPage, explicitPage, Markdown::extractPageTitle, FALSE, FileInfo::fileName, AnchorGenerator::generate, getFileNameExtension, AnchorGenerator::instance, QCString::isEmpty, isExplicitPage, QCString::left, QCString::length, QCString::lower, Debug::Markdown, markdownFileNameToId, notExplicit, p, QCString::prepend, Debug::print, Markdown::process, QCString::right, reg::search, Markdown::setIndentLevel, QCString::size, QCString::str, stripExtensionGeneral, stripFromPath, stripIndentation and QCString::stripWhiteSpace.

parsePrototype()

void MarkdownOutlineParser::parsePrototype (const QCString & text)
virtual

Callback function called by the comment block scanner.

It provides a string text containing the prototype of a function or variable. The parser should parse this and store the information in the Entry node that corresponds with the node for which the comment block parser was invoked.

Declaration at line 57 of file markdown.h, definition at line 3777 of file markdown.cpp.

3778{
3779 Doxygen::parserManager->getOutlineParser("*.cpp")->parsePrototype(text);
3780}

Reference Doxygen::parserManager.

Private Member Attributes

p

std::unique_ptr<Private> MarkdownOutlineParser::p

Definition at line 60 of file markdown.h.

60 std::unique_ptr<Private> p;

Referenced by MarkdownOutlineParser and parseInput.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.