1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleskandars Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __DOCRIPPER_G__
13 #define __DOCRIPPER_G__
15 #include "scriptbinder.h"
16 #include "srcparser.h"
17 #include "sourcepainter.h"
19 #if defined( wxUSE_TEMPLATE_STL )
23 typedef vector
<ScriptTemplate
*> STemplateListT
;
29 typedef ScriptTemplate
* ScriptTemplatePtrT
;
30 typedef WXSTL_VECTOR_SHALLOW_COPY(ScriptTemplatePtrT
) STemplateListT
;
35 // specific DocGenerator class for "Ripper",
36 // also acts as source code visitor
38 class RipperDocGen
: public DocGeneratorBase
, public spVisitor
41 // templates for various sections
42 ScriptTemplate mTopTempl
;
43 ScriptTemplate mContentIdxTempl
;
44 ScriptTemplate mSuperContentTempl
;
45 ScriptTemplate mSubContentTempl
;
46 ScriptTemplate mOutLineTempl
;
47 ScriptTemplate mOutLine1Templ
;
49 // template used for corss-references
50 ScriptTemplate mRefTempl
;
52 // template used to show not-existing sections
53 ScriptTemplate mDeadRefTempl
;
55 // template collection for generation of class-tree
56 STemplateListT mTreeTemplates
;
58 // pointers to all major index sections
59 ScriptSection
* mpTopIdx
;
60 ScriptSection
* mpClassIdx
;
61 ScriptSection
* mpEnumIdx
;
62 ScriptSection
* mpTypeDefIdx
;
63 ScriptSection
* mpMacroIdx
;
64 ScriptSection
* mpGlobalVarsIdx
;
65 ScriptSection
* mpGlobalFuncIdx
;
66 ScriptSection
* mpConstIdx
;
68 // parser set up from user-code for sepcific language
69 SourceParserBase
* mpParser
;
71 // class section, which is currently being
73 ScriptSection
* mpCurClassSect
;
75 // source syntax heighlighter object
76 SourcePainter mSrcPainter
;
78 // context, to which all file contexts
80 spContext
* mpFileBinderCtx
;
82 // script tags set up from usesr code
87 void AppendComments( spContext
& fromContext
, wxString
& str
);
89 void AppendMulitilineStr( wxString
& st
, wxString
& mlStr
);
91 void AppendHighlightedSource( wxString
& st
, wxString source
);
93 // returns true, if no comments found in the context,
94 // plus, creates dummy(empty) section, and puts a
95 // reference woth "dead-link" template to it in the
96 // given index-section "toSect"
98 bool CheckIfUncommented( spContext
& ctx
, ScriptSection
& toSect
);
100 // checks if context has any comments, then returns
101 // template of normal reference, otherwise of dead reference
103 ScriptTemplate
* GetRefTemplFor( spContext
& ctx
);
105 // adds "someClass::" perfix to the context name,
106 // if it's not in the file scope (i.e. if it's not global)
108 wxString
GetScopedName( spContext
& ofCtx
);
110 // adds section to currently assembled class section
111 // and places references to it from "public", "protected"
112 // or "private" indexing-subsections of the class, depending
113 // on the visibility of the context
115 void AddToCurrentClass( ScriptSection
* pSection
, spContext
& ctx
,
116 const char* subSectionName
);
118 // called, after all files are processed, to
119 // resolve possible super/derived class relations,
120 // and put cross references to them - where resolution was
122 void LinkSuperClassRefs();
124 // implementations of "visiting procedures", declared in spVisitor
126 virtual void VisitClass( spClass
& cl
);
127 virtual void VisitEnumeration( spEnumeration
& en
);
128 virtual void VisitTypeDef( spTypeDef
& td
);
129 virtual void VisitPreprocessorLine( spPreprocessorLine
& pd
);
130 virtual void VisitAttribute( spAttribute
& attr
);
131 virtual void VisitOperation( spOperation
& op
);
133 // overriden member of DocGernatorBase
135 virtual bool OnSaveDocument( ScriptStream
& stm
);
137 virtual ScriptSection
* GetTopSection()
144 // should be called onece to set user-code provided,
145 // parser for specific source code language
146 // (NOTE:: it's the user-code's responsibility to
147 // relseas memory of pParser)
149 void Init( SourceParserBase
* pParser
);
151 // should be called on each file
153 void ProcessFile( const char* sourceFile
);