Doxygen sees everything as detailed description in C++ project - documentation

I'm trying to setup Doxygen in my Qt C++ project, I documented my methods of each class in the .cpp file as followed:
/**
* #file fragmentsfactory.cpp
* #author Dylan Van Assche
* #date 09 Aug 2018
* #brief Requests a page by URI
* #param const QUrl &uri
* #param QObject *caller
* #package Fragments
* #public
* Starts the generation process of a QRail::Fragments::Page object by
* requesting a page by URI. When the page is ready, the pageReady signal will
* be emitted.
*/
void QRail::Fragments::Factory::getPage(const QUrl &uri, QObject *caller)
{
// Use processing methods to allow other extensions in the future if needed
this->getPageByURIFromNetworkManager(uri);
QUrlQuery query = QUrlQuery(uri);
QDateTime departureTime = QDateTime::fromString(query.queryItemValue("departureTime"), Qt::ISODate);
this->dispatcher()->addTarget(departureTime, caller);
}
When I run Doxygen in the terminal I get a lot of warning about each method. Doxygen doesn't see the comments for each method. It assumes that the comments are part of the description of the whole file.
My DoxyFile: https://gist.github.com/DylanVanAssche/c83c98e73f43cfb466b6d6f45da950f9

Related

Editing fields in Javadoc IntelliJ

I am rather new to java and for one of my assignments am looking into how to add information for the methods in each of my classes. I am using the IntelliJ Idea Editor.
Here is an example of using the JavaDoc.
import java.io.*;
/**
* <h1>Add Two Numbers!</h1>
* The AddNum program implements an application that
* simply adds two given integer numbers and Prints
* the output on the screen.
* <p>
* <b>Note:</b> Giving proper comments in your program makes it more
* user friendly and it is assumed as a high quality code.
*
* #author Zara Ali
* #version 1.0
* #since 2014-03-31
*/
public class AddNum {
/**
* This method is used to add two integers. This is
* a the simplest form of a class method, just to
* show the usage of various javadoc Tags.
* #param numA This is the first paramter to addNum method
* #param numB This is the second parameter to addNum method
* #return int This returns sum of numA and numB.
*/
public int addNum(int numA, int numB) {
return numA + numB;
}
/**
* This is the main method which makes use of addNum method.
* #param args Unused.
* #return Nothing.
* #exception IOException On input error.
* #see IOException
*/
public static void main(String args[]) throws IOException
{
AddNum obj = new AddNum();
int sum = obj.addNum(10, 20);
System.out.println("Sum of 10 and 20 is :" + sum);
}
}
After adding all the information for Documentation in Intellij IDEA go to Tools -> Generate JavaDoc... then specify the Output directory and click OK
Here is more detailed information on how to use Generate JavaDoc Dialog in IDEA - https://www.jetbrains.com/idea/help/generate-javadoc-dialog.html
Also take a look at the Oracle's Style Guide How to Write Doc Comments for the Javadoc Tool - http://www.oracle.com/technetwork/articles/java/index-137868.html
Good luck!

Use of undeclared identifier 'RTLD_SELF'

I have just started iPad programming. I am trying to import an existing project. I am getting the following error, while building through Xcode(4.2): Google didn't help.
/*
* Copyright 2009 Facebook
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "FBLoginButton.h"
#import "FBLoginDialog.h"
#include <dlfcn.h>
///////////////////////////////////////////////////////////////////////////////////////////////////
static UIAccessibilityTraits *traitImage = nil, *traitButton = nil;
#implementation FBLoginButton
#synthesize session = _session, style = _style;
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
+ (void)initialize {
if (self == [FBLoginButton class]) {
// Try to load the accessibility trait values on OS 3.0
traitImage = dlsym(RTLD_SELF, "UIAccessibilityTraitImage");
traitButton = dlsym(RTLD_SELF, "UIAccessibilityTraitButton");
}
}
Both errors were fixed by enclosing the the method in:
#ifdef RTLD_SELF
//initialize method
#endif
Got hint from http://opensource.apple.com/source/dyld/dyld-45.1/unit-tests/test-cases/dlsym-RTLD_SELF/main.c?txt

Check for project errors before performing action

I have an eclipse plug-in which provides a menu item which can be selected to run a command on the currently active file. I would like the plug-in to display a warning message if the currently active file has any errors on it (as reported in the Problems view), similar to how Eclipse acts when you try to run a java project with errors.
I know it's an old question, but I found a solution similar to the one proposed. The code that does what you descrive is in org.eclipse.debug.core.model.LaunchConfigurationDelegate. It checks if the project has errors and show the dialog if needed. Here is the relevant code, from Eclipse Luna:
/**
* Returns whether the given project contains any problem markers of the
* specified severity.
*
* #param proj the project to search
* #return whether the given project contains any problems that should
* stop it from launching
* #throws CoreException if an error occurs while searching for
* problem markers
*/
protected boolean existsProblems(IProject proj) throws CoreException {
IMarker[] markers = proj.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
if (markers.length > 0) {
for (int i = 0; i < markers.length; i++) {
if (isLaunchProblem(markers[i])) {
return true;
}
}
}
return false;
}
/**
* Returns whether the given problem should potentially abort the launch.
* By default if the problem has an error severity, the problem is considered
* a potential launch problem. Subclasses may override to specialize error
* detection.
*
* #param problemMarker candidate problem
* #return whether the given problem should potentially abort the launch
* #throws CoreException if any exceptions occur while accessing marker attributes
*/
protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException {
Integer severity = (Integer)problemMarker.getAttribute(IMarker.SEVERITY);
if (severity != null) {
return severity.intValue() >= IMarker.SEVERITY_ERROR;
}
return false;
}
The same code can run on any IResource instead of an IProject.
I managed to find it easily by suspending from the debugger when the dialog was shown and setting a breakpoint on the relevant class and tracing back from there.
Errors are usually saved as IMarkers on a resource (IFile in your case), so you can query the IFile for the markers you are looking for.
You'll need to know the type of the markers before the look-up (either by debugging and get all the current markers, or by looking at the code the contributed them in the validation process of the file).
Hope that helps.

HELP! Issues with the build phase when binding Objective-C library to MonoTouch

I am currently working on the port of ZebraLink's printer libraries for using into MonoTouch project. These libraries exist and where created for the iOS, so I got the .a file and the bunch of header files developed with Objective-C. Once I get some success on it I will gladly upload it to share with anyone interested, but first I gotta get around a couple of issues, I ask for your kind help:
I currently have 3 classes -> Main.cs , enums.cs and helpers.cs
In the Main.cs I follow the basic structure as mentioned in the Binding Objective-C tutorial
using System;
using MonoTouch.Foundation;
namespace btouchtest
{
[BaseType (typeof (NSObject))]
[Model]
interface ZebraPrinterConnection
{
/**
* Returns the maximum time, in milliseconds, to wait for any data to be received.
*/
//- (NSInteger) getMaxTimeoutForRead;
[Export ("getMaxTimeoutForRead")]
int getMaxTimeoutForRead();
/**
* Returns the maximum time, in milliseconds, to wait between reads after the initial read.
*/
//- (NSInteger) getTimeToWaitForMoreData;
[Export ("getTimeToWaitForMoreData")]
int getTimeToWaitForMoreData();
/**
* Returns <c>YES</c> if the connection is open.
*
* #return <c>YES</c> if this connection is open.
*/
//- (BOOL) isConnected;
[Export ("isConnected")]
bool isConnected();
/**
* Opens the connection to a device. If the ZebraPrinterConnection::open method is called on an open connection
* this call is ignored. When a handle to the connection is no longer needed, call ZebraPrinterConnection::close
* to free up system resources.
*
* #return <c>NO</c> if the connection cannot be established.
*/
//- (BOOL) open;
[Export ("open")]
bool open();
/**
* Closes this connection and releases any system resources associated with the connection. If the connection is
* already closed then invoking this method has no effect.
*/
//- (void) close;
[Export ("close")]
void close();
/**
* Writes the number of bytes from <c>data</c> to the connection. The connection must be
* open before this method is called. If ZebraPrinterConnection::write:error: is called when a connection is closed, -1 is returned.
*
* #param data The data.
* #param error Will be set to the error that occured.
* #return The number of bytes written or -1 if an error occurred.
*/
//- (NSInteger) write:(NSData *)data error:(NSError **)error;
[Internal, Export ("write:error:")]
int _write(NSData data, IntPtr error);
/**
* Reads all the available data from the connection. This call is non-blocking.
*
* #param error Will be set to the error that occured.
* #return The bytes read from the connection or <c>nil</c> if an error occurred.
*/
//- (NSData *)read: (NSError**)error;
[Internal, Export ("read:")]
NSData _read(IntPtr error);
/**
* Returns <c>YES</c> if at least one byte is available for reading from this connection.
*
* #return <c>YES</c> if there is data available.
*/
//- (BOOL) hasBytesAvailable;
[Export ("hasBytesAvailable")]
bool hasBytesAvailable();
/**
* Causes the currently executing thread to sleep until <c>hasBytesAvailable</c> equals <c>YES</c>, or for a maximum of
* <c>maxTimeout</c> milliseconds.
*
* #param maxTimeout Maximum time in milliseconds to wait for an initial response from the printer.
*/
//- (void) waitForData: (NSInteger)maxTimeout;
[Export ("waitForData:")]
void waitForData(int maxTimeout);
}
}
In the enums.cs I simply list the enums, no namespace and I use the template of an empty c# file:
public enum PrinterLanguage
{
/**
* Printer control language ZPL
*/
PRINTER_LANGUAGE_ZPL,
/**
* Printer control language CPCL
*/
PRINTER_LANGUAGE_CPCL
}
At this point I have no problems with the build, I can get a .dll using bash
/Developer/MonoTouch/usr/bin/btouch Main.cs -s:enums.cs -out:btouchtest.dll
The issues start when I try to use a "helper class" for exporting methods that require the handling of some pointers. The tutorial is clear with the binding of methods with arguments like (NSError **), so I create the helper.cs file
using System;
using MonoTouch.Foundation;
namespace btouchtest
{
partial class ZebraPrinterConnection
{
int write (NSData data, out NSError error)
{
unsafe
{
IntPtr error;
IntPtr ptr_to_error = (IntPtr) (&error);
_write(data, ptr_to_error);
if (error != IntPtr.Zero)
error = (NSError) Runtime.GetNSObject (error);
else
error = null;
}
}
NSData read (out NSError error)
{
unsafe
{
IntPtr error;
IntPtr ptr_to_error = (IntPtr) (&error);
_read(ptr_to_error);
if (error != IntPtr.Zero)
error = (NSError) Runtime.GetNSObject (error);
else
error = null;
}
}
}
}
The build this time goes like this:
/Developer/MonoTouch/usr/bin/btouch -unsafe -out:btouchtest.dll Main.cs helper.c
And bingo!, instead of a nice .dll, btouch spits all kinds of errors:
Main.cs(8,19): error CS0260: Missing partial modifier on declaration of type `btouchtest.ZebraPrinterConnection'. Another partial declaration of this type exists
helper.cs(7,23): (Location of the symbol related to previous error)
helper.cs(7,23): error CS0261: Partial declarations of `btouchtest.ZebraPrinterConnection' must be all classes, all structs or all interfaces
Main.cs(8,19): (Location of the symbol related to previous error)
helper.cs(13,25): error CS0136: A local variable named `error' cannot be declared in this scope because it would give a different meaning to `error', which is already used in a `parent or current' scope to denote something else
helper.cs(10,21): error CS0531: `btouchtest.ZebraPrinterConnection.write(NSData, out NSError)': interface members cannot have a definition
helper.cs(27,25): error CS0136: A local variable named `error' cannot be declared in this scope because it would give a different meaning to `error', which is already used in a `parent or current' scope to denote something else
helper.cs(24,24): error CS0531: `btouchtest.ZebraPrinterConnection.read(out NSError)': interface members cannot have a definition
Compilation failed: 6 error(s), 0 warnings
btouch: API binding contains errors.
What I get out of this is that in the same namespace I got an interface named "ZebraPrinterConnection" and also a partial class named "ZebraPrinterConnection". I dunno how to handle this because I am just following the guideline.
The other issue comes from using the next snippet for handling (NSError **), and it is the sample shown in the Binding Objective-C tutorial, so something is wrong.
I declare my exported methods:
[Internal, Export ("write:error:")]
int _write(NSData data, IntPtr error);
[Internal, Export ("read:")]
NSData _read(IntPtr error);
because its objective-C signatures are:
(NSInteger) write:(NSData *)data error:(NSError **)error;
(NSData *)read: (NSError**)error;
and I need to implement the helper class, according to the tutorial, for handling the error with something like what is shown before in the source code of the helper class (which in turn is very sound to me, as I need to handle a pointer to a pointer):
int write (NSData data, out NSError error)
{
unsafe
{
IntPtr error;
IntPtr ptr_to_error = (IntPtr) (&error);
_write(data, ptr_to_error);
if (error != IntPtr.Zero)
error = (NSError) Runtime.GetNSObject (error);
else
error = null;
}
}
NSData read (out NSError error)
{
unsafe
{
IntPtr error;
IntPtr ptr_to_error = (IntPtr) (&error);
_read(ptr_to_error);
if (error != IntPtr.Zero)
error = (NSError) Runtime.GetNSObject (error);
else
error = null;
}
}
But btouch hates this!!! When trying to build it yells:
helper.cs(27,25): error CS0136: A local variable named `error' cannot be declared in this scope because it would give a different meaning to `error', which is already used in a `parent or current' scope to denote something else
After everything mentioned ... I downloaded a binding source sample from http://mtcocos2d.googlecode.com/svn/trunk , it is an 'almost working' port of Cocos2D to Monotouch, additionally to the source code one can find a lib.a and .dll available, so I suppose the binding source code can be "btouch"-ed and generate my own lib based on the source code provided ...
/Developer/MonoTouch/usr/bin/btouch -unsafe -out:cocos2d.dll -s:cocos2d.cs enums.cs extensions.cs structs.cs
AND NO!!!!! Btouch spits like 36 errors identical to mine ... so I am doomed ...
I've been comparing the source files from this binding demo and I see no big differences in the general structure, same type of files, same type of interfaces, same type of classes ... all brackets closed ...
I'd really appreciate your help, I'm no expert on C# but I have lots of iOS developing experience ... but in this new job we gotta work under MonoTouch, so I am still learning.
PLEASE HELP!!!! And many thanx in advance!!
It would be useful if you posted snippets (and links) to the objective-c headers. Maybe ZebraPrinter is not suppose to be defined with [Model]. And it is always useful to include in your description the version of MT you are using.

Doxygen including methods twice doc files

I'm having this issue where doxygen is adding the method twice in the documentation file. Is there a setting that stops auto-generation of documentation for methods within the .m file.
For example in the documentation I'll see something like whats below where
the first definition of + (Status *)registerUser is from the header XXXXXX.h file where the second is from XXXXXX.m.
Header documentation :
/**
#brief Test
Yada Yada
#return <#(description)#>
*/
+ (Status *)registerUser;
Output:
+ (Status *) registerUser
Test Yada Yada.
Returns:
<#(description)#>
+ (Status *) registerUser
<#(brief description)#> <#(comprehensive description)#>
registerUser
Returns:
<#(description)#>
Definition at line 24 of file XXXXXX.m.
Problem solved! I found out that doxygen was including my build directory and my .svn directories.
I added to EXCLUDE_PATTERNS
*/.svn/*
*/.build/*