Click here to Skip to main content
15,895,799 members
Articles / Desktop Programming / MFC

Documenting Header Files

Rate me:
Please Sign up or sign in to vote.
2.95/5 (14 votes)
16 Sep 2003CPOL6 min read 63.8K   848   24  
This tool will turn a header file into an XML and/or HTML file for documentation purposes. The output may be merged with previously created or edited XML files.
// Helper classes for CDocHDocumentor
//Helperclasses for converting a header file into a HTML file

#if !defined (_MODULHELPERCLASSES_INCLUDED_)
#define _MODULHELPERCLASSES_INCLUDED_

static const enum ModulType
      { mt_unknown   = 0,
	    mt_Modul     = 0x0001,
	    mt_Class     = 0x0002,
        mt_Structure = 0x0003,

	    mt_local     = 0x0010,// scope 
	    mt_global    = 0x0020,

	    mt_private   = 0x0100,// access
	    mt_protected = 0x0200,
	    mt_public    = 0x0300,
      };

// structure to store informations for variables or functions found
struct SModulVariable
{ CString m_strName;      // name of variable or function
  CString m_strHREFName;  // URL of variable or function
  CString m_strClass;     // name of structur or class
  CStringArray m_astrParameter; // function parameters or variable initialization
  CStringArray m_astrReturn;    // return values
  CStringArray m_astrFullName;  // array of fully qualified function names

  CString m_strSplitfileName;   // name of optional split file
  CString m_strSplitfileTitle;  // title for optional split file

  CString m_strShortDescription; // short description of variable or function
  CString m_strLongDescription;  // long description of function

  CStringArray m_astrDescriptionParameter; // description of parameters or variable initialization
  CStringArray m_astrDescriptionReturn;    // description of return values

  enum ModulType m_mtType;  // scope of variable/function

  SModulVariable(void);
  ~SModulVariable(void);
  void Empty(void);
};

// structure to store information for classes found
struct SModulClasses
{ CString m_strName;            // name of class
  CString m_strHREFName;        // URL of class
  CString m_strBaseclass;       // name of base class
  CString m_strHREFVariables;   // URL of data members
  CString m_strHREFFunctions;   // URL of function members

  CString m_strSplitfileName;   // name of optional split file
  CString m_strSplitfileTitle;  // title for optional split file
  CString m_strSplitfileNameClassVariables;
  CString m_strSplitfileTitleClassVariables;
  CString m_strSplitfileNameClassFunctions;
  CString m_strSplitfileTitleClassFunctions;

  CString m_strDescription; // Description of class/structure
  CString m_strDescriptionMemberlist; // Description for memberlist
  CString m_strDescriptionMethodlist; // Description for methodlist
  enum ModulType m_mtType;  // Type of class

  int m_iVariables;               // count of data members to show
  int m_iTotalVariables;          // count of data members found
  int m_iprivateVariables;        // count of private data members found
  int m_iprotectedVariables;      // count of protected data members found
  int m_ipublicVariables;         // count of public data members found
  SModulVariable* m_smvVariables; // array of data member datas

  int m_iFunctions;               // count of function members to show
  int m_iTotalFunctions;          // count of function members found
  int m_iprivateFunctions;        // count of private function members found
  int m_iprotectedFunctions;      // count of protected function members found
  int m_ipublicFunctions;         // count of public function members found
  SModulVariable* m_smvFunctions; // array of function member datas

  SModulClasses(void);
  ~SModulClasses(void);
  void Empty(void);
};

// overall structure to store the information found in a header file
struct SModul
{ CString m_strHTMLTitle;
  CString m_strHREFModul;
  CString m_strHREFGlobalVariables;
  CString m_strHREFGlobalFunctions;
  CString m_strSplitfileModulName;
  CString m_strSplitfileNameGlobalVariables;
  CString m_strSplitfileNameGlobalFunctions;
  CString m_strSplitfileTitleModul;
  CString m_strSplitfileTitleGlobalVariables;
  CString m_strSplitfileTitleGlobalFunctions;
  CString m_strDescription;
  CString m_strDescriptionVariablelist;
  CString m_strDescriptionFunctionlist;

  int			m_iClasses;                 // count of classes
  int			m_iNonClassVariables;       // count of global variables to show
  int			m_iNonClassFunctions;       // count of global functions to show
  int			m_iTotalNonClassVariables;  // count of global variables found
  int			m_iLocalNonClassVariables;  // count of local global variables found
  int			m_iExternNonClassVariables; // count of exported global variables found
  int			m_iTotalNonClassFunctions;  // count of global functions found
  int			m_iLocalNonClassFunctions;  // count of local global functions found
  int			m_iExternNonClassFunctions; // count of exported global functions found
  SModulVariable* m_smvNonClassVariables;  // array of global variables found
  SModulVariable* m_smvNonClassFunctions;  // array of global functions found
  SModulClasses*  m_smcClasses;            // array of classes found

//What shall be done
  bool m_bCreateKeywords;
  bool m_bCreateSplitfiles;
  bool m_bUseStyleSheet;

// What shall be documented
  bool m_bDocumentPublic;
  bool m_bDocumentProtected;
  bool m_bDocumentPrivate;

  bool m_bDocumentExternal;
  bool m_bDocumentInternal;

  CStringArray m_astrHIncludes;
  CStringArray m_astrCPPIncludes;

  SModul(void);
  ~SModul(void);

  void Empty(void);
// Counting various types
  void CountGlobals(CStringArray& astrText);
  void CountClasses(CStringArray& astrText);
  void CountClassMembers(const CString strClassname,  CStringArray& astrText);

// Checking and storing various types
  void FindGlobalVariables(CStringArray& astrText);
  void FindGlobalFunctions(CStringArray& astrText, const CStringArray& astrNotReturns);
  void FindClasses(CStringArray& astrText);
  void FindClassVariables(const CString strClassname, CStringArray& astrText);
  void FindClassFunctions(const CString strClassname, CStringArray& astrText, const CStringArray& astrNotReturns);

  void MakeHREFNames(void);
  void MakeSplitfileNames(const CString &strHeaderFilename, const CString& strHTMLFilename);
};
#endif //_MODULHELPERCLASSES_INCLUDED_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions