Sunday 25 March 2012

How to use Doxygen,sample included

Doxygen is any programmers toy which allows you to present your code as a webpage complete with hyper links !!
All you have to do is incorporate certain specific comments in your code,be it a c or c++ or java and so on.
For example the comments which you incorporate into the c code such as
/* this is a comment */
can be embedded with  some additional syntax which allows you to instruct how to build a webpage out of your code.refer for syntax

So this is how things work as obvious is the case we are using the linux environment (don't we all love free stuff !).

install doxygen by " sudo apt-get install doxygen " command in the terminal ,Then once its installed try " doxygen -g " in the terminal this instructs to create a config like file called doxyfile .

The doxyfile contains a set of features and you may want to change it for effective use of doxygen .

Some very important features you may need to change are :

line 601:  FILE_PATTERNS          = " type your file extension "
line 28: PROJECT_NAME           = " type any statement such as the project name or so (it just outputs it in the html file but nevertheless optional)"
line 41: OUTPUT_DIRECTORY       = " Type the path of the directory where you want to store the html and latex folders generated by the doxygen " eg: /home/folder/
 line 63: OUTPUT_LANGUAGE        =  "by default its english but you can set your language here ,this language will be output in the html file"

in lines 189,196,202,208 .. it requests for the optimisation ,if your file is a c or java or fortran or vhdl you can set yes in the approriate section

line 584: INPUT                  = " specify the directory path of the folder comprising your code files (doxygen searches for all *.fileextension (earlier specified in line 601) here )"

line 711: STRIP_CODE_COMMENTS    = " set yes if say you are using a .c file and want to hide the comments as in // and  /*comments*/ "

so once the doxyfile is edited save it.Then we got to actually put the comments in the source file .c or .cpp etc (whatever you are using) the comments here will be actually instruction for the doxygen for syntax please check the link mentioned before.



For example consider a .cpp or c++ file the comments below are given in the file


/*! \mainpage Welcome to The Academic management system
 * \section welcome A software suite to aid in your universities candidate registration and seat selection
 *
 * \image html index.jpeg
 *

 * \section  install  To run you need the ubiquitous
* <a href="en.wikipedia.org/wiki/Linux"> linux</a> OS and the
 * <a href="en.wikipedia.org/wiki/GNU_Compiler_Collection">  gcc</a> <a href="en.wikipedia.org/wiki/Compiler"> compiler </a>
 *\section usage Follow the specified steps to get it going
 * \subsection step1 Step 1:Run the program in the terminal
* \subsection step2 Step 2:Follow the instructions in the screen and act accordingly
* \subsection step3 Step 3:Observe the results upon completion of tasks,in case of any error ,rerun the program
 *
 *
 */

/*!
 *  \brief    program to implementation of Academic management system in c++
 *  \details   The program accepts the student parameter details such as the CGPA,ID,name etc and maintains a database of the same.
it also requires the data regarding the department details such as the department id and the available vacant seats.
 *If for a given department the influx of meritorious students specified by a tier 1 band such as the cgpa 9+ band ,then automatically a 5% increment in total seat is observed.
 *Also the department seats is alloted to the candidates based on their preference order with respect to their CGPA.
 *  \author    Vinayak
 * 
 *  \version   1.0
 *  \date      2-2011
 *  \pre       Run the program in the terminal
 *  \bug       The data entry is restricted as the suite believes the enterd data is authenticated also it does not check for the error in quantum of data entities
 *  \warning   Improper use can crash your application
 *  \copyright  Public License.
 * 
 * 
 *  
 */


\mainpage indicates the mainpage the string following it is the heading of the html file.

to add images use \image pathname to the image

and those <a href="en.wikipedia.org/wiki/Linux"> refers to hyperlinks in your end html file ,you can give any links
<a href="url link"> string representing url link</a>



to add class data in the html file

**
* @class stud
*
* @brief This is the Student class which is used to specify the objects of student type,It specify student name,id,cgpa,preference list.And the Department id as its private members,additionally the various functions to get and set the same which are having the public scope
*
*
*
*
*
*
*
*/

@class classname               @brief  brief introduction

You can even specify the attribute and function data

for a function say

void fu(char *a,char *d,char *co)

{
 **************
return;
}



**
 * \brief   The function is intended to alter the arrays as per the rule depending on the user input in the file b1.txt,Temporary arrays are internally generated and which holds the intermediate data ,eventually the content of the temporary array is transfered to the main array.And similar process is carried out in the next iteration
 *
 * \details   Three iterations are performed and at each iteration the corresponding number of characters in the user chosen card is provided in the array "co" which is utilised,The iteration eventually causes the desired card to arrive at the slot as premised.
 *
 *
 *
 *
 * @param a
 *  The <a href="en.wikipedia.org/wiki/Pointer"> pointer</a>  to an <a href="en.wikipedia.org/wiki/Array"> array</a> is passed here,the array content being the card list ,As the approach illustrates representation of datum of cards as a two one dimensional array rather than a single two dimensional array.
 *   The array holds one component of a two component list which uniquely identifies the card
 *  
 *  
 * @param d
 *   It represent a pointer to an array which holds the other half of the card representation parameter
 * @param co
 *   It also represents an array which is used to hold the length of the spoken word by the user which being indicated in the file b1.txt
 *   Only optional parameters are explicitly stated as such. The description
 *   should clarify the default value if omitted.
 *
 * @return
 *   No return is required as the pointer data is
 *   <a href="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/topic/com.ibm.xlcpp8l.doc/language/ref/cplr233.htm"> passed by reference</a>
 */

@param argument info of the function

Upon adding such comments in your source file save it and then run

doxygen Doxyfile  in the terminal and check the html and latex folders in the destination path we had already specified.
open the html folder and click on the index.html ,now that should open in your browser and thats the webpage which we want !!

I'll now make multiple file program incorporating doxygen comments ,also i'll let you people in for a treat and provide a makefile as well check here

1 comment:

  1. Wow Did god write this ?

    I have been searching the web and this is the only article of this kind!!

    ReplyDelete