Debian Codegraph @

geanygendoc/docs/manual.rst

raw
1 =======================
2 GeanyGenDoc User Manual
3 =======================
4 -------------------------------------------------
5 A handy hand guide for the lazy documenter in you
6 -------------------------------------------------
7
8
9 Introduction
10 ============
11
12 First of all, welcome to this manual. Then, what is GeanyGenDoc? It is a
13 plug-in for Geany as you might have noticed; but what is it meant to do?
14 Basically, it generates and inserts text chunks, particularly from document's
15 symbols. Its goal is to ease writing documentation for the good.
16
17 If you are impatient, you will probably want to discover the `user interface in
18 Geany`_ first; but if you have the time to discover the tool, take a look at the
19 `design`_ and learn how GeanyGenDoc works and how you can make the most of it.
20
21
22 .. contents::
23
24
25 User interface in Geany
26 =======================
27
28 Menus
29 -----
30
31 GeanyGenDoc adds an item named `Insert Documentation Comment` in the editor's
32 pop-up under the `Insert Comments` sub-menu; and a menu named
33 `Documentation Generator` into the `Tools` menu.
34
35 Editor's pop-up menu
36 ~~~~~~~~~~~~~~~~~~~~
37
38 The item `Editor's pop-up → Insert Comments → Insert Documentation Comment`
39 generates documentation for the current symbol. It has a keyboard shortcut
40 that can be configured through Geany's keybinding configuration system, under
41 `GeanyGenDoc → Insert Documentation Comment`.
42
43 Tools menu
44 ~~~~~~~~~~
45
46 The `Documentation Generator` menu under `Tools` contains the following items:
47
48 `Document Current Symbol`
49 This generates documentation for the current symbol. It is equivalent to the
50 item `Insert Documentation Comment` that can be found in the editor's pop-up
51 menu.
52
53 `Document All Symbols`
54 This generates documentation for all symbols in the document. This is
55 equivalent to manually requesting documentation generation for each symbol in
56 the document.
57
58 `Reload Configuration Files`
59 This force reloading of all the `file type`_ configuration files. It is
60 useful when a file type configuration file was modified, in order to the new
61 configuration to be used without reloading the plugin.
62
63 `Edit Current Language Configuration`
64 This opens the configuration file that applies to the current document for
65 editing. The opened configuration file has write permissions: if it was a
66 system configuration file it is copied under your personal `configuration
67 directory`_ transparently.
68
69 `Open Manual`
70 Opens this manual in a browser.
71
72
73 Preferences dialog
74 ------------------
75
76 The preferences dialog, that can either be opened through `Edit →
77 Plugin Preferences` or with the `Preferences` button in the plugin manager,
78 allows to modify the following preferences:
79
80 `General`
81 `Save file before generating documentation`
82 Choose whether the current document should be saved to disc before
83 generating the documentation. This is a technical detail, but it is
84 currently needed to have an up-to-date tag list. If you disable this option
85 and ask for documentation generation on a modified document, the behavior
86 may be surprising since the comment will be generated for the last saved
87 state of the document and not the current one.
88
89 `Indent inserted documentation`
90 Chooses whether the inserted documentation should be indented to fit the
91 indentation at the insertion position.
92
93 `Documentation type`
94 This list allows you to choose the documentation type to use with each file
95 type. The special language `All` on top of the list is used to choose the
96 default documentation type, used for all languages that haven't one set.
97
98 `Global environment`
99 Global environment overrides and additions. This is an environment that will
100 be merged with the `file type`_-specific ones, possibly overriding some parts.
101 It can be used to define some values for all the file types, such as whether
102 to write the common `Since` tag, define the `Doxygen`_ prefix an so on.
103 Its most practical use case is not to need to change a file type's environment
104 to change the value of one of its elements.
105
106
107 Design
108 ======
109
110 GeanyGenDoc has an extensible design based on three points: file type,
111 documentation type and rules.
112
113 `File type`_
114 The file type determines which configuration applies to which document. For
115 example, the "c" file type corresponds to C source, and so on.
116
117 `Documentation type`_
118 A documentation type is an arbitrary name for a set of rules. The goal of
119 documentation types is to allow different set of rules to be defined for each
120 file type.
121 One might want to have separate rules to generate for example `Doxygen`_
122 and `Gtk-Doc`_ documentation from C sources, and should then create two
123 documentation types in the C `file type configuration file`_, such as
124 "doxygen" and "gtkdoc".
125
126 `Rule`_
127 A rule is a group of settings controlling how a documentation comment is
128 generated. For example, it can define a template, describe how to handle
129 particular imbrications and so on.
130
131
132 Syntax
133 ======
134
135 Key-Value pairs
136 ---------------
137
138 The syntax used by the configuration files is an extended key-value tree
139 definition based on common concepts (trees, string literals, semicolon-ended
140 values, etc.).
141
142 The key-value syntax is as follows::
143
144 key = value
145
146 where value is either a semicolon-ended single value::
147
148 value;
149
150 or a brace-surrounded list of key-value pairs that use the same syntax again::
151
152 {
153 key1 = value1
154 key2 = value2
155 }
156
157 Here a little example of the *syntax* (not any actual configuration example)::
158
159 key1 = value1;
160 key2 = {
161 sub-key1 = sub-value1;
162 sub-key2 = {
163 sub-sub-key1 = sub-sub-value1;
164 }
165 }
166
167
168 Naming
169 ------
170
171 Key-value pairs are often referred as *group* when they are meant to have
172 multiple values and as *setting* when they have a single value.
173
174
175 Comments
176 --------
177
178 Is considered as comment (and therefore ignored) everything between a number
179 sign (``#``) and the following end of line, unless the ``#`` occurs as part of
180 another syntactic element (such as a string literal).
181
182 A short example::
183
184 # This is a comment
185 key = value; # This is also a comment
186 string = "A string. # This isn't a comment but a string";
187
188
189 Value types
190 -----------
191
192 string
193 A string literal. String literals are surrounded by either single (``'``) or
194 double (``"``) quotes.
195
196 Some special characters can be inserted in a string with an escape sequence:
197
198 ``\t``
199 A tabulation.
200 ``\n``
201 A new line.
202 ``\r``
203 A carriage return.
204 ``\\``
205 A backslash.
206 ``\'``
207 A single quote (escaping only needed in single-quotes surrounded strings).
208 ``\"``
209 A double quote (escaping only needed in double-quotes surrounded strings).
210
211 Note that backslashes are used as the escaping character, which means that it
212 must be escaped to be treated as a simple backslash character.
213
214 A simple example::
215
216 "This is a string with \"special\" characters.\nThis is another line!"
217
218 boolean
219 A boolean. It can take one of the two symbolic values ``True`` and ``False``.
220
221 enumeration
222 An enumeration. It consists of a named constant, generally in capital letters.
223 The possible values depend on the setting using this type.
224
225 flags
226 A logical OR of named constants. This is similar to enumerations but can
227 combine different values.
228
229 The syntax is common for such types and uses the pipe (``|``) as
230 combination character. Considering the ``A``, ``B`` and ``C`` constants, a
231 valid value could be ``A | C``, which represents both ``A`` and ``C`` but
232 not ``B``.
233
234 list
235 A list of values (often referred as array).
236
237
238 File types
239 ==========
240
241 The file type determines which configuration applies to which document.
242 *File type identifiers* are the lowercased name of Geany's file type, for
243 example "c" or "python".
244
245 Configuration for a particular file type goes in a file named
246 ``file-type-identifier.conf`` in the ``filetypes`` sub-directory of a
247 `configuration directory`_.
248
249 A file type configuration can contain two type of things: file-type-wide
250 settings and any number of `documentation types`_.
251
252
253 The ``settings`` group
254 ----------------------
255
256 This group contains the file-type-wide settings.
257
258 ``match_function_arguments`` (string)
259 A regular expression used to extract arguments from a function-style argument
260 list (functions, methods, macros, etc.). This regular expression should match
261 one argument at a time and capture only the argument's name.
262 This setting is a little odd but currently required to extract argument list
263 from function declarations.
264
265 ``global_environment`` (string)
266 A description of a CTPL_ environment to add when parsing rule_'s templates.
267
268
269 The ``doctypes`` group
270 ----------------------
271
272 This group contains a list of `documentation types`_.
273
274
275 Documentation types
276 ===================
277
278 A documentation type is a named set of rules_ for a `file type`_, describing how
279 to generate a particular type of documentation (i.e. Doxygen_, `Gtk-Doc`_,
280 Valadoc_ or whatever).
281
282 A documentation type is identified by its name and must therefore be unique
283 in a file type. But of course, different file types can define the same
284 documentation type. It is even recommended for a better consistency to use the
285 same identifier in different file types when they generate the same type of
286 documentation (even though it is completely up to you).
287
288
289 Short example
290 -------------
291
292 ::
293
294 doxygen = {
295 struct.member = {
296 template = " /**< {cursor} */";
297 position = AFTER;
298 }
299 struct.template = "/**\n * @brief: {cursor}\n * \n * \n */\n";
300 }
301
302
303 Rules: the cool thing
304 =====================
305
306 Rules are the actual definition of how documentation is generated. A rule
307 applies to a symbol type and hierarchy, allowing fine control over which and
308 how symbols are documented.
309
310 A rule is represented as a group of `settings`_ in a `documentation type`_.
311 The name of this group is the `type hierarchy`_ to which the settings applies.
312
313
314 Type hierarchy
315 --------------
316
317 A type hierarchy is a hierarchy of the types that a symbol must have to match
318 this rule.
319
320 In the symbol side, the type hierarchy is the types of the symbol's parents,
321 terminated by the symbol's own type. For example, a method in a class would
322 have a hierarchy like ``class -> method``; and if the class is itself in a
323 namespace, the hierarchy would the look like ``namespace -> class -> method``,
324 and so on.
325
326 For a rule to apply, its type hierarchy must match *the end* of the symbol
327 type hierarchy. For example a rule with the type hierarchy ``class`` will match
328 a symbol with the type hierarchy ``namespace -> class`` but not one with
329 ``class -> method``.
330
331 A type hierarchy uses dots (``.``) to separate types and build the hierarchy.
332 For example, the type hierarchy representing ``namespace -> class`` would be
333 written ``namespace.class``.
334
335
336 Known types
337 ~~~~~~~~~~~
338
339 ``class``
340 A class.
341 ``enum``
342 An enumeration.
343 ``enumval``
344 An enumeration value.
345 ``field``
346 A field (of a class for example).
347 ``function``
348 A function.
349 ``include``
350 An include directive.
351 ``interface``
352 An interface.
353 ``local``
354 A local variable.
355 ``member``
356 A member (of a structure for example).
357 ``method``
358 A method.
359 ``namespace``
360 A namespace.
361 ``other``
362 A non-specific type that highly depend on the language.
363 ``package``
364 A package.
365 ``prototype``
366 A prototype.
367 ``struct``
368 A structure.
369 ``typedef``
370 A type alias definition (*typedef* in C).
371 ``union``
372 An union.
373 ``variable``
374 A variable.
375 ``extern``
376 `???`
377 ``define``
378 A definition (like the *define* C preprocessor macro).
379 ``macro``
380 A macro.
381 ``file``
382 A file (will never match).
383
384
385 Rule settings
386 -------------
387
388 ``template`` (string)
389 A CTPL_ template that can include references to the following predefined
390 variables in addition to the file-type-wide and the global environments:
391
392 ``argument_list`` (string list)
393 A list of the arguments of the currently documented symbol.
394
395 ``returns`` (boolean)
396 Indicates whether the currently documented symbol returns a value
397 (makes sense only for symbols that may return a value).
398
399 ``children`` (string list)
400 A list of the current symbol's first-level children. This is only set if
401 the rule's setting ``children`` is set to ``MERGE``.
402
403 ``symbol`` (string)
404 The name of the symbol that is documented.
405
406 **[...]**
407
408 ``cursor`` (special, described below)
409 This can be used to mark in the template the position where the editor's
410 cursor should be moved to after comment insertion.
411 This mark will be removed from the generated documentation.
412 Note that even if this mark may occur as many times as you want in a
413 template, only the first will be actually honored, the latter being
414 only removed.
415
416 ``position`` (enumeration)
417 The position where the documentation should be inserted. Possible values are:
418
419 ``BEFORE`` [default]_
420 Inserts the documentation just before the symbol.
421
422 ``AFTER``
423 Inserts the documentation just after the symbol (currently quite limited, it
424 inserts the documentation at the end of the symbol's first line).
425
426 ``CURSOR``
427 Inserts the documentation at the current cursor position.
428
429 ``policy`` (enumeration)
430 How the symbol is documented. Possible values are:
431
432 ``KEEP`` [default]_
433 The symbol documents itself.
434
435 ``FORWARD``
436 Forward the documentation request to the parent. This is useful for symbols
437 that are documented by their parent, such as `Gtk-Doc`_'s enumerations.
438
439 ``PASS``
440 Completely ignore the symbol and handle the documentation request as if it
441 hasn't existed at all. This can be useful to ignore e.g. variables if they
442 are extracted by the tag parser of the language and you don't want to
443 document them, and don't want them to "eat" the documentation request.
444
445 ``children`` (enumeration)
446 How the symbol's children can be used in the template. Possible values are:
447
448 ``SPLIT`` [default]_
449 The symbol's children are provided as per-type lists.
450
451 ``MERGE``
452 The symbol's children are provided as a single list named ``children``.
453
454 ``matches`` (flags)
455 List of the children types that should be provided. Only useful if the
456 ``children`` setting is set to ``MERGE``.
457 Defaults to all.
458 **FIXME: check the exactitude of this description**
459
460 ``auto_doc_children`` (boolean)
461 Whether to also document symbol's children (according to their own rules).
462
463
464 Miscellaneous
465 =============
466
467 Configuration directories
468 -------------------------
469
470 Configuration directories hold GeanyGenDoc's configuration. They are the
471 following:
472
473 *
474 The user-specific configuration directory, containing the user-defined
475 settings is ``$GEANY_USER_CONFIG/plugins/geanygendoc/``.
476 ``$GEANY_USER_CONFIG`` is generally ``~/.config/geany/`` on UNIX systems.
477 *
478 The system-wide configuration directory containing the default and
479 pre-installed configuration is ``$GEANY_SYS_CONFIG/plugins/geanygendoc/``.
480 ``$GEANY_SYS_CONFIG`` is generally ``/usr/share/geany/`` or
481 ``/usr/local/share/geany`` on UNIX systems.
482
483 When searching for a configuration, GeanyGenDoc will first look in the
484 user's configuration directory, and if it wasn't found there, in the system
485 configuration directory. If both failed, it assumes that there is no
486 configuration at all.
487
488
489 Appendix
490 ========
491
492 License
493 -------
494
495 | GeanyGenDoc, a Geany plugin to ease generation of source code documentation
496 | Copyright (C) 2010-2011 Colomban Wendling <ban(at)herbesfolles(dot)org>
497
498 This program is free software: you can redistribute it and/or modify
499 it under the terms of the GNU General Public License as published by
500 the Free Software Foundation, either version 3 of the License, or
501 (at your option) any later version.
502
503 This program is distributed in the hope that it will be useful,
504 but WITHOUT ANY WARRANTY; without even the implied warranty of
505 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
506 GNU General Public License for more details.
507
508 You should have received a copy of the GNU General Public License
509 along with this program. If not, see <http://www.gnu.org/licenses/>.
510
511
512 Configuration syntax summary
513 ----------------------------
514
515 ::
516
517 string ::= ( """ .* """ | "'" .* "'" )
518 constant ::= [_A-Z][_A-Z0-9]+
519 integer ::= [0-9]+
520 boolean ::= ( "True" | "False" )
521 setting_value ::= ( string | constant | integer )
522 setting ::= "setting-name" "=" setting_value ";"
523 setting_list ::= ( "{" setting* "}" | setting )
524 setting_section ::= "settings" "=" setting_list
525
526 position ::= ( "BEFORE" | "AFTER" | "CURSOR" )
527 policy ::= ( "KEEP" | "FORWARD" | "PASS" )
528 children ::= ( "SPLIT" | "MERGE" )
529 type ::= ( "class" | "enum" | "enumval" | "field" |
530 "function" | "interface" | "member" | "method" |
531 "namespace" | "package" | "prototype" | "struct" |
532 "typedef" | "union" | "variable" | "extern" |
533 "define" | "macro" | "file" )
534 matches ::= type ( "|" type )*
535 doctype_subsetting ::= ( "template" "=" string |
536 "position" "=" position |
537 "policy" "=" policy |
538 "children" "=" children |
539 "matches" "=" matches |
540 "auto_doc_children" "=" boolean ) ";"
541 match ::= type ( "." type )*
542 doctype_setting ::= ( match "=" "{" doctype_subsetting* "}" |
543 match "." doctype_subsetting )
544 doctype_setting_list ::= ( "{" doctype_setting* "}" | doctype_setting )
545 doctype ::= "doctype-name" "=" doctype_setting_list
546 doctype_list ::= ( "{" doctype* "}" | doctype )
547 doctype_section ::= "doctypes" "=" doctype_list
548
549 document ::= ( setting_section? doctype_section? |
550 doctype_section? setting_section? )
551
552
553 .. Content end, begin references
554
555 .. External links
556 ..
557 .. _Doxygen: http://www.doxygen.org
558 .. _Gtk-Doc: http://www.gtk.org/gtk-doc/
559 .. _Valadoc: http://www.valadoc.org/
560 .. _CTPL: http://ctpl.tuxfamily.org/
561
562 .. Internal links
563 ..
564 .. _file type: `File types`_
565 .. _file type configuration file: `File types`_
566 .. _documentation type: `Documentation types`_
567 .. _rule: `Rules: the cool thing`_
568 .. _rules: `Rules: the cool thing`_
569 .. _settings: `Rule settings`_
570 .. _configuration directory: `Configuration directories`_
571
572 -------------------
573
574 .. [default] This is the default value of the setting