Thread: Re: [Doxygen-users] adding doxygen comments to code
Brought to you by:
dimitri
From: woody <kn...@re...> - 2015-06-26 15:46:36
|
At 01:49 AM 6/26/2015 -0400, you wrote: >Woody, >I would strongly disagree about adding that functionality directly into >doxygen. In its normal usage, it totally should not be changing the source >base, and for that to happen with just an option change. The code to add >the comment frames into the source files would be a much simpler program >than doxygen itself, and if such a feature was added, having a separate >executable makes much more sense to me. That sounds logical, which is why I said, "have it generate a diff-merge" file that can be run through a diff merger. I'm kind of comparing what the old c-doc did. For a large program that does not have doxygen headers, it would take a large amount of time to go through and add them. Doxygen *could* create a diff-merge file though pretty easily. It would not add the comments to the source, just make a file that could be run through a diff merger. Cdoc would do this for you, but it was an option to add the comments to the file. typically you did it once. As you can see, this was done back in 2004. The code is now 11 years old, and this has never been updated, primarily because C-Doc isn't around any more.:, secondarily because I don't have the documentation for the version of C-Doc that I do have. Of course, this isn't doxygen compliant, obviously, since doxygen wasn't around in the 1980's when C-Doc was first created. /*FF*********************************************************************** FUNCT: update_intensity 2004/09/22 14:29 USERS: main update_current_values DEFIN: INTENSITY_ALLOWED INTENSITY_MODIFY INTENSITY_OVERIDE USER_MAX_INTS GLOBL: control_arrays.intensity_array control_arrays.permission control_arrays.table_pointer control_arrays.table_pointer->intensity_maximum control_arrays.table_pointer->intensity_minimum control_arrays.table_pointer->intensity_type current_intensity current_user_intensity PARAM: flags next_entry LOCAL: permit **************************************************************************/ >I will point out a big reason I don't think you want to do this. Doxygen >is fully capable of generating the documentation for objects without the >comments being present, and can also generate a list of warning for items >that it created documentation without comments. I have not seen it do any warnings like that todate > If the default documentation is good enough, It really isn't. There are lots of holes that I see so far, including no cross reference that gives you all the line numbers where a symbol is used. Especially global variables. I know Doxygen has all the information to do that. Other holes I know Doxygen could fill in with the proper headers, but the syntax of the headers is obtuse at best, and would take a huge amount of time to manually add to any non-trivial program,. >you don't need to add the comments to the code to get them (but I think >normally you want to go in and improve on them). yes, but on a multi thousand line code base that would be very expensive in terms of time and money. It seems so logical to have Doxygen be able to do it for you on a one time basis to get a start. It baffles me that it can't. It certainly has the information. It would make it a much more complete documentation tool. > Having the undocumented warning is a good way to get a task list of > stuff that you want to go in to improve. If you automatically add the > comments, the warnings go away and you need to do something else to keep > track of what is needed to improve the entries. I would disagree, once the comments are added, and you have the result, then it would be a magnitude easier to tweak them until they were fine. You could always run it once, and save the warning file, then add the comments in. You can always refer to the warning file to go in and clean things up, but the tool would have saved potentially hundreds of man-hours of time. Here is the problem. The major use case for doxygen is to come in behind some guy who wrote a bunch of code, and gain some idea of how the code works, so you can maintain it, and create a documentation package for it. I've been writing code since 1976 for micros, and have made a career as a temp. Ninety percent of the time, I would be coming in to rescue a project where the original programmer left and/or is not contactable (in one case he was in a mental institution, I kid you not). So you take the code, and run it through whatever tools you have so you can pick up and go. Doxygen is most of the way there, but it desperately needs a way to be able to insert the comments it can generate, into the source. C-Doc doesn't exist any more, (though I have an old copy), and no one has the key for the newer copy. Additionally without any kind of manual, it is pretty hard to get the options right. In this case *I* wrote the code over the past 10 years, and now it needs to be put in shape so someone coming in can maintain it, cause I'm looking retirement in the face. That and we need to document an architecture for IEC 62304 compliance. (this is code for a FDA cleared micro-current tens unit). I would have to do extensive editing to the code to embed the comments that doxygen can use to create the documentation correctly. I have yet to get doxygen to do a flow tree, though I have enabled the "dot" stuff and have graphviz in the path. It created flows only for certain structures, and those are really not right. I have two different structures with a common header. I have a structure that just has the common header. So I can tell the compiler to point to the common structure, and information in the common structure area will identify which structure it is, so the run time can know how to handle it. Yes it is weird, but it solved a batch of "incompatible pointer" problems.... What I have been trying to get it to do is something like this -------------[update_parameters] | | | --------[calls function 2] | |____[calls function 2] | |____ [calls function 4] | main- | | ---- [calls button scan] |------[calls function 5] | etc. the editor I use Source Insight (one of the best editors on the planet in my opinion) will do this, but you have to save screen shots. and by the way, it has a free trial. This feature is the relationship window. You can have multiple windows, each with a different relationship and when you click on a symbol in the code, it will generate a nice graphic for you. Quite impressive. I am aware that *IF* you have the right headers, Doxygen can do this and a whole lot more. >-- >Richard Damon |
From: Ron W <ron...@gm...> - 2015-06-29 19:50:58
|
On Mon, Jun 29, 2015 at 10:58 AM, woody <kn...@re...> wrote: > > It *has* to have the information though, whether or not it organizes it. > When it scan a program, indentifies a symbol, it reports which line the > symbol is defined on. It could and should > also have an option to report ALL the lines. > Doxygen might only save the names of functions where each variable and function are referenced, but not the line numbers. The HTML source listings Doxygen can generate contain algorithmically generated anchors to serve as target for links from the generated documentation, so line numbers are not needed. Certainly would be good if it could produce a cross-reference with line numbers. Well, consider the issue raised :D . It just seems obvious. > I'm just a user of Doxygen. > Even after comments blocks are automatically inserted, I would think you > will still have to do extensive editing to include descriptive prose. > > > You might, but they would just be padding on existing lines more or less. > So yes, but it is a lot easier and quicker to go into the code and add the > comments or descriptive prose to an > existing comment block. 1. You don't have to remember how to create the > block. 2. with the blocks in place, documentation would certainly be > easier. > My team and I have templates defined in the source code editors we use. When reviewing/studying legacy code, we can insert the relevant temple and fill in the descriptive prose. Or, more often, since what Doxygen needs is so minimal, just type. for example: /** One line description. * More detail.... * @return Description of what's returned. */ or: /**< One line description after a parameter or variable definition. More detail.... */ One of the things coming down in the medical device world, is compliance > with IEC 62304. One part of this requires detailed architectural > descriptions and diagrams. Current code will ultimately > have to be brought up to that standard, and all over the medical world, > people are having to back document programs. > I don't know what requirements IEC 62304 imposes, particularly on "in line" code documentation. Doxygen is meant to make generating a separate document from special comments contained in the code. The (limited) source analysis capability Doxygen has is there to make adding and maintaining those comments easier by allowing the coder/documentor to follow the principle of "Do Not Repeat Yourself". Feeding the output of Doxygen back in to the source files is possible. Most probably something to be done using a post processor. > I have attached a file, and hope it comes through. > > current_intensity is the variable. This shows that build_array uses it, > as do a bunch of the routines that build array calls. > There are many other places in the code where this variable are referenced. > Right now, Doxygen can produce a call graph similar to what your charts shows in relation to "build_array" and what it calls. Enhancing Doxygen to product a (textural) cross-reference should not be hard. However, I can't speak to the internals of Doxygen. The chart you produced with Source Insight is a hybrid of a call graph and a graphical cross-reference. That is most likely best implemented as a post processor. > Doxygen has the info to do this, or would with an extension. I was hoping > that graphvis would be able to take Doxygen's data > and produce this kind of diagram automatically for each function, > variable, and data structure. > With a cross-reference and the output Doxygen currently produces, post processing should be able to produce most kinds of (code) relationship diagrams. Flow diagrams would require help from additional analysis tools. Unfortunately, all such tools I know of that provide the kind of sophisticated analysis that Source Insight does are expensive, proprietary tools that work much like you describe Source Insight, unless you add expensive, optional reporting extensions. Graphvis is just a tool for interpreting description in DOT notation in to graphical charts. It has no analysis capability. Doxygen uses it because it was much easier to use it than to attempt to produce such diagrams directly. |
From: woody <kn...@re...> - 2015-06-29 20:32:32
|
>Doxygen might only save the names of functions where each variable and >function are referenced, but not the line numbers. The html documentation has the line numbers, as does the rtf file, so obviously it is tracking at some level. I see that the call graphs are interspersed through the rtf file, but they are not really grouped into a coherent structure. And I never found them at all in the html generated stuff. ::#define CONTROL_TABLE 1 Definition at line 388 of file medbest_310_o_split.c. ::void adc_window_complete () Definition at line 5983 of file medbest_310_o_split.c. 5984 { 5985 } ::void adc_window_interrupt () Definition at line 5970 of file medbest_310_o_split.c. 5971 { 5972 } ::data char beep_count Definition at line 1052 of file medbest_310_o_split.c. ::data int beep_duration Definition at line 1053 of file medbest_310_o_split.c. And the .rtf file lists the code for each function. >The HTML source listings Doxygen can generate contain algorithmically >generated anchors to serve as target for links from the generated >documentation, so line numbers are not needed. > >Certainly would be good if it could produce a cross-reference with line >numbers. >Well, consider the issue raised :D . It just seems obvious. > > >I'm just a user of Doxygen. I wonder if Dimitri monitors this list.... >>Even after comments blocks are automatically inserted, I would think you >>will still have to do extensive editing to include descriptive prose. >You might, but they would just be padding on existing lines more or >less. So yes, but it is a lot easier and quicker to go into the code and >add the comments or descriptive prose to an >existing comment block.  1. You don't have to remember how to create >the block.  2. with the blocks in place, documentation would certainly >be easier. > > >My team and I have templates defined in the source code editors we use. >When reviewing/studying legacy code, we can insert the relevant temple and >fill in the descriptive prose. Or, more often, since what Doxygen needs is >so minimal, just type. for example: > /** One line description. > * More detail.... > * @return Description of what's returned. > */ >or: > /**< One line description after a parameter or variable definition. More > detail.... */ There is the @brief and a ton more. >One of the things coming down in the medical device world, is compliance >with IEC 62304. One part of this requires detailed >architectural descriptions and diagrams. Current code will ultimately >have to be brought up to that standard, and all over the medical world, >people are having to back document programs. > > >I don't know what requirements IEC 62304 imposes, particularly on "in >line" code documentation. It is a very long discussion :( But essentially it means for class A and B, you have to document each software item, and create architectural documents, etc. For class C (stuff that can kill you) it gets really detailed, with having to document all boundry conditions code flow and on and on... part of the checklist B and C are classes. [B, C] The manufacturer transformed the requirements for the medical device software into a documented architecture that describes the softwares structure and identifies the software items [B, C] The manufacturer developed and documented an architecture for the interfaces between the software items and the components external to the software items (both software and hardware), and between the software items [B, C] If a software item is identified as soup, the manufacturer specified functional and performance requirements for the soup item that are necessary for its intended use [B, C] If a software item is identified as soup, the manufacturer specified the system hardware and software necessary to support the proper operation of the soup item [C] The manufacturer identified the segregation between software items that is essential to risk control, and state how to ensure that the segregation is effective [B, C] The manufacturer verified and document that: a) the architecture of the software implements system and software requirements including those relating to risk control b) the software architecture is able to support interfaces between software items and between software items and hardware c) the medical device architecture supports proper operation of any soup items [B, C] The manufacturer refined the software architecture until it is represented by software units [C] The manufacturer developed and documented a detailed design for each software unit of the software item >Feeding the output of Doxygen back in to the source files is possible. >Most probably something to be done using a post processor. > >I have attached a file, and hope it comes through. > >current_intensity is the variable. This shows that build_array uses it, >as do a bunch of the routines that build array calls. >There are many other places in the code where this variable are referenced. > > >Right now, Doxygen can produce a call graph similar to what your charts >shows in relation to "build_array" and what it calls. > >Enhancing Doxygen to product a (textural) cross-reference should not be >hard. However, I can't speak to the internals of Doxygen. > >The chart you produced with Source Insight is a hybrid of a call graph and >a graphical cross-reference. That is most likely best implemented as a >post processor. Probably. You can turn off the cross reference, in which case it is a call graph. > >Doxygen has the info to do this, or would with an extension. I was >hoping that graphvis would be able to take Doxygen's data >and produce this kind of diagram automatically for each function, >variable, and data structure. > > >With a cross-reference and the output Doxygen currently produces, post >processing should be able to produce most kinds of (code) relationship >diagrams. >Flow diagrams would require help from additional analysis tools. >Unfortunately, all such tools I know of that provide the kind of >sophisticated analysis that Source Insight does are expensive, proprietary >tools that work much like you describe Source Insight, unless you add >expensive, optional reporting extensions. Well source insight isn't exactly cheap, around 239.00 or so. But it isn't a flow analysis tool per se. http://www.sourceinsight.com/eval.html you can download a 30 day trial, and there are keys on the net. I was one of Ray Grahms early beta testers. It is one of the coolest editors ever, with full syntax coloring and parsing for literally dozens of languages, and a fully documented api that you can extend. an more nifty features than you can shake a stick at. >Graphvis is just a tool for interpreting description in DOT notation in to >graphical charts. It has no analysis capability. Doxygen uses it because >it was much easier to use it than to attempt to produce such diagrams directly. |
From: Ron W <ron...@gm...> - 2015-06-29 22:49:51
|
On Mon, Jun 29, 2015 at 4:32 PM, woody <kn...@re...> wrote: > The html documentation has the line numbers, as does the rtf file, so > obviously it is tracking at some level. > > I see that the call graphs are interspersed through the rtf file, but they > are not really grouped into a coherent structure. > And I never found them at all in the html generated stuff. > > > *::#define CONTROL_TABLE 1 *Definition at line 388 of file > medbest_310_o_split.c. > > *::void adc_window_complete ()* I meant for the references. I know it records the line numbers of the definitions. > > There is the @brief and a ton more. > We use "AUTO_BRIEF" in our Doxygen configuration so we rarely need @brief or @details. Besides @return, we use @f$, @f[ and @f] (for formulae), @note, @internal/@endinternal, @ref, @see, @page, @section, @test, @todo, and a few custom directives.* But, most of the time, we only need descriptive prose. > I don't know what requirements IEC 62304 imposes, particularly on "in > line" code documentation. > > > It is a very long discussion > Looks very similar to ISO-26262. Doxygen helps us here because we can define the interfaces directly at the code level and generate an interface document from that. Otherwise, Doxygen's strength is in generating low level documentation. Higher level documentation, we use Dia to create diagrams and charts and Libre Office to write prose. * Our custom Doxygen directives include @req (for denoting requirements (by ReqID)), @range (for annotating limits and constraints) and @issue (for annotating code changes made per issue tracking). |
From: Ron W <ron...@gm...> - 2015-06-30 16:59:41
|
On Tue, Jun 30, 2015 at 9:51 AM, woody <kn...@re...> wrote: > > How do you create the custom directives? > See: http://www.stack.nl/~dimitri/doxygen/manual/custcmd.html "@req" is just a short hand for "@par Requirements". "@range" is defined as: ALIASES += range{1}="@par Range @f[ @1 @f]" "@issue" works like "@todo" and is defined as: ALIASES += issue="\xrefitem issues,\"Issue\",\"Issues Addressed\"" |