Generate Source Code for specific file using Doxygen - doxygen

Setting SOURCE_BROWSER = TRUE show source code for all files.
Is it possible to show source of specific file?
Or enable \ref or equivalent using SOURCE_BROWSER = FALSE
Or remove source code for specifics files if SOURCE_BROWSER = TRUE
Or equivalent

It is possible using \include and \verbinclude.
/**
* \verbinclude Example.cs
* \include Example.cs
* */
public class Example
{
}

Related

TYPO3 change template inside action method

In my ext I have singleAction method. I want to change template inside this method, because I have 2 templates for single action. Is it possible? If it impossible, how can I solve this problem? Maybe generate another action?
It's not that simple to set a template. the setTemplate and getTemplate don't exist in the View.
You could revert to a standaloneview implemtation, which supports the use of setTemplatePathAndFilename
(example copied from Ludwig)
/**
* Renders the fluid email template
* #param string $template
* #param array $assign
* #return string
*/
public function renderFluidTemplate($template, Array $assign = array()) {
$templatePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:myextension/Resources/Private/Templates/' . $template);
$view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$view->setTemplatePathAndFilename($templatePath);
$view->assignMultiple($assign);
return $view->render();
}
echo renderFluidTemplate('mail.html', array('test' => 'This is a test!'));
You could also switch to a different template with typoscript.
plugin.tx_yourpluginname.view.templateRootPaths = EXT:extension_name/Resources/Private/CustomPath/Templates/
And this can be put into any typoscript condition you want.
The best way to handle this is simply to have a switch in the template of the action, loading a different partial. This way the whole flow of logic stays intact and it's immediately understandable for everyone who will have to edit your code later on.

Is it possible for Doxygen to exclude undocumented functions from generated XML?

I want to generate documentation only for code that has Doxygen comments. I have created a Doxyfile via Doxygen version 1.8.9.1 and configured it to output only XML and to hide all undocumented code:
GENERATE_HTML = NO
GENERATE_LATEX = NO
GENERATE_XML = YES
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
After that I created a simple C header test.h with one documented and one non-documented function declaration:
void foo(int a);
/**
* "bar" function description
* #param b sample param
*/
void bar(int b);
By executing doxygen I expected only documentation for bar to be included in the resulting XML. Unfortunately, documentation for both functions is generated. Is it possible to generate documentation only for code that has Doxygen comments? Or will Doxygen always include everything in the XML output regardless of settings?
Before reading any further make sure EXTRACT_ALL is set to NO.
I'm not a fan of the following solution but it does work. Use doxygen's preprocessor
#ifdef PROJECT_NO_DOC
void foo(int a);
#endif /* PROJECT_NO_DOC */
/**
* * "bar" function description
* * #param b sample param
* */
void bar(int b);
Note, in their docs you have to set a PREDEFINED macro but at least in my version of doxygen this was not required. Their docs specify to do it this way set a predefined macro in the config to do it for you
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/* code that must be skipped by Doxygen */
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
around the blocks that should be hidden and put:
PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
in the config file then all blocks should be skipped by doxygen as long as
ENABLE_PREPROCESSING = YES
There are other methods but they come with additional constraints ie to make sure no static method appear in your public docs you can set EXTRACT_STATIC to NO.
You can use \cond to hide parts of the source code from Doxygen. This avoids the need to use the preprocessor as in Harry's answer.
For example, here foo will not be seen by Doxygen, and hence not documented:
/** \cond */
void foo(int a);
/** \endcond */
/**
* "bar" function description
* #param b sample param
*/
void bar(int b);
Furthermore, it is possible to add section labels to \cond, and control which sections are included by listing them in the ENABLED_SECTIONS configuration option.
For example:
/// \cond CLASS_A
/// This function foos `a`.
void foo(int a);
/// \endcond
/// \cond CLASS_B
/// This function bars `b`.
void bar(int b);
/// \endcond
By setting ENABLED_SECTIONS = CLASS_A CLASS_B, both functions will show up in the documentation. Leaving one of the labels out will hide the corresponding function.

What is the correct syntax for using EXCLUDE_SYMBOLS?

I have a class like so:
class Foo {
public:
/** blah blah */
void bar();
}
I want to exclude this from the documentation, but EXCLUDE_SYMBOLS isn't working for me. I have tried the following (one by one):
EXCLUDE_SYMBOLS = Foo::bar
EXCLUDE_SYMBOLS = Foo::*
EXCLUDE_SYMBOLS = Foo
EXCLUDE_SYMBOLS = *
None of these is working. Is there a mistake in my syntax, or is there some other configuration I need to change for this to take effect?
I have looked at several questions on SO, but the syntax used in those answers doesn't work for me.
This exclude expression works good in my case with doxygen 1.8.14:
EXCLUDE_SYMBOLS = "TestTemplate< T, std::string >" "TestNS::*" "TestClass*"
In EXCLUDE_SYMBOLS it is specified or exact symbol name or a '*'-pattern. Exact symbol name may be retrieved from doxygen XML output (try enable it in Doxyfile).

doxygen not listing functions in nested namespaces

I'm documenting my code and can't make doxygen to pick up
functions inside nested namespaces.
Googling around i didn't see anyone facing this problem, sorry if a duplicate.
namespace n1 {
/*! #addtogroup n1
*#{
*/
/**
* n2 is...
*/
namespace n2 {
/**
* n3 is...
*/
namespace n3 {
/**
* function does...
*/
static inline
int
find() { }
}
}
/*#}*/
}
In the resulting documentation (html) I see all namespaces (n1, n2, n3) but don't see any functions (e.g. find() ). The page corresponding to n3 namespace contains none.
I also tried EXTRACT_ALL build flag, does not seem to help.
p/s/ doxygen is generated using Doxygen GUI for OS-X.
You need to set EXTRACT_STATIC = YES in your Doxyfile.
The comment on EXTRACT_ALL states, "Private class members and static file members will be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES"
I've tested with your example and setting EXTRACT_STATIC = YES and the find function is visible in the resulting documentation.

Make Doxygen document a struct/class defined inside a macro call

I have this PACKED macro, that receives a struct definition and returns it with a compiler annotation to make it packed.
For example:
/**
* ...
*/
PACKED(struct A {
/**
* ...
*/
int x;
});
I have tried several Doxygen options to include that documentation, but I've had no success so far. Closest I've come up with is this:
ENABLE_PREPROCESSING = YES
PREDEFINED = PACKED(type)=type
MACRO_EXPANSION = YES
But that messes up the struct and members' documentation (confirmed via doxygen -d Preprocessor).
Ideas?
Turns out it's a bug in Doxygen.
One possible workaround is to use #class, and so on.