From 24604d024a187dd06544ddbda880ab4bc4bcdb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Lafuente?= Date: Tue, 9 Jan 2024 22:51:39 +0100 Subject: [PATCH] C API: fix docs build after rebase --- Makefile | 9 +++++++++ Makefile.config.in | 1 + configure.ac | 4 ++++ doc/external-api/README.md | 6 +++--- doc/external-api/local.mk | 16 ++-------------- package.nix | 3 +++ src/libstore/c/nix_api_store.h | 2 +- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index d9efc8154..ae4a8f0a4 100644 --- a/Makefile +++ b/Makefile @@ -129,3 +129,12 @@ internal-api-html: @echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'." @exit 1 endif + +ifeq ($(ENABLE_EXTERNAL_API_DOCS), yes) +$(eval $(call include-sub-makefile, doc/external-api/local.mk)) +else +.PHONY: external-api-html +external-api-html: + @echo "External API docs are disabled. Configure with '--enable-external-api-docs', or avoid calling 'make external-api-html'." + @exit 1 +endif diff --git a/Makefile.config.in b/Makefile.config.in index d5c382630..7f517898c 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -12,6 +12,7 @@ ENABLE_BUILD = @ENABLE_BUILD@ ENABLE_DOC_GEN = @ENABLE_DOC_GEN@ ENABLE_FUNCTIONAL_TESTS = @ENABLE_FUNCTIONAL_TESTS@ ENABLE_INTERNAL_API_DOCS = @ENABLE_INTERNAL_API_DOCS@ +ENABLE_EXTERNAL_API_DOCS = @ENABLE_EXTERNAL_API_DOCS@ ENABLE_S3 = @ENABLE_S3@ ENABLE_UNIT_TESTS = @ENABLE_UNIT_TESTS@ GTEST_LIBS = @GTEST_LIBS@ diff --git a/configure.ac b/configure.ac index c3823c01c..1d327d51d 100644 --- a/configure.ac +++ b/configure.ac @@ -177,6 +177,10 @@ AC_ARG_ENABLE(internal-api-docs, AS_HELP_STRING([--enable-internal-api-docs],[Bu ENABLE_INTERNAL_API_DOCS=$enableval, ENABLE_INTERNAL_API_DOCS=no) AC_SUBST(ENABLE_INTERNAL_API_DOCS) +AC_ARG_ENABLE(external-api-docs, AS_HELP_STRING([--enable-external-api-docs],[Build API docs for Nix's external unstable C interfaces]), + ENABLE_EXTERNAL_API_DOCS=$enableval, ENABLE_EXTERNAL_API_DOCS=no) +AC_SUBST(ENABLE_EXTERNAL_API_DOCS) + AS_IF( [test "$ENABLE_FUNCTIONAL_TESTS" == "yes" || test "$ENABLE_DOC_GEN" == "yes"], [NEED_PROG(jq, jq)]) diff --git a/doc/external-api/README.md b/doc/external-api/README.md index ff0a30ff4..3fa1c55f9 100644 --- a/doc/external-api/README.md +++ b/doc/external-api/README.md @@ -48,7 +48,7 @@ int main() { return 0; } ``` - + **Usage:** ```ShellSession $ gcc main.c $(pkg-config nix-expr-c --libs --cflags) -o main @@ -66,7 +66,7 @@ It will increment the argument if it is an integer and throw an error otherwise. #include #include #include - + void increment(void* user_data, nix_c_context* ctx, State* state, Value** args, Value* v) { nix_value_force(NULL, state, args[0]); if (nix_get_type(NULL, args[0]) == NIX_TYPE_INT) { @@ -75,7 +75,7 @@ void increment(void* user_data, nix_c_context* ctx, State* state, Value** args, nix_set_err_msg(ctx, NIX_ERR_UNKNOWN, "First argument should be an integer."); } } - + void nix_plugin_entry() { const char* args[] = {"n", NULL}; PrimOp *p = nix_alloc_primop(NULL, increment, 1, "increment", args, "Example custom built-in function: increments an integer", NULL); diff --git a/doc/external-api/local.mk b/doc/external-api/local.mk index aa501198b..c739bdaf0 100644 --- a/doc/external-api/local.mk +++ b/doc/external-api/local.mk @@ -1,19 +1,7 @@ -.PHONY: external-api-html - -ifeq ($(external_api_docs), yes) - $(docdir)/external-api/html/index.html $(docdir)/external-api/latex: $(d)/doxygen.cfg mkdir -p $(docdir)/external-api { cat $< ; echo "OUTPUT_DIRECTORY=$(docdir)/external-api" ; } | doxygen - -# Generate the HTML API docs for Nix's unstable external interfaces. +# Generate the HTML API docs for Nix's unstable C bindings +.PHONY: external-api-html external-api-html: $(docdir)/external-api/html/index.html - -else - -# Make a nicer error message -external-api-html: - @echo "External API docs are disabled. Configure with '--enable-external-api-docs', or avoid calling 'make external-api-html'." - @exit 1 - -endif diff --git a/package.nix b/package.nix index af4ca9b46..c9e50c399 100644 --- a/package.nix +++ b/package.nix @@ -184,6 +184,9 @@ in { ./doc/manual ] ++ lib.optionals enableInternalAPIDocs [ ./doc/internal-api + ] ++ lib.optionals enableExternalAPIDocs [ + ./doc/external-api + ] ++ lib.optionals (enableInternalAPIDocs || enableExternalAPIDocs) [ # Source might not be compiled, but still must be available # for Doxygen to gather comments. ./src diff --git a/src/libstore/c/nix_api_store.h b/src/libstore/c/nix_api_store.h index 91abdb201..7732ade6b 100644 --- a/src/libstore/c/nix_api_store.h +++ b/src/libstore/c/nix_api_store.h @@ -109,7 +109,7 @@ bool nix_store_is_valid_path(nix_c_context * context, Store * store, StorePath * /** * @brief Realise a Nix store path * - * Blocking, calls callback once for each realisedoutput + * Blocking, calls callback once for each realised output * * @param[out] context Optional, stores error information * @param[in] store Nix Store reference