diff --git a/book/Makefile b/book/Makefile index 91af83f..7ee8c3e 100644 --- a/book/Makefile +++ b/book/Makefile @@ -79,8 +79,9 @@ man: $(SphinxMan) ## Generate and open the documentation in the terminal man $< pdf: $(SphinxPdf) ## Generate and open the documentation as a PDF + $(Open) $(SphinxFolder)/latex/blackmagic.pdf -doxygen_html html pdf: +doxygen_html html: $(Open) $< 2>/dev/null .PHONY: doxygen_html html man pdf diff --git a/book/pages/reference/arg_count.md b/book/pages/reference/arg_count.md deleted file mode 100644 index b0dcb92..0000000 --- a/book/pages/reference/arg_count.md +++ /dev/null @@ -1,4 +0,0 @@ -# Counting arguments - -:::{doxygenfile} arg_count.h -::: diff --git a/book/pages/reference/fold.md b/book/pages/reference/fold.md deleted file mode 100644 index 4ee11fe..0000000 --- a/book/pages/reference/fold.md +++ /dev/null @@ -1,4 +0,0 @@ -# Fold - -:::{doxygenfile} fold.h -::: diff --git a/book/pages/reference/index.md b/book/pages/reference/index.md index 3af5380..75d3c44 100644 --- a/book/pages/reference/index.md +++ b/book/pages/reference/index.md @@ -1,9 +1,7 @@ # Reference :::{toctree} -token -arg_count -fold +internal color log ::: diff --git a/book/pages/reference/token.md b/book/pages/reference/internal.md similarity index 61% rename from book/pages/reference/token.md rename to book/pages/reference/internal.md index be0c6e2..9764d54 100644 --- a/book/pages/reference/token.md +++ b/book/pages/reference/internal.md @@ -1,4 +1,4 @@ -# Token manipulation +# Macros for writing macros ## Create a string literal @@ -13,3 +13,13 @@ ::: :::{doxygendefine} CONCAT ::: + +## Count arguments + +:::{doxygendefine} ARG_COUNT +::: + +## Fold + +:::{doxygenfile} fold.h +::: diff --git a/include/blackmagic/arg_count.h b/include/blackmagic/arg_count.h index a3aa98c..cc0688c 100644 --- a/include/blackmagic/arg_count.h +++ b/include/blackmagic/arg_count.h @@ -3,7 +3,6 @@ /** * @file * Count the number of arguments of a variadic macro. - * @author Antoine GAGNIERE */ /** Returns the 78th argument */ diff --git a/include/blackmagic/blackmagic.h b/include/blackmagic/blackmagic.h index 1dc5b60..c681ba2 100644 --- a/include/blackmagic/blackmagic.h +++ b/include/blackmagic/blackmagic.h @@ -3,13 +3,14 @@ /** * @file * Include all blackmagic headers with a single include + * @author Antoine GAGNIERE */ -#include "blockmagic/token.h" -#include "blockmagic/log.h" -#include "blockmagic/for.h" -#include "blockmagic/color.h" -#include "blockmagic/enum.h" +#include "blackmagic/token.h" +#include "blackmagic/log.h" +#include "blackmagic/for.h" +#include "blackmagic/color.h" +#include "blackmagic/enum.h" #include "blackmagic/fold.h" /** @@ -19,15 +20,18 @@ * @code{.c} * #include * @endcode + * @author Antoine GAGNIERE */ /** * @dir blackmagic * This directory contains all blackmagic headers. * Do not add it directly to the search path for headers, prefer instead the `include` directory + * @author Antoine GAGNIERE */ /** * @mainpage * Welcome to the documentation of black magic. + * @author Antoine GAGNIERE */ diff --git a/include/blackmagic/color.h b/include/blackmagic/color.h index 7cccb52..3cbd652 100644 --- a/include/blackmagic/color.h +++ b/include/blackmagic/color.h @@ -2,7 +2,7 @@ /** * @file - * + * Human readable ANSI escape code */ #include "blackmagic/token.h" // STRINGIZE @@ -52,6 +52,14 @@ /** * Expands to a string literal containig an escape code setting the terminal color. + * @section example Example + * @code{.c} + * COLOR(BOLD, ITALIC, UNDERLINED, BLUE) + * @endcode + * Evaluates to: + * @code{.c} + * "\e[1;3;4;34m" + * @endcode * @since 0.1 */ #define COLOR(...) STRINGIZE(\e[FOLD(COLOR_JOIN __VA_OPT__(,) __VA_ARGS__)m) diff --git a/include/blackmagic/fold.h b/include/blackmagic/fold.h index 92dc2e7..ce88f51 100644 --- a/include/blackmagic/fold.h +++ b/include/blackmagic/fold.h @@ -3,7 +3,6 @@ /** * @file * Apply a binary macro on any number of argument - * @author Antoine GAGNIERE */ #include "blackmagic/arg_count.h" // ARG_COUNT @@ -13,7 +12,7 @@ ///@{ #ifndef FOLD /** Default fold to use, can be overridden */ -# define FOLD TREE_FOLD +# define FOLD TREE_FOLD #endif ///@} @@ -45,6 +44,7 @@ */ #define FOLD_RIGHT(M, ...) CONCAT(FOLD_RIGHT_, ARG_COUNT(__VA_ARGS__))(M __VA_OPT__(,) __VA_ARGS__) +/// @cond #define TREE_FOLD_0(M) #define TREE_FOLD_1(M, A) A #define TREE_FOLD_2(M, A, B) M(A, B) @@ -68,23 +68,24 @@ #define TREE_FOLD_20(M, A, B, C, D, ...) M(M(M(A, B), M(C, D)), TREE_FOLD_16(M, __VA_ARGS__)) #define FOLD_RIGHT_0(M) -#define FOLD_RIGHT_1(M, A) A -#define FOLD_RIGHT_2(M, A, B) M(A, B) -#define FOLD_RIGHT_3(M, A, B, C) M(A, M(B, C)) -#define FOLD_RIGHT_4(M, A, B, C, D) M(A, M(B, M(C, D))) +#define FOLD_RIGHT_1(M, A) A +#define FOLD_RIGHT_2(M, A, B) M(A, B) +#define FOLD_RIGHT_3(M, A, B, C) M(A, M(B, C)) +#define FOLD_RIGHT_4(M, A, B, C, D) M(A, M(B, M(C, D))) #define FOLD_RIGHT_5(M, A, B, C, D, E) M(A, M(B, M(C, M(D, E)))) -#define FOLD_RIGHT_6(M, A, ...) M(A, FOLD_RIGHT_5(M, __VA_ARGS__)) -#define FOLD_RIGHT_7(M, A, B, ...) M(A, M(B, FOLD_RIGHT_5(M, __VA_ARGS__))) -#define FOLD_RIGHT_8(M, A, B, C, ...) M(A, M(B, M(C, FOLD_RIGHT_5(M, __VA_ARGS__)))) -#define FOLD_RIGHT_9(M, A, ...) M(A, FOLD_RIGHT_8(M, __VA_ARGS__)) -#define FOLD_RIGHT_10(M, A, ...) M(A, FOLD_RIGHT_9(M, __VA_ARGS__)) -#define FOLD_RIGHT_11(M, A, ...) M(A, FOLD_RIGHT_10(M, __VA_ARGS__)) -#define FOLD_RIGHT_12(M, A, ...) M(A, FOLD_RIGHT_11(M, __VA_ARGS__)) -#define FOLD_RIGHT_13(M, A, ...) M(A, FOLD_RIGHT_12(M, __VA_ARGS__)) -#define FOLD_RIGHT_14(M, A, ...) M(A, FOLD_RIGHT_13(M, __VA_ARGS__)) -#define FOLD_RIGHT_15(M, A, ...) M(A, FOLD_RIGHT_14(M, __VA_ARGS__)) -#define FOLD_RIGHT_16(M, A, ...) M(A, FOLD_RIGHT_15(M, __VA_ARGS__)) -#define FOLD_RIGHT_17(M, A, ...) M(A, FOLD_RIGHT_16(M, __VA_ARGS__)) -#define FOLD_RIGHT_18(M, A, ...) M(A, FOLD_RIGHT_17(M, __VA_ARGS__)) -#define FOLD_RIGHT_19(M, A, ...) M(A, FOLD_RIGHT_18(M, __VA_ARGS__)) -#define FOLD_RIGHT_20(M, A, ...) M(A, FOLD_RIGHT_19(M, __VA_ARGS__)) +#define FOLD_RIGHT_6(M, A, ...) M(A, FOLD_RIGHT_5(M, __VA_ARGS__)) +#define FOLD_RIGHT_7(M, A, B, ...) M(A, M(B, FOLD_RIGHT_5(M, __VA_ARGS__))) +#define FOLD_RIGHT_8(M, A, B, C, ...) M(A, M(B, M(C, FOLD_RIGHT_5(M, __VA_ARGS__)))) +#define FOLD_RIGHT_9(M, A, ...) M(A, FOLD_RIGHT_8(M, __VA_ARGS__)) +#define FOLD_RIGHT_10(M, A, ...) M(A, FOLD_RIGHT_9(M, __VA_ARGS__)) +#define FOLD_RIGHT_11(M, A, ...) M(A, FOLD_RIGHT_10(M, __VA_ARGS__)) +#define FOLD_RIGHT_12(M, A, ...) M(A, FOLD_RIGHT_11(M, __VA_ARGS__)) +#define FOLD_RIGHT_13(M, A, ...) M(A, FOLD_RIGHT_12(M, __VA_ARGS__)) +#define FOLD_RIGHT_14(M, A, ...) M(A, FOLD_RIGHT_13(M, __VA_ARGS__)) +#define FOLD_RIGHT_15(M, A, ...) M(A, FOLD_RIGHT_14(M, __VA_ARGS__)) +#define FOLD_RIGHT_16(M, A, ...) M(A, FOLD_RIGHT_15(M, __VA_ARGS__)) +#define FOLD_RIGHT_17(M, A, ...) M(A, FOLD_RIGHT_16(M, __VA_ARGS__)) +#define FOLD_RIGHT_18(M, A, ...) M(A, FOLD_RIGHT_17(M, __VA_ARGS__)) +#define FOLD_RIGHT_19(M, A, ...) M(A, FOLD_RIGHT_18(M, __VA_ARGS__)) +#define FOLD_RIGHT_20(M, A, ...) M(A, FOLD_RIGHT_19(M, __VA_ARGS__)) +///@endcond diff --git a/include/blackmagic/for.h b/include/blackmagic/for.h index 93b8622..49552a6 100644 --- a/include/blackmagic/for.h +++ b/include/blackmagic/for.h @@ -3,7 +3,6 @@ /** * @file * Generate code by calling a macro repeatedly - * @author Antoine GAGNIERE */ /** To be used with @ref FOR */ diff --git a/include/blackmagic/log.h b/include/blackmagic/log.h index dc79b61..8afa22c 100644 --- a/include/blackmagic/log.h +++ b/include/blackmagic/log.h @@ -83,6 +83,7 @@ # define log_header() /**< Place this macro once before any log */ #endif +///@cond #if LOG_FORMAT == LOG_FORMAT_CONSOLE # define log_log(LEVEL, IGNORED, MESSAGE, ...) \ fprintf(LOG_FILE, "[%5s " __FILE__ ":%s:" STRINGIZE(__LINE__) "] " MESSAGE "\n", LEVEL, __func__ __VA_OPT__(, ) __VA_ARGS__) @@ -96,6 +97,7 @@ #else # define log_log(L, C, M, ...) /* Logs are disabled */ #endif +///@endcond #if LOG_LEVEL >= LOG_LEVEL_FATAL /** Report a condition that forces to program to terminate */ diff --git a/include/blackmagic/token.h b/include/blackmagic/token.h index 4a587bd..5ddec87 100644 --- a/include/blackmagic/token.h +++ b/include/blackmagic/token.h @@ -3,7 +3,6 @@ /** * @file * Token manipulation. - * @author Antoine GAGNIERE */ /**