Skip to content

Commit

Permalink
Fix Warning doxygenfunction: Unable to resolve function errors in docs
Browse files Browse the repository at this point in the history
Doxygen has trouble creating documentation for functions that are declared in a
header file and defined in an other `.h`, rather than `.c` file, or otherwise
appear in multiple header files. This fixes two functions that were displaying
warning messages inside the published documentation. The folowing pattern can be
used in future cases that need to be explicitly ommited due to multiple
appearences in header files:

`#ifndef DOXYGEN_SKIP_SECTION`
<code to be omitted>
`#endif /* DOXYGEN_SKIP_SECTION */`

Preferably with a short `/* comment */` trailing the `#ifndef` entry mentioning
the file where the function is actually documented.

Signed-off-by: Winford <winford@object.stream>
  • Loading branch information
UncleGrumpy committed Jul 10, 2023
1 parent 528b5e9 commit a370831
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ C source modules (`.c`) should be organized as follows:
+-------------------
module.c

#### Documentation

[Doxygen Javadoc style](https://www.doxygen.nl/manual/docblocks.html) code comments will be picked up and added to the documentation. Changes will automatically be added to the [libAtomVM Source Files](https://www.atomvm.net/doc/master/c_api_docs.html#libatomvm-source-files) and the [libAtomVM Index](https://www.atomvm.net/doc/master/apidocs/libatomvm/index.html#libatomvm-index). But to have `Data Strucures`, `Types`, `MACROS`, and `Functions` appear in the correct C Library APIs section the corresponding entries must be added to the similarly named `*.rst` files in the `AtomVM/doc/src/apidocs/libatomvm/` directory. The exact names of the flies that need to be altered are: `data_structures.rst`, `functions.rst`, `macros.rst`, and `types.rst`. The other files in the directory handle auto`generated content and do not need to be altered.

In the rare case that a function declaration and definition are both in different header files (rather than the definition in a `*.c` file) this can cause rendering errors for `Doxygen`. The work around for these cases can be demonstrated with this example for the function `sys_listener_destroy` it is documented and declared in `sys.h` and defined as follows in `listeners.h`:

#ifndef DOXYGEN_SKIP_SECTION /* documented in sys.h */
void sys_listener_destroy(struct ListHead *item)
{
EventListener *listener = GET_LIST_ENTRY(item, EventListener, listeners_list_head);
free(listener);
}
#endif /* DOXYGEN_SKIP_SECTION */

> Note: You should include a short `/* comment */` trailing the `#ifndef` entry mentioning the file where the function is actually documented.
### Erlang Code

Erlang source code style is enforced using [erlfmt](https://github.com/WhatsApp/erlfmt).
Expand Down
2 changes: 1 addition & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED =
PREDEFINED = DOXYGEN_SKIP_SECTION

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
11 changes: 0 additions & 11 deletions doc/erlang-reference-doc.md

This file was deleted.

2 changes: 2 additions & 0 deletions src/libAtomVM/listeners.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ static inline bool process_listener_handler(GlobalContext *glb, listener_event_t
return result;
}

#ifndef DOXYGEN_SKIP_SECTION /* documented in sys.h */
void sys_listener_destroy(struct ListHead *item)
{
EventListener *listener = GET_LIST_ENTRY(item, EventListener, listeners_list_head);
free(listener);
}
#endif /* DOXYGEN_SKIP_SECTION */
2 changes: 2 additions & 0 deletions src/libAtomVM/opcodesswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,9 @@ static bool maybe_call_native(Context *ctx, AtomString module_name, AtomString f
int read_core_chunk(Module *mod)
#else
#ifdef IMPL_EXECUTE_LOOP
#ifndef DOXYGEN_SKIP_SECTION /* documented in context.h */
int context_execute_loop(Context *ctx, Module *mod, const char *function_name, int arity)
#endif /* DOXYGEN_SKIP_SECTION */
#else
#error Need implementation type
#endif
Expand Down

0 comments on commit a370831

Please sign in to comment.