library: libHtml #include "THtml.h" |
THtml
class description - header file - source file - inheritance tree (.pdf)
protected:
virtual void BeautifyLine(ostream& srcOut, TString* anchor = 0)
void Class2Html(Bool_t force = kFALSE)
void ClassDescription(ofstream& out)
void ClassHtmlTree(ofstream& out, TClass* classPtr, THtml::ETraverse dir = kBoth, int depth = 1)
void ClassTree(TVirtualPad* canvas, TClass* classPtr, Bool_t force = kFALSE)
Bool_t CopyHtmlFile(const char* sourceName, const char* destName = "")
void CreateHierarchy(const char** classNames, Int_t numberOfClasses)
void CreateIndex(const char** classNames, Int_t numberOfClasses)
void CreateIndexByTopic(char** filenames, Int_t numberOfNames)
void CreateListOfClasses(const char* filter)
void CreateListOfTypes()
void CreateSourceOutputStream(ofstream& out, const char* extension, TString& filename)
void CreateStyleSheet()
void DescendHierarchy(ofstream& out, TClass* basePtr, const char** classNames, Int_t numberOfClasses, Int_t maxLines = 0, Int_t depth = 1)
void ExpandKeywords(ostream& out, const char* line)
void ExpandKeywords(TString& text)
void ExpandPpLine(ostream& out)
TClass* GetClass(const char* name, Bool_t load = kFALSE)
const char* GetFileName(const char* filename)
void GetHtmlFileName(TClass* classPtr, TString& filename)
void GetSourceFileName(TString& filename)
Bool_t IsModified(TClass* classPtr, const Int_t type)
static Bool_t IsName(UChar_t c)
static Bool_t IsWord(UChar_t c)
TMethod* LocateMethodInCurrentLine(Ssiz_t& posMethodName, TString& ret, TString& name, TString& params, ostream& srcOut, TString& anchor, ifstream& sourcefile, Bool_t allowPureVirtual)
void LocateMethods(ofstream& out, const char* filename, Bool_t lookForSourceInfo = kTRUE, Bool_t useDocxxStyle = kFALSE, Bool_t lookForClassDescr = kTRUE, Bool_t allowPureVirtual = kFALSE, const char* methodPattern = "0", const char* sourceExt = "0")
void LocateMethodsInHeaderClassDecl(ofstream& out)
void LocateMethodsInHeaderInline(ofstream& out)
void LocateMethodsInSource(ofstream& out)
void NameSpace2FileName(TString& name)
void ReplaceSpecialChars(ostream& out, const char c)
void ReplaceSpecialChars(ostream& out, const char* string)
void ReplaceSpecialChars(TString& text, Ssiz_t& pos)
void SortNames(const char** strings, Int_t num, Bool_t type = 0)
char* StrDup(const char* s1, Int_t n = 1)
public:
THtml()
THtml(const THtml&)
virtual ~THtml()
static TClass* Class()
void Convert(const char* filename, const char* title, const char* dirname = "")
const char* GetDeclFileName(TClass* cl) const
const char* GetImplFileName(TClass* cl) const
const char* GetOutputDir()
const char* GetSourceDir()
const char* GetXwho() const
virtual TClass* IsA() const
void MakeAll(Bool_t force = kFALSE, const char* filter = "*")
void MakeClass(const char* className, Bool_t force = kFALSE)
void MakeIndex(const char* filter = "*")
void MakeTree(const char* className, Bool_t force = kFALSE)
void SetDeclFileName(TClass* cl, const char* filename)
void SetEscape(char esc = \\)
void SetImplFileName(TClass* cl, const char* filename)
void SetOutputDir(const char* dir)
void SetSourceDir(const char* dir)
void SetSourcePrefix(const char* prefix)
void SetXwho(const char* xwho)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
virtual void WriteHtmlFooter(ofstream& out, const char* dir = "", const char* lastUpdate = "", const char* author = "", const char* copyright = "")
virtual void WriteHtmlHeader(ofstream& out, const char* title, const char* dir = "", TClass* cls = 0)
protected:
TString fXwho by default http://xwho.cern.ch/WHO/people?
TString fSourcePrefix prefix to relative source path
TString fSourceDir source path
TString fOutputDir output directory
TString fLine current line
TString fLineExpanded current line with links
TClass* fCurrentClass current class context of sources being parsed
map<string,int,less<string>,allocator<pair<const string,int> > > fMethodNames current class's method names
THtml::EDocContext fDocContext current context of parsed sources for documenting
THtml::EParseContext fParseContext current context of parsed sources
TString fSourceInfo[3] author, last changed, ...
TString fCounter counter string
Bool_t fEscFlag Flag to mark the symbol must be written "as is"
char fEsc The special symbol ("backslash" by default) to mark "the next symbol should not be converted"
Int_t fHierarchyLines counter for no. lines in hierarchy
Int_t fNumberOfClasses Number of known classes
const char** fClassNames Names of known classes
Int_t fNumberOfFileNames Number of names of files for known classes
char** fFileNames Names of files for known classes
list<std::string> fModules Names of modules
map<TClass*,std::string> fGuessedDeclFileNames names of additional decl file names
map<TClass*,std::string> fGuessedImplFileNames names of additional impl file names
static set<std::string> fgKeywords C++ keywords
public:
static const THtml::ETraverse kUp
static const THtml::ETraverse kDown
static const THtml::ETraverse kBoth
static const THtml::EParseContext kCode
static const THtml::EParseContext kCComment
static const THtml::EParseContext kBeginEndHtml
static const THtml::EParseContext kBeginEndHtmlInCComment
static const THtml::EParseContext kString
static const THtml::EParseContext kNumParseContexts
static const THtml::EDocContext kIgnore
static const THtml::EDocContext kDocFunc
static const THtml::EDocContext kDocClass
static const THtml::EDocContext kNumDocContexts
static const THtml::ESourceInfo kInfoLastUpdate
static const THtml::ESourceInfo kInfoAuthor
static const THtml::ESourceInfo kInfoCopyright
static const THtml::ESourceInfo kNumSourceInfos
The HyperText Markup Language (HTML) is a simple data format used to
create hypertext documents that are portable from one platform to another.
HTML documents are SGML documents with generic semantics that are
appropriate for representing information from a wide range of domains.
The THtml class is designed to provide an easy way for converting ROOT
classes, and files as well, into HTML documents. Here are the few rules and
suggestions for a configuration, coding and usage.
Configuration:
-------------
(i) Input files
Define Root.Html.SourceDir to point to directories containing .cxx and
.h files ( see: TEnv ) of the classes you want to document. Better yet,
specify separate Unix.*.Root.Html.SourceDir and WinNT.*.Root.Html.SourceDir.
Root.Html.SourcePrefix can hold an additional (relative) path to help THtml
find the source files. Its default value is "". Root's class documentation
files can be linked in if Root.Html.Root is set to Root's class
documentation root. It defaults to "".
Examples:
Unix.*.Root.Html.SourceDir: .:src:include
WinNT.*.Root.Html.SourceDir: .;src;include
Root.Html.SourcePrefix:
Root.Html.Root: http://root.cern.ch/root/html
(ii) Output directory
The output directory can be specified using the Root.Html.OutputDir
environment variable ( default value: "htmldoc" ). If it doesn't exist, it
will be created.
Examples (with defaults given):
Root.Html.OutputDir: htmldoc
(iii) Class documentation
The class documentation has to appear in the header file containing the
class, right in front of its declaration. It is introduced by a string
defined by Root.Html.Description. See below, section "Coding", for
further details.
Examples (with defaults given):
Root.Html.Description: //____________________
(iv) Source file information
During the conversion, THtml will look for the certain number of user
defined strings ("tags") in the source file, which have to appear right in
front of e.g. the author's name, copyright notice, etc. These tags can be
defined with the following environment variables: Root.Html.Author,
Root.Html.LastUpdate and Root.Html.Copyright.
If the LastUpdate tag is not found, the current date and time are given.
This makes sense if one uses THtml's default option force=kFALSE, in which
case THtml generates documentation only for changed classes.
Authors can be a comma separated list of author entries. Each entry has
one of the following two formats:
* "Name (non-alpha)". THtml will generate an HTML link for Name, taking
the Root.Html.XWho environment variable (defaults to
"http://consult.cern.ch/xwho/people?") and adding all parts of the name
with spaces replaces by '+'. Non-Alphas are printed out behind Name.
Example: "// Author: Enrico Fermi" appears in the source file. THtml
will generate the link
"http://consult.cern.ch/xwho/people?Enrico+Fermi". This works well for
people at CERN.
* "Name <link> Info" THtml will generate a HTML link for Name as specified
by "link" and print Info behind Name.
Example: "// Author: Enrico Fermi <http://www.enricos-home.it>" or
"// Author: Enrico Fermi <mailto:enrico@fnal.gov>" in the
source file. That's world compatible.
Examples (with defaults given):
Root.Html.Author: // Author:
Root.Html.LastUpdate: // @(#)
Root.Html.Copyright: * Copyright
Root.Html.XWho: http://consult.cern.ch/xwho/people?
(v) Style
THtml generates a default header and footer for all pages. You can
specify your own versions with the environment variables Root.Html.Header
and Root.Html.Footer. Both variables default to "", using the standard Root
versions. If set the parameter to your file and append a "+", THtml will
write both versions (user and root) to a file, for the header in the order
1st root, 2nd user, and for the footer 1st user, 2nd root (the root
versions containing "<html>" and </html> tags, resp).
If you want to replace root's header you have to write a file containing
all HTML elements necessary starting with the <DOCTYPE> tag and ending with
(and including) the <BODY> tag. If you add your header it will be added
directly after Root's <BODY> tag. Any occurrence of the string "%TITLE%"
(without the quotation marks) in the user's header file will be replaced by
a sensible, automatically generated title. If the header is generated for a
class, occurrences of %CLASS% will be replaced by the current class's name,
%SRCFILE% and %INCFILE% by the name of the source and header file, resp.
(as given by TClass::GetImplFileName(), TClass::GetDeclFileName()).
If the header is not generated for a class, they will be replaced by "".
Root's footer starts with the tag "<!--SIGNATURE-->". It includes the
author(s), last update, copyright, the links to the Root home page, to the
user home page, to the index file (ClassIndex.html), to the top of the page
and "this page is automatically generated" infomation. It ends with the
tags "</body></html>". If you want to replace it, THtml will search for some
tags in your footer: Occurrences of the strings "%AUTHOR%", "%UPDATE%", and
"%COPYRIGHT%" (without the quotation marks) are replaced by their
corresponding values before writing the html file. The %AUTHOR% tag will be
replaced by the exact string that follows Root.Html.Author, no link
generation will occur.
(vi) Miscellaneous
Additional parameters can be set by Root.Html.Homepage (address of the
user's home page), Root.Html.SearchEngine (search engine for the class
documentation) and Root.Html.Search (search URL). All default to "".
Examples:
Root.Html.Homepage: http://www.enricos-home.it
Root.Html.SearchEngine: http://root.cern.ch/root/Search.phtml
Root.Html.Search: http://www.google.com/search?q=%s+site%3Aroot.cern.ch%2Froot%2Fhtml
(vii) HTML Charset
HTML 4.01 transitional recommends the specification of the charset in the
content type meta tag, see e.g.
http://www.w3.org/TR/REC-html40/charset.html
THtml generates it for the HTML output files. It defaults to ISO-8859-1, and
can be changed using Root.Html.Charset.
Example:
Root.Html.Charset: EUC-JP
Coding rules:
------------
A class description block, which must be placed before the first
member function, has a following form:
//
// TMyClass
//
// This is the description block.
//
The environment variable Root.Html.Description ( see: TEnv ) contents
the delimiter string ( default value: //_________________ ). It means
that you can also write your class description block like this:
//_____________________________________________________________
// A description of the class starts with the line above, and
// will take place here !
Note that EVERYTHING until the first non-commented line is considered
as a valid class description block.
A member function description block starts immediately after '{'
and looks like this:
void TWorld::HelloWorldFunc(string *text)
{
// This is an example of description for the
// TWorld member function
helloWorld.Print( text );
}
Like in a class description block, EVERYTHING until the first
non-commented line is considered as a valid member function
description block.
==> The "Begin_Html" and "End_Html" special keywords <=========
--------------------------------------------
You can insert pure html code in your comment lines. During the
generation of the documentation, this code will be inserted as is
in the html file.
Pure html code must be inserted between the keywords "Begin_Html"
and "End_Html" starting/finishing anywhere in the comment lines.
Examples of pure html code are given in many Root classes.
See for example the classes TDataMember and TMinuit.
==> The escape character
--------------------
Outside blocks starting with "Begin_Html" and finishing with "End_Html"
one can prevent the automatic translation of symbols like "<" and ">"
to "<" and ">" by using the escape character in front.
The default escape character is backslash and can be changed
via the member function SetEscape.
==> The ClassIndex
--------------
All classes to be documented will have an entry in the ClassIndex.html,
showing their name with a link to their documentation page and a miniature
description. This discription for e.g. the class MyClass has to be given
in MyClass's header as a comment right after ClassDef( MyClass, n ).
Usage:
-----
Root> THtml html; // create a THtml object
Root> html.MakeAll() // invoke a make for all classes
Root> html.MakeClass("TMyClass") // create a HTML files for that class only
Root> html.MakeIndex() // creates an index files only
Root> html.MakeTree("TMyClass") // creates an inheritance tree for a class
Root> html.Convert( hist1.mac, "Histogram example" )
Environment variables:
---------------------
Root.Html.OutputDir (default: htmldoc)
Root.Html.SourceDir (default: .:src/:include/)
Root.Html.Author (default: // Author:) - start tag for authors
Root.Html.LastUpdate (default: // @(#)) - start tag for last update
Root.Html.Copyright (default: * Copyright) - start tag for copyright notice
Root.Html.Description (default: //____________________ ) - start tag for class descr
Root.Html.HomePage (default: ) - URL to the user defined home page
Root.Html.Header (default: ) - location of user defined header
Root.Html.Footer (default: ) - location of user defined footer
Root.Html.Root (default: ) - URL of Root's class documentation
Root.Html.SearchEngine (default: ) - link to the search engine
Root.Html.XWho (default: http://consult.cern.ch/xwho/people?) - URL stem of CERN's xWho system
Root.Html.Charset (default: ISO-8859-1) - HTML character set
THtml()
Create a THtml object.
In case output directory does not exist an error
will be printed and gHtml stays 0 also zombie bit will be set.
void CreateSourceOutputStream(std::ofstream& out, const char* extension, TString& sourceHtmlFileName)
Open a Class.cxx.html file, where Class is defined by classPtr, and .cxx.html by extension
It's created in fOutputDir/src. If successful, the HTML header is written to out.
TMethod* LocateMethodInCurrentLine(Ssiz_t &posMethodName, TString& ret, TString& name, TString& params, std::ostream &srcOut, TString &anchor, std::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 fMethodNames.
void LocateMethods(std::ofstream & out, const char* filename, Bool_t lookForSourceInfo /*= kTRUE*/, Bool_t useDocxxStyle /*= kFALSE*/, Bool_t lookForClassDescr /*= kTRUE*/, 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
fMethodNames are searched for.
void ClassHtmlTree(ofstream & out, TClass * classPtr, ETraverse dir, int depth)
This function builds the class tree for one class in HTML
(inherited and succeeding classes, called recursively)
Input: out - output file stream
classPtr - pointer to the class
dir - direction to traverse tree: up, down or both
void ClassTree(TVirtualPad * psCanvas, TClass * classPtr, Bool_t force)
It makes a graphical class tree
Input: psCanvas - pointer to the current canvas
classPtr - pointer to the class
void Convert(const char *filename, const char *title, const char *dirname)
It converts a single text file to HTML
Input: filename - name of the file to convert
title - title which will be placed at the top of the HTML file
dirname - optional parameter, if it's not specified, output will
be placed in html/examples directory.
NOTE: Output file name is the same as filename, but with extension .html
Bool_t CopyHtmlFile(const char *sourceName, const char *destName)
Copy file to HTML directory
Input: sourceName - source file name
destName - optional destination name, if not
specified it would be the same
as the source file name
Output: TRUE if file is successfully copied, or
FALSE if it's not
NOTE: The destination directory is always fOutputDir
void CreateIndex(const char **classNames, Int_t numberOfClasses)
Create an index
Input: classNames - pointer to an array of class names
numberOfClasses - number of elements
void CreateIndexByTopic(char **fileNames, Int_t numberOfNames)
It creates several index files
Input: fileNames - pointer to an array of file names
numberOfNames - number of elements in the fileNames array
maxLen - maximum length of a single name
void CreateHierarchy(const char **classNames, Int_t numberOfClasses)
Create a hierarchical class list
The algorithm descends from the base classes and branches into
all derived classes. Mixing classes are displayed several times.
Input: classNames - pointer to an array of class names
numberOfClasses - number of elements
void DescendHierarchy(ofstream & out, TClass* basePtr, const char **classNames, Int_t numberOfClasses, Int_t maxLines, Int_t depth)
Descend hierarchy recursively
loop over all classes and look for classes with base class basePtr
void ExpandKeywords(TString& keyword)
Find keywords in keyword 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.
void ExpandPpLine(ostream & out)
Expand preprocessor statements
Input: out - output file stream
NOTE: Looks for the #include statements and
creates link to the corresponding file
if such file exists
const char * GetFileName(const char *filename)
It discards any directory information inside filename
Input: filename - pointer to the file name
Output: pointer to the string containing just a file name
without any other directory information, i.e.
'/usr/root/test.dat' will return 'test.dat'
void GetSourceFileName(TString& filename)
Find the source file. If filename contains a path it will be used
together with the possible source prefix. If not found we try
old algorithm, by stripping off the path and trying to find it in the
specified source search path.
void GetHtmlFileName(TClass * classPtr, TString& filename)
Return real HTML filename
Input: classPtr - pointer to a class
filename - string containing a full name
of the corresponding HTML file after the function returns.
TClass * GetClass(const char *name1, Bool_t load)
*-*-*-*-*Return pointer to class with name*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =================================
Bool_t IsModified(TClass * classPtr, const Int_t type)
Check if file is modified
Input: classPtr - pointer to the class
type - file type to compare with
values: kSource, kInclude, kTree
Output: TRUE - if file is modified since last time
FALSE - if file is up to date
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_]
void MakeAll(Bool_t force, const char *filter)
Produce documentation for all the classes specified in the filter (by default "*")
To process all classes having a name starting with XX, do:
html.MakeAll(kFALSE,"XX*");
If force=kFALSE (default), only the classes that have been modified since
the previous call to this function will be generated.
If force=kTRUE, all classes passing the filter will be processed.
void MakeClass(const char *className, Bool_t force)
Make HTML files for a single class
Input: className - name of the class to process
void MakeIndex(const char *filter)
It makes an index files
by default makes an index of all classes (if filter="*")
To generate an index for all classes starting with "XX", do
html.MakeIndex("XX*");
void MakeTree(const char *className, Bool_t force)
Make an inheritance tree
Input: className - name of the class to process
void ReplaceSpecialChars(ostream & out, const char c)
Replace ampersand, less-than and greater-than character, writing to out.
Input: out - output file stream
c - single character
void ReplaceSpecialChars(TString& text, Ssiz_t &pos)
Replace ampersand, less-than and greater-than character
Input: text - text where replacement will happen,
pos - index of char to be replaced; will point to next char to be
replaced when function returns
void ReplaceSpecialChars(ostream & out, const char *string)
Replace ampersand, less-than and greater-than characters, writing to out
Input: out - output file stream
string - pointer to an array of characters
void SortNames(const char **strings, Int_t num, Bool_t type)
Sort strings
Input: strings - pointer to an array of strings
type - sort type
values : kCaseInsensitive, kCaseSensitive
default: kCaseInsensitive
char * StrDup(const char *s1, Int_t n)
Returns a pointer to a new string which is a duplicate
of the string to which 's1' points. The space for the
new string is obtained using the 'new' operator. The new
string has the length of 'strlen(s1) + n'.
void WriteHtmlHeader(ofstream & out, const char *title, const char* dir /*=""*/, TClass *cls/*=0*/)
{
Write HTML header
Input: out - output file stream
title - title for the HTML page
cls - current class
dir - relative directory to reach the top
("" for html doc, "../" for src/*cxx.html etc)
evaluates the Root.Html.Header setting:
* if not set, the standard header is written. (ROOT)
* if set, and ends with a "+", the standard header is written and this file included afterwards. (ROOT, USER)
* if set but doesn't end on "+" the file specified will be written instead of the standard header (USER)
Any occurrence of "%TITLE%" (without the quotation marks) in the user provided header file
will be replaced by the value of this method's parameter "title" before written to the output file.
%CLASS% is replaced by the class name ("" if not a class), %INCFILE% by the header file name as
given by TClass::GetDeclFileName() and %SRCFILE% by the source file name as given by
TClass::GetImplFileName() (both "" if not a class).
void WriteHtmlFooter(ofstream & out, const char *dir, const char *lastUpdate, const char *author, const char *copyright)
Write HTML footer
Input: out - output file stream
dir - usually equal to "" or "../", depends of
current file directory position, i.e. if
file is in the fOutputDir, then dir will be ""
lastUpdate - last update string
author - author's name
copyright - copyright note
Allows optional user provided footer to be written. Root.Html.Footer holds the file name for this footer.
For details see THtml::WriteHtmlHeader (here, the "+" means the user's footer is written in front of Root's!)
Occurences of %AUTHOR%, %UPDATE% and %COPYRIGHT% in the user's file are replaced by their corresponding
values (author, lastUpdate and copyright) before written to out.
Author: Nenad Buncic (18/10/95), Axel Naumann (09/28/01)
Last update: root/html:$Name: $:$Id: THtml.cxx,v 1.102 2006/07/11 10:39:15 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.