ROOT logo
ROOT » HTML » TDocParser

class TDocParser: public TObject

 Parse C++ source or header, and extract documentation.

 Also handles special macros like

output of MACRO_TDocParser_0_testMainFrame
   TGMainFrame* f = new TGMainFrame(0, 100, 100);
   f->SetName("testMainFrame"n c's part of the name of the image
   TGButton* b = new TGTextButton(f, "Test Button");

   return f; 
 or multiline Latex aligned at =:

C = d #sqrt{#frac{2}{#lambdaD}} #int^{x}_{0}cos(#frac{#pi}{2}t^{2})dt 
 even without alignment:
x=sin^2(y) and what about running an external macro?

output of MACRO_TDocParser_3_c
TObject* testmacro() 
   TH1* h = new TH1F("h", "h", 100, 0., 1.);
   TCanvas* c=new TCanvas("c","c");
   return c;

and some nested stuff which doesn't work yet: 

/* BEGIN_LATEX Wow,^{an}_{image}^{inside}_{a}^{html}_{block} END_LATEX */

Function Members (Methods)

TDocParser(TDocOutput& docOutput)
TDocParser(TClassDocOutput& docOutput, TClass* cl)
voidTObject::AbstractMethod(const char* method) const
static voidAnchorFromLine(const TString& line, TString& anchor)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
voidConvert(ostream& out, istream& in, const char* relpath, Bool_t isCode, Bool_t interpretDirectives)
virtual voidTObject::Copy(TObject& object) const
virtual voidDecorateKeywords(TString& text)
virtual voidDecorateKeywords(ostream& out, const char* text)
voidDecrementMethodCount(const char* name)
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual voidDeleteDirectiveOutput() const
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
TClass*GetCurrentClass() const
voidGetCurrentModule(TString& out_module) const
const TList*GetDataMembers(TDocParser::EAccess access) const
TDocOutput*GetDocOutput() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
const TList*GetEnums(TDocParser::EAccess access) const
virtual const char*TObject::GetIconName() const
Long_tGetLineNumber() const
const TList*GetMethods(TDocParser::EAccess access) const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
const char*GetSourceInfo(TDocParser::ESourceInfo type) const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
UInt_tInContext(Int_t context) const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
static Bool_tIsName(UChar_t c)
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
static Bool_tIsWord(UChar_t c)
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject&TObject::operator=(const TObject& rhs)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidParse(ostream& out)
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCurrentModule(const char* module)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
static Bool_tStrip(TString& s)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
voidAddClassDataMembersRecursively(TBaseClass* bc)
voidAddClassMethodsRecursively(TBaseClass* bc)
TDocParser::EParseContextContext() const
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual voidExpandCPPLine(TString& line, Ssiz_t& pos)
virtual Bool_tHandleDirective(TString& keyword, Ssiz_t& pos, TString& word, Ssiz_t& copiedToCommentUpTo)
virtual voidInitKeywords() const
virtual TClass*IsDirective(const TString& line, Ssiz_t pos, const TString& word, Bool_t& begin) const
TMethod*LocateMethodInCurrentLine(Ssiz_t& posMethodName, TString& ret, TString& name, TString& params, ostream& srcOut, TString& anchor, ifstream& sourcefile, Bool_t allowPureVirtual)
voidLocateMethods(ostream& out, const char* filename, Bool_t lookForSourceInfo = kTRUE, Bool_t useDocxxStyle = kFALSE, Bool_t allowPureVirtual = kFALSE, const char* methodPattern = 0, const char* sourceExt = 0)
voidLocateMethodsInHeaderClassDecl(ostream& out)
voidLocateMethodsInHeaderInline(ostream& out)
voidLocateMethodsInSource(ostream& out)
virtual Bool_tProcessComment()
voidRemoveCommentContext(Bool_t cxxcomment)
voidWriteClassDoc(ostream& out, Bool_t first = kTRUE)
voidWriteMethod(ostream& out, TString& ret, TString& name, TString& params, const char* file, TString& anchor, TString& codeOneLiner)
voidWriteSourceLine(ostream& out)

Data Members

enum EDocContext { kIgnore
enum ESourceInfo { kInfoLastUpdate
enum EAccess { kPrivate
enum EParseContext { kNoContext
enum EParseContextFlag { kCXXComment
enum { kClassDoc_Uninitialized
enum TObject::EStatusBits { kCanDelete
enum TObject::[unnamed] { kIsOnHeap
Bool_tfAllowDirectiveswhether directives are to be interpreted
Bool_tfCheckForMethodwhether to check the current line for a method
TStringfClassDescrTagtag for finding the class description
enum TDocParser::fClassDocStatewhether we found the class description
TStringfCommentcurrent comment
Bool_tfCommentAtBOLat the beginning of the current line, fParseContext contained kComment
TClass*fCurrentClasscurrent class context of sources being parsed
TStringfCurrentFilecurrent source / header file name
TStringfCurrentMethodTagname_idx of the currently parsed method
TStringfCurrentModulecurrent module context of sources being parsed
TListfDataMembers[6]data members (by access, plus enums)
Int_tfDirectiveCountindex of directive for current method
TListfDirectiveHandlershandler for doc directives (TDocDirective objects)
TDocParser::EDocContextfDocContextcurrent context of parsed sources for documenting
TDocOutput*fDocOutputTDocOutput invoking us
set<UInt_t>fExtraLinesWithAnchorlines that need an additional anchor
TStringfFirstClassDocfirst class-doc found - per file, taken if fLastClassDoc is empty
THtml*fHtmlTHtml object using us
TStringfLastClassDoclast class-doc found - becomes class doc at ClassImp or first method
TStringfLineCommentcurrent line with links and directives for doc
UInt_tfLineNocurrent line number
Long_tfLineNumbersource line number
TStringfLineRawcurrent line
TStringfLineSourcecurrent line with links
TStringfLineStrippedcurrent line without surrounding spaces
map<std::string,Int_t>fMethodCountsnumber of undocumented overloads
THashListfMethods[3]methods as TMethodWrapper objects (by access)
list<UInt_t>fParseContextcurrent context of parsed sources
TClass*fRecentClassrecently seen class context of sources being parsed, e.g. for Convert()
TStringfSourceInfo[5]author, last changed, ...
TStringfSourceInfoTags[5]tags for source info elements (copyright, last changed, author)
static set<std::string>fgKeywordsC++ keywords

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TDocParser(TClassDocOutput& docOutput, TClass* cl)
 Constructor called for parsing class sources
TDocParser(TDocOutput& docOutput)
 constructor called for parsing text files with Convert()
 destructor, checking whether all methods have been found for gDebug > 3
void AddClassMethodsRecursively(TBaseClass* bc)
 Add accessible (i.e. non-private) methods of base class bc
 and its base classes' methods to methodNames.
 If bc==0, we add fCurrentClass's methods (and also private functions).
void AddClassDataMembersRecursively(TBaseClass* bc)
 Add data members of fCurrentClass and of bc to datamembers, recursively.
 Real data members are in idx 0..2 (public, protected, private access),
 enum constants in idx 3..5.
void AnchorFromLine(const TString& line, TString& anchor)
 Create an anchor from the given line, by hashing it and
 convertig the hash into a custom base64 string.
void Convert(ostream& out, istream& in, const char* relpath, Bool_t isCode, Bool_t interpretDirectives)
 Parse text file "in", add links etc, and write output to "out".
 If "isCode", "in" is assumed to be C++ code.
void DecorateKeywords(ostream& out, const char* text)
 Expand keywords in text, writing to out.
void DecorateKeywords(TString& text)
 Find keywords in line and create URLs around them. Escape characters with a
 special meaning for HTML. Protect "Begin_Html"/"End_Html" pairs, and set the
 parsing context. Evaluate sequences like a::b->c.
 Skip regions where directives are active.
void DecrementMethodCount(const char* name)
 reduce method count for method called name,
 removing it from fMethodCounts once the count reaches 0.
void DeleteDirectiveOutput() const
 Delete output generated by prior runs of all known directives;
 the output file names might have changes.
void ExpandCPPLine(TString& line, Ssiz_t& pos)
 Expand preprocessor statements

 Input: line - line containing the CPP statement,
        pos  - position of '#'

  NOTE: Looks for the #include statements and
        creates link to the corresponding file
        if such file exists

void GetCurrentModule(TString& out_module) const
 Return the name of module for which sources are currently parsed.
Bool_t HandleDirective(TString& keyword, Ssiz_t& pos, TString& word, Ssiz_t& copiedToCommentUpTo)
 Process directives to the documentation engine, like "Begin_Html" / "End_Html",
 "Begin_Macro" / "End_Macro", and "Begin_Latex" / "End_Latex".
UInt_t InContext(Int_t context) const
 checks whether we are in a parse context, return the entry closest
 to the current context.
 If context is a EParseContextFlag just look for the first match in
 the flags
void InitKeywords() const
 fill C++ keywords into fgKeywords
TClass* IsDirective(const TString& line, Ssiz_t pos, const TString& word, Bool_t& begin) const
 return whether word at line's pos is a valid directive, and returns its
 TDocDirective's TClass object, or 0 if it's not a directive. Set begin
 to kTRUE for "Begin_..."
 You can implement your own handlers by implementing a class deriving
 from TDocHandler, and calling it TDocTagDirective for "BEGIN_TAG",
 "END_TAG" blocks.
Bool_t IsName(UChar_t c)
 Check if c is a valid C++ name character

  Input: c - a single character

 Output: TRUE if c is a valid C++ name character
         and FALSE if it's not.

   NOTE: Valid name characters are [a..zA..Z0..9_~],

Bool_t IsWord(UChar_t c)
 Check if c is a valid first character for C++ name

  Input: c - a single character

 Output: TRUE if c is a valid first character for C++ name,
         and FALSE if it's not.

   NOTE: Valid first characters are [a..zA..Z_~]

TMethod* LocateMethodInCurrentLine(Ssiz_t& posMethodName, TString& ret, TString& name, TString& params, ostream& srcOut, TString& anchor, ifstream& sourcefile, Bool_t allowPureVirtual)
 Search for a method starting at posMethodName, and return its return type,
 its name, and its arguments. If the end of arguments is not found in the
 current line, get a new line from sourceFile, beautify it to srcOut, creating
 an anchor as necessary. When this function returns, posMethodName points to the
 end of the function declaration, i.e. right after the arguments' closing bracket.
 If posMethodName == kNPOS, we look for the first matching method in fMethodCounts.
void Parse(ostream& out)
 Locate methods, starting in the source file, then inline, then
 immediately inside the class declaration. While doing that also
 find the class description and special tags like the macro tag etc.
void LocateMethods(ostream& out, const char* filename, Bool_t lookForSourceInfo = kTRUE, Bool_t useDocxxStyle = kFALSE, Bool_t allowPureVirtual = kFALSE, const char* methodPattern = 0, const char* sourceExt = 0)
 Collect methods from the source or header file called filename.
 It generates a beautified version of the source file on the fly;
 the output file is given by the fCurrentClass's name, and sourceExt.
 Documentation is extracted to out.
   lookForSourceInfo: if set, author, lastUpdate, and copyright are
     extracted (i.e. the values contained in fSourceInfo)
   useDocxxStyle: if set, documentation can be in front of the method
     name, not only inside the method. Useful doc Doc++/Doxygen style,
     and inline methods.
   lookForClassDescr: if set, the first line matching the class description
     rules is assumed to be the class description for fCurrentClass; the
     description is written to out.
   methodPattern: if set, methods have to be prepended by this tag. Usually
     the class name + "::". In header files, looking for in-place function
     definitions, this should be 0. In that case, only functions in
     fMethodCounts are searched for.
void LocateMethodsInSource(ostream& out)
 Given fCurrentClass, look for methods in its source file,
 and extract documentation to out, while beautifying the source
 file in parallel.
void LocateMethodsInHeaderInline(ostream& out)
 Given fCurrentClass, look for methods in its header file,
 and extract documentation to out.
void LocateMethodsInHeaderClassDecl(ostream& out)
 Given fCurrentClass, look for methods in its header file's
 class declaration block, and extract documentation to out,
 while beautifying the header file in parallel.
Bool_t ProcessComment()
 Parse the current line as a comment, handling directives and re-formatting
 the comment: remove "/*", "*/", "//", similar characters surrounding lines,

 Return kFALSE if the line is not a comment.
void RemoveCommentContext(Bool_t cxxcomment)
 remove the top-most comment context that matches cxxcomment,
Bool_t Strip(TString& s)
 strips ' ', tabs, and newlines from both sides of str
void WriteClassDoc(ostream& out, Bool_t first = kTRUE)
 Write the class description depending (among others) on fClassDocState.
void WriteMethod(ostream& out, TString& ret, TString& name, TString& params, const char* file, TString& anchor, TString& codeOneLiner)
 Write a method, forwarding to TClassDocOutput
void WriteSourceLine(ostream& out)
 Write fLineSource to out.
 Adjust relative paths first.
const TList* GetMethods(TDocParser::EAccess access) const
{ return &fMethods[access]; }
TClass* GetCurrentClass() const
{ return fCurrentClass; }
TDocOutput* GetDocOutput() const
{ return fDocOutput; }
Long_t GetLineNumber() const
{ return fLineNumber; }
const TList* GetDataMembers(TDocParser::EAccess access) const
{ return &fDataMembers[access]; }
const TList* GetEnums(TDocParser::EAccess access) const
{ return &fDataMembers[access+3]; }
const char* GetSourceInfo(TDocParser::ESourceInfo type) const
{ return fSourceInfo[type]; }
void SetCurrentModule(const char* module)
{ fCurrentModule = module; }