]> jfr.im git - irc/quakenet/snircd.git/blame - doc/api/api.txt
Update my e-mail address.
[irc/quakenet/snircd.git] / doc / api / api.txt
CommitLineData
189935b1 1This directory is intended for documents describing programming
2interfaces within ircu, including such things as modebuf's and the
3features interface. Please write these documents as plain text; if we
4want HTML, we can write a script to convert the text versions into
5HTML versions. Toward that end, I respectfully suggest everyone
6conform to a common format, which I will describe here:
7
8Every .txt file should begin with a couple of paragraphs giving an
9overview of the API, its purpose, and how to use it. Paragraphs
10should be separated by blank lines, as shown here. Paragraphs that do
11not end in some form of punctuation, such as a period, will be treated
12as section headings. The introduction ends when the first API element
13appears. API element documentation is introduced with "<" followed by
14the element type--"struct", "typedef", "function", "macro", or (heaven
15forbid) "global", followed by ">", all on a line by itself. The next
16line should contain a declaration of the element as it would appear in
17a header file; this may spread across multiple lines and contain
18comments and blank lines. The declaration ends for most elements when
19a ";" is encountered; for macros, the declaration ends on the last
20line not ending in "\".
21
22The documentation for the API element should immediately follow the
23declaration of that element, and should be separated from it by a
24single blank line. This documentation should explain the purpose of
25the element and describe what each of its fields mean. The
26documentation ends when the corresponding "</" tag is reached, just as
27in HTML or XML. (I don't intend for the files to be either HTML or
28XML, I just want them to be easy to parse so they could be turned into
29either, as occasion warrants.) An example follows:
30
31<struct>
32struct FooBar; /* a sample structure with no definition */
33
34The comment, since it's on the same line as the ";", is associated
35with the declaration for struct FooBar.
36</struct>
37
38<struct>
39struct FooBar {
40 long fb_magic; /* a magic number */
41 char *fb_string; /* a string of some sort */
42};
43
44The sequence "};" ends the struct declaration.
45</struct>
46
47<typedef>
48typedef FooBar_t; /* a simple typedef */
49
50This element shows how to hide the inner workings of typedefs.
51</typedef>
52
53<typedef>
54typedef struct FooBar FooBar_t; /* a more complex typedef */
55
56Here we show the full typedef declaration.
57</typedef>
58
59<global>
60extern int fooBarFreeList; /* global variables should be avoided */
61
62You should avoid global variables, but if you must have one for alloc
63counts or whatever, here's how to specify documentation for them.
64</global>
65
66<macro>
67#define HAVE_FOOBAR /* We have FOOBAR, whatever it may be */
68
69This could be used for boolean macros (macros used in #ifdef's, for
70instance) or for simple value macros where you're hiding the values.
71Since there are so many variations on macros, I'll only show one other
72variation below:
73</macro>
74
75<macro>
76#define FooBarVerify(foobar) ((foobar) && \
77 (foobar)->fb_magic == FOOBAR_STRUCT_MAGIC)
78
79This macro takes arguments. Again, we could leave out the actual
80definition, or even treat the macro as a function rather than a
81macro. This also shows how to do multi-line macros.
82</macro>
83
84<function>
85void *foobar(struct FooBar *blah, int flag);
86
87Since function definitions never appear in header files anyway, we
88don't have to worry about hiding information. You should leave off
89"extern" in the function declaration, and please include names for the
90variables, so you can refer to them in the function documentation.
91</function>
92
93The API document may then end in some summary information, if you
94wish, or a ChangeLog of some form, such as follows.
95
96<authors>
97Kev <klmitch@mit.edu>
98</authors>
99
100<changelog>
101[2000-12-18 Kev] Initial definition of how API documents should look.
102Further entries in the changelog should *precede* this one and should
103be separated from it by a blank line. Also specify your name, as
104listed in the "<authors>" section, so we know who to blame ;)
105</changelog>