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