Public Member Functions | List of all members
MarkdownFileParser Class Reference

#include <markdown.h>

Inheritance diagram for MarkdownFileParser:
ParserInterface

Public Member Functions

virtual ~MarkdownFileParser ()
 
void startTranslationUnit (const char *)
 
void finishTranslationUnit ()
 
void parseInput (const char *fileName, const char *fileBuf, Entry *root, bool sameTranslationUnit, QStrList &filesInSameTranslationUnit)
 
bool needsPreprocessing (const QCString &)
 
void parseCode (CodeOutputInterface &codeOutIntf, const char *scopeName, const QCString &input, SrcLangExt lang, bool isExampleBlock, const char *exampleName=0, FileDef *fileDef=0, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, MemberDef *memberDef=0, bool showLineNumbers=TRUE, Definition *searchCtx=0, bool collectXRefs=TRUE)
 
void resetCodeParserState ()
 
void parsePrototype (const char *text)
 
- Public Member Functions inherited from ParserInterface
virtual ~ParserInterface ()
 

Detailed Description

Definition at line 28 of file markdown.h.

Constructor & Destructor Documentation

virtual MarkdownFileParser::~MarkdownFileParser ( )
inlinevirtual

Definition at line 31 of file markdown.h.

31 {}

Member Function Documentation

void MarkdownFileParser::finishTranslationUnit ( )
inlinevirtual

Called after all files in a translation unit have been processed.

Implements ParserInterface.

Definition at line 33 of file markdown.h.

33 {}
bool MarkdownFileParser::needsPreprocessing ( const QCString extension)
inlinevirtual

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()

Implements ParserInterface.

Definition at line 39 of file markdown.h.

39 { return FALSE; }
const bool FALSE
Definition: qglobal.h:370
void MarkdownFileParser::parseCode ( CodeOutputInterface codeOutIntf,
const char *  scopeName,
const QCString input,
SrcLangExt  lang,
bool  isExampleBlock,
const char *  exampleName = 0,
FileDef fileDef = 0,
int  startLine = -1,
int  endLine = -1,
bool  inlineFragment = FALSE,
MemberDef memberDef = 0,
bool  showLineNumbers = TRUE,
Definition searchCtx = 0,
bool  collectXRefs = TRUE 
)
virtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in]codeOutIntfAbstract interface for writing the result.
[in]langThe programming language of the code fragment.
[in]scopeNameName of scope to which the code belongs.
[in]inputActual code in the form of a string
[in]isExampleBlockTRUE iff the code is part of an example.
[in]exampleNameName of the example.
[in]fileDefFile definition to which the code is associated.
[in]startLineStarting line in case of a code fragment.
[in]endLineEnding line of the code fragment.
[in]inlineFragmentCode fragment that is to be shown inline as part of the documentation.
[in]memberDefMember definition to which the code is associated (non null in case of an inline fragment for a member).
[in]showLineNumbersif set to TRUE and also fileDef is not 0, line numbers will be added to the source fragement
[in]searchCtxcontext under which search data has to be stored.
[in]collectXRefscollect cross-reference relations.

Implements ParserInterface.

Definition at line 2432 of file markdown.cpp.

2447 {
2449  if (pIntf!=this)
2450  {
2451  pIntf->parseCode(
2452  codeOutIntf,scopeName,input,lang,isExampleBlock,exampleName,
2453  fileDef,startLine,endLine,inlineFragment,memberDef,showLineNumbers,
2454  searchCtx,collectXRefs);
2455  }
2456 }
ParserInterface * getParser(const char *extension)
Definition: parserintf.h:191
Abstract interface for programming language parsers.
Definition: parserintf.h:38
static ParserManager * parserManager
Definition: doxygen.h:141
virtual void parseCode(CodeOutputInterface &codeOutIntf, const char *scopeName, const QCString &input, SrcLangExt lang, bool isExampleBlock, const char *exampleName=0, FileDef *fileDef=0, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, MemberDef *memberDef=0, bool showLineNumbers=TRUE, Definition *searchCtx=0, bool collectXRefs=TRUE)=0
bool collectXRefs
void MarkdownFileParser::parseInput ( const char *  fileName,
const char *  fileBuf,
Entry root,
bool  sameTranslationUnit,
QStrList filesInSameTranslationUnit 
)
virtual

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

Parameters
[in]fileNameThe full name of the file.
[in]fileBufThe contents of the file (zero terminated).
[in,out]rootThe root of the tree of Entry *nodes representing the information extracted from the file.
[in]sameTranslationUnitTRUE if this file was found in the same translation unit (in the filesInSameTranslationUnit list returned for another file).
[in,out]filesInSameTranslationUnitother files expected to be found in the same translation unit (used for libclang)

Implements ParserInterface.

Definition at line 2353 of file markdown.cpp.

2358 {
2359  Entry *current = new Entry;
2360  current->lang = SrcLangExt_Markdown;
2361  current->fileName = fileName;
2362  current->docFile = fileName;
2363  current->docLine = 1;
2364  QCString docs = fileBuf;
2365  QCString id;
2367  QCString titleFn = QFileInfo(fileName).baseName().utf8();
2369  static QCString mdfileAsMainPage = Config_getString("USE_MDFILE_AS_MAINPAGE");
2370  if (id.isEmpty()) id = markdownFileNameToId(fileName);
2371  if (!mdfileAsMainPage.isEmpty() &&
2372  (fn==mdfileAsMainPage || // name reference
2374  QFileInfo(mdfileAsMainPage).absFilePath()) // file reference with path
2375  )
2376  {
2377  docs.prepend("@mainpage "+title+"\n");
2378  }
2379  else if (id=="mainpage" || id=="index")
2380  {
2381  if (title.isEmpty()) title = titleFn;
2382  docs.prepend("@mainpage "+title+"\n");
2383  }
2384  else
2385  {
2386  if (title.isEmpty()) title = titleFn;
2387  docs.prepend("@page "+id+" "+title+"\n");
2388  }
2389  int lineNr=1;
2390  int position=0;
2391 
2392  // even without markdown support enabled, we still
2393  // parse markdown files as such
2394  bool markdownEnabled = Doxygen::markdownSupport;
2396 
2397  bool needsEntry = FALSE;
2398  Protection prot=Public;
2399  while (parseCommentBlock(
2400  this,
2401  current,
2402  docs,
2403  fileName,
2404  lineNr,
2405  FALSE, // isBrief
2406  FALSE, // javadoc autobrief
2407  FALSE, // inBodyDocs
2408  prot, // protection
2409  position,
2410  needsEntry))
2411  {
2412  if (needsEntry)
2413  {
2414  QCString docFile = current->docFile;
2415  root->addSubEntry(current);
2416  current = new Entry;
2417  current->lang = SrcLangExt_Markdown;
2418  current->docFile = docFile;
2419  current->docLine = lineNr;
2420  }
2421  }
2422  if (needsEntry)
2423  {
2424  root->addSubEntry(current);
2425  }
2426 
2427  // restore setting
2428  Doxygen::markdownSupport = markdownEnabled;
2429  //g_correctSectionLevel = FALSE;
2430 }
static bool markdownSupport
Definition: doxygen.h:153
QCString stripWhiteSpace() const
Definition: qcstring.cpp:295
bool isEmpty() const
Definition: qcstring.h:189
Definition: entry.h:63
Definition: types.h:26
int docLine
line number at which the documentation was found
Definition: entry.h:261
const bool FALSE
Definition: qglobal.h:370
void addSubEntry(Entry *e)
Definition: entry.cpp:206
QString baseName() const
Definition: qfileinfo.cpp:341
QString absFilePath() const
QAsciiDict< Entry > fn
fileName
Definition: dumpTree.py:9
QCString & prepend(const char *s)
Definition: qcstring.cpp:387
static Entry * current
static QCString extractPageTitle(QCString &docs, QCString &id)
Definition: markdown.cpp:2198
#define Config_getString(val)
Definition: config.cpp:660
bool parseCommentBlock(ParserInterface *parser, Entry *curEntry, const QCString &comment, const QCString &fileName, int &lineNr, bool isBrief, bool isAutoBriefOn, bool isInbody, Protection &prot, int &position, bool &newEntryNeeded)
QCString fileName
file this entry was extracted from
Definition: entry.h:282
QString fileName() const
Protection
Definition: types.h:26
QCString docFile
file in which the documentation was found
Definition: entry.h:262
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
QCString markdownFileNameToId(const QCString &fileName)
Definition: markdown.cpp:2344
SrcLangExt lang
programming language in which this entry was found
Definition: entry.h:286
QCString utf8() const
Definition: qstring.cpp:14507
const bool TRUE
Definition: qglobal.h:371
void MarkdownFileParser::parsePrototype ( const char *  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.

Implements ParserInterface.

Definition at line 2467 of file markdown.cpp.

2468 {
2470  if (pIntf!=this)
2471  {
2472  pIntf->parsePrototype(text);
2473  }
2474 }
ParserInterface * getParser(const char *extension)
Definition: parserintf.h:191
Abstract interface for programming language parsers.
Definition: parserintf.h:38
virtual void parsePrototype(const char *text)=0
static ParserManager * parserManager
Definition: doxygen.h:141
void MarkdownFileParser::resetCodeParserState ( )
virtual

Resets the state of the code parser. Since multiple code fragments can together form a single example, an explicit function is used to reset the code parser state.

See also
parseCode()

Implements ParserInterface.

Definition at line 2458 of file markdown.cpp.

2459 {
2461  if (pIntf!=this)
2462  {
2463  pIntf->resetCodeParserState();
2464  }
2465 }
ParserInterface * getParser(const char *extension)
Definition: parserintf.h:191
Abstract interface for programming language parsers.
Definition: parserintf.h:38
static ParserManager * parserManager
Definition: doxygen.h:141
virtual void resetCodeParserState()=0
void MarkdownFileParser::startTranslationUnit ( const char *  fileName)
inlinevirtual

Starts processing a translation unit (source files + headers). After this call parseInput() is called with sameTranslationUnit set to FALSE. If parseInput() returns additional include files, these are also processed using parseInput() with sameTranslationUnit set to TRUE. After that finishTranslationUnit() is called.

Implements ParserInterface.

Definition at line 32 of file markdown.h.

32 {}

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