Documentation: Difference between revisions
(omit m4) |
(add J) |
||
Line 1: | Line 1: | ||
{{task|Software Engineering}}Show how to insert documentation for classes, functions, and/or variables in your language. If this documentation is built-in to the language, note it. If this documentation requires external tools, note them. |
{{task|Software Engineering}}Show how to insert documentation for classes, functions, and/or variables in your language. If this documentation is built-in to the language, note it. If this documentation requires external tools, note them. |
||
=={{header|J}}== |
|||
Use [http://www.jsoftware.com/trac/base/browser/trunk/main/script/doc.ijs?rev=1 scripdoc]: |
|||
NB. ========================================================= |
|||
NB.*apply v apply verb x to y |
|||
apply=: 128!:2 |
|||
NB. ========================================================= |
|||
NB.*def c : (explicit definition) |
|||
def=: : |
|||
NB.*define a : 0 (explicit definition script form) |
|||
define=: : 0 |
|||
NB.*do v name for ". |
|||
do=: ". |
|||
NB.*drop v name for }. |
|||
drop=: }. |
|||
=={{header|Java}}== |
=={{header|Java}}== |
Revision as of 18:48, 8 September 2009
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Show how to insert documentation for classes, functions, and/or variables in your language. If this documentation is built-in to the language, note it. If this documentation requires external tools, note them.
J
Use scripdoc:
NB. ========================================================= NB.*apply v apply verb x to y apply=: 128!:2 NB. ========================================================= NB.*def c : (explicit definition) def=: : NB.*define a : 0 (explicit definition script form) define=: : 0 NB.*do v name for ". do=: ". NB.*drop v name for }. drop=: }.
Java
Documentation is typically given using Javadoc comments. Documentation is generated from these comments using the Javadoc tool. It takes the form of an HTML page with frames, so HTML is frequently embedded in the comments. The comments all start with /**
, end with */
, and usually have "tags" embedded starting with @
.
<lang java>/**
* This is a class documentation comment. This text shows at the top of the page for this class * @author Joe Schmoe */
public class Doc{
/** * This is a field comment for a variable */ private String field;
/** * This is a method comment. It has parameter tags (param), an exception tag (throws), * and a return value tag (return). * * @param num a number with the variable name "num" * @throws BadException when something bad happens * @return another number */ public int method(long num) throws BadException{ //...code here }
}</lang>
Tcl
Documentation for Tcl code is usually prepared in separate files using a tool like doctools, but inline docs (with all their inherent limitations) can be done with the likes of Robodoc. For example: <lang tcl>#****f* RosettaCode/TclDocDemo
- FUNCTION
- TclDocDemo is a simple illustration of how to do documentation
- of Tcl code using Robodoc.
- SYNOPSYS
- TclDocDemo foo bar
- INPUTS
- foo -- the first part of the message to print
- bar -- the last part of the message to print
- RESULT
- No result
- NOTES
- Prints a message based on a template by filling in with the
- supplied strings.
proc TclDocDemo {foo bar} {
puts [format "%s -- %s" $foo $bar]
}</lang> Both doctools and robodoc can produce output in multiple formats.