Documentation Team/API Documentation: Difference between revisions
m editing Writing APIDOX in New Code |
m categorize |
||
| (6 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
<noinclude>[[Category:API]] | |||
[[Category:Documentation]] | |||
</noinclude>{{draft}} | |||
== Definition == | == Definition == | ||
| Line 126: | Line 129: | ||
//DOXYGEN_EXCLUDE | //DOXYGEN_EXCLUDE | ||
</code> | </code> | ||
*Every module should have a module comment. | *Every module should have a module comment. | ||
| Line 138: | Line 140: | ||
</code> | </code> | ||
*Every class should have a comment. Classes are the important building blocks of your application or library, so this is one place where writing lots helps. Write down why the class exists. Write down what it is supposed to do. Give an example of how to use it. Explain how not to use it, or what prerequisites it has (for instance, lots of classes need a KInstance object, but don't document that explicitly).<br />The same caveats apply as with namespace apidox: make sure the class follows its apidox immediately. | |||
*Every method should have a comment explaining what it does and what the parameters are for. Method parameters should be documented using @param. Don't rely on the name of the method or the parameters to be fully self-documenting. Besides, writing these things down properly will trigger Doxygen errors if you change them in an incompatible way later -- and that is going to save you lots of time in finding source and binary incompatibilities and explaining to users why their code suddenly doesn't do what they expect (assuming it compiles at all). So good method apidox is an additional insurance against making bad changes. Same caveats apply. | |||
'''3. Watch this space!''' | '''3. Watch this space!''' | ||
| Line 171: | Line 151: | ||
'''4. Write a main page for your application.''' | '''4. Write a main page for your application.''' | ||
This is usually done in a separate file | This is usually done in a separate file in the top-level of a library or application. The file's content is just a single apidox comment that starts with /** @mainpage title ; the rest of the file is just a long comment about what the library or application is for. | ||
== Fixing APIDOX in Old Code == | == Fixing APIDOX in Old Code == | ||
| Line 402: | Line 382: | ||
Very useful, in fact, for the reader who is wondering | Very useful, in fact, for the reader who is wondering | ||
how exactly to use the class in a straightforward way. | how exactly to use the class in a straightforward way. | ||
Most classes | Most classes have example code. | ||
One way to write example code is to use @code and @endcode around | One way to write example code is to use @code and @endcode around | ||
| Line 418: | Line 398: | ||
</code> | </code> | ||
This is how most of the examples | This is how most of the examples | ||
are done, actually. It works reasonably well, you can pare the | are done, actually. It works reasonably well, you can pare the | ||
example down to something really minimal and leave out all the | example down to something really minimal and leave out all the | ||
| Line 447: | Line 427: | ||
:This is a list of all available documentation tags of doxygen, from the official site. Note that the list uses a backslash in front of a tag, while this page always used the at sign. Both are allowed, but for KDE you should use the at sign to stay consistent within KDE. | :This is a list of all available documentation tags of doxygen, from the official site. Note that the list uses a backslash in front of a tag, while this page always used the at sign. Both are allowed, but for KDE you should use the at sign to stay consistent within KDE. | ||
--> | --> | ||