Doxyqml, supporting type
Aurélien Gâteau
agateau at kde.org
Mon Oct 22 15:12:21 UTC 2012
Hi,
I have been working a bit more on Doxyqml, the Doxygen input filter for QML
[1]. It now uses a more robust parser, is growing a test-suite and can
override types when needed, allowing you to specify types for function
parameters, return values and properties.
Here is an excerpt of the README:
-----------------------------
## Functions
Functions in QML are untyped, but you can define types in the documentation
like this:
/**
* Create a user
* @param type:string firstname User firstname
* @param type:string lastname User lastname
* @param type:int User age
* @return type:User The User object
*/
function createUser(firstname, lastname, age);
## Properties
QML properties are typed, doxyqml will take advantage of the existing type.
You can nevertheless overwrite the type using the same `type:<name>` syntax.
This is useful for example to document property aliases:
/** type:string The user lastname */
property alias lastname: someObject.text
## Signals
QML signals are typed, so there is no need to use the `type:<name>` syntax to
document their parameters. Using `type:<name>` syntax in signal documentation
will not work: Doxyqml won't strip it out and Doxygen will confuse it with the
parameter name.
/**
* User just logged in
* @param user The user which logged in
*/
signal loggedIn(User user)
-----------------------------
I decided to use a syntax of the form `type:<name>` because it makes it
possible to skip type definition. This is handy for properties, since they
already have type information so specifying a type is not mandatory for them.
I am wondering however if it would be better to simplify the syntax for
functions so that @param and @return expect the first argument to always be a
type, making it possible to write:
@param string lastname User lastname
instead of:
@param type:string lastname User lastname
The plus of this solution is that it is a bit shorter to type (no "type:"
prefix), the minus being that the syntax is a bit inconsistent with properties
documentation (which would still require the "type:" prefix, because type has
to be optional there)
What do you think?
Aurélien
[1]: Available from kde:scratch/gateau/doxyqml
More information about the Plasma-devel
mailing list