how to write Click element documentation
Documentation for a Click element is automatically generated from formatted comments in its header files. This manual page describes how to write one of these formatted comments.
Click element documentation syntax is based on Perl-style PODs; see perlpod(1) for more information. However, not all POD constructs are usable in element documentation at the moment; and Click element documentation is line-oriented, not paragraph-oriented.
These are the sectioning commands and the sections they correspond to, listed in the conventional order.
- =s category
- NAME (one-line summary)
- INPUTS AND OUTPUTS
- PROCESSING TYPE
- =h name type
- ELEMENT HANDLERS
- SEE ALSO
- =head1 text
- other heading
These are the other commands used in element documentation.
- =head2 text
- =over amount
- begin item list
- =item text
- add item
- end item list
- =for format
- selective formatting
- =begin format
- selective formatting
- =end format
- selective formatting
- =deprecated new-element
- element is deprecated
These are the formatting commands, used inside ordinary text.
- underlined (if possible)
- plain text (i.e., no automatic links)
- code (fixed-width)
- filename (italics)
- line break
- hide text
And these are the category keywords, used in the summary section to categorize elements.
- Basic Sources and Sinks
- Basic Classification and Selection
- Basic Packet Transfer
- Basic Packet Modification
- Packet Storage
- Active Queue Management
- Packet Scheduling
- Traffic Shaping
- Information Elements
- Network Devices
- Host and Socket Communication
- IPv4 Routing
- Network Address Translation
- Trace Manipulation
- TCP/IP Measurement
- Paint Annotations
- Multithreaded Click
- Regression Tests
Each piece of documentation is stored in a single block comment ‘/*...*/’. Two kinds of block comment are recognized:
/* =c ElementName(...) ... and so on ... */ /* * =c * ElementName(...) * ... and so on ... */
In the first form, commands and normal text MUST begin in the first column of each line. In the second form, commands and normal text MUST begin in the fourth column of each line, immediately following the initial star and spaces ‘ * ’. Indented lines are treated as verbatim text, as in POD.
Commands are lines that begin with ‘=’ and a lower-case letter. There are two kinds of commands, those that start new sections and those that occur within sections. There is also a set of formatting commands—for turning text bold, for example—that occurs inside normal text; they are described in the next section.
=s storage stores packets in a FIFO queueThe summary text should generally be a verb phrase.
The optional category specifies one or more element categories into which this element fits, separated by commas. Specifying meaningful categories helps a lot; documentation tools use categories to divide elements into manageable groups. Use existing categories, defined by the list of category keywords above in the Command Quick Reference, or create your own.
The =c section gives the element’s name and any of its configuration arguments. For example:
=c IPEncap(PROTOCOL, SADDR, DADDR)
Configuration arguments should be specified as all-upper-case words. The description section will use those upper-case words to talk about the arguments. Use brackets to show that an argument is optional:
=c UDPIPEncap(SADDR, SPORT, DADDR, DPORT [, CHECKSUM?])
Do not use anything more complicated than brackets. If an element has complex syntax, either use upper-case words and talk about the syntax more in the description section, or give multiple lines:
=c ControlSocket(tcp, PORTNUMBER [, READONLY?]) ControlSocket(unix, PORTNUMBER [, READONLY?])(‘tcp’ and ‘unix’ are lowercase because they should be typed verbatim.)
=io NoneThis section is optional, and most elements don’t bother to have one; they mention inputs and outputs in the description section.
=processing Push inputs, pull outputsThis section is optional. Documentation processing tools will generate a =processing section from the element’s processing() method, if possible.
=h capacity read/write Returns or sets the queue's capacity.
=a RED, FrontDropQueueThe optional text is just part of the body of the section.
The references in this section should be either manual page references, like ‘tcpdump(1)’, or text references, like ‘RFC 959: File Transfer Protocol’. However, the first paragraph in the section is special; there, you can just give element names without ‘(n)’ suffixes.
If one of these references occurs in some other section, it will be formatted like a link. For example, in
=d This element is like Queue. =a Queuethe mention of ‘Queue’ in the description section will be formatted like a link.
=for html <p>Here is a pretty picture: <img src="pretty.gif"></p> Back to B<normal text> here.
Each line that doesn’t begin with ‘=’ and a lower-case letter is treated as text. (Unless it starts with a space or tab; see verbatim text, below.) This text is formatted nicely, and perhaps even justified. You can use several formatting commands inside normal text; they consist of an uppercase letter, followed by ‘<’, some text, and ‘>’. The commands are:
Lines that start with a space or tab character are printed out verbatim—that is, without any changes, and with the line breaks and indentation you specified. You can’t use formatting commands in verbatim text. Verbatim text is useful for showing example code; for example:
This code q :: Queue; ... -> RED(5, 50, 0.02) -> q -> ... adds RED dropping to q.
/* =c * Align(MODULUS, OFFSET) * =s modification * aligns packet data * =d * Aligns packet data. Each input packet is aligned so that * its first byte is OFFSET bytes off from a MODULUS-byte * boundary. This may involve a packet copy. * * MODULUS I<must> be 2, 4, or 8. * =n * The click-align(1) tool will insert this element * automatically wherever it is required. * =e * ... -> Align(4, 0) -> ... * =a AlignmentInfo, click-align(1) */
/* =c * Counter([TYPE]) * =s measurement * measures packet count and rate * =d * Passes packets unchanged from its input to its output, * maintaining statistics information about packet count and * rate if TYPE is "packets", or byte count and byte rate if * TYPE is "bytes". The default TYPE is "packets". * =h count read-only * Returns the number of packets/bytes that have passed through. * =h rate read-only * Returns the recent arrival rate (measured by exponential * weighted moving average) in packets/bytes per second. * =h reset write-only * Resets the count and rate to zero. */
perlpod(1), click(1), click(5)
Eddie Kohler, [email protected]
Robert Morris, [email protected]