From 3eeef346b1cf8033b4259f6ade93d765226f55f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 29 Mar 2023 23:54:07 +0200 Subject: [PATCH] doc: update autogen files only if changed, add autogen dependencies on docs --- doc/de/CMakeLists.txt | 4 + doc/en/CMakeLists.txt | 12 +++ doc/fr/CMakeLists.txt | 12 +++ doc/it/CMakeLists.txt | 12 +++ doc/ja/CMakeLists.txt | 12 +++ doc/pl/CMakeLists.txt | 4 + doc/sr/CMakeLists.txt | 12 +++ src/core/wee-doc.c | 198 +++++++++++++++++++++++++----------------- 8 files changed, 186 insertions(+), 80 deletions(-) diff --git a/doc/de/CMakeLists.txt b/doc/de/CMakeLists.txt index 34a2e86c9..d1593b6f1 100644 --- a/doc/de/CMakeLists.txt +++ b/doc/de/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.de.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.de.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.de.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.de.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.de.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.de.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.de.html" ) diff --git a/doc/en/CMakeLists.txt b/doc/en/CMakeLists.txt index 799a24258..84d629180 100644 --- a/doc/en/CMakeLists.txt +++ b/doc/en/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.en.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.en.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.en.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.en.html" ) @@ -74,6 +78,14 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/../docinfo.html ${CMAKE_CURRENT_SOURCE_DIR}/weechat_plugin_api.en.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_completions.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_config_priority.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_hdata.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infolists.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos_hashtable.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_plugins_priority.en.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_url_options.en.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_plugin_api.en.html" ) diff --git a/doc/fr/CMakeLists.txt b/doc/fr/CMakeLists.txt index a21e8bc01..8e0912145 100644 --- a/doc/fr/CMakeLists.txt +++ b/doc/fr/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.fr.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.fr.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.fr.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.fr.html" ) @@ -74,6 +78,14 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/../docinfo.html ${CMAKE_CURRENT_SOURCE_DIR}/weechat_plugin_api.fr.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_completions.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_config_priority.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_hdata.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infolists.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos_hashtable.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_plugins_priority.fr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_url_options.fr.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_plugin_api.fr.html" ) diff --git a/doc/it/CMakeLists.txt b/doc/it/CMakeLists.txt index 8e50bc705..2892ee5b2 100644 --- a/doc/it/CMakeLists.txt +++ b/doc/it/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.it.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.it.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.it.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.it.html" ) @@ -74,6 +78,14 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/../docinfo.html ${CMAKE_CURRENT_SOURCE_DIR}/weechat_plugin_api.it.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_completions.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_config_priority.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_hdata.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infolists.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos_hashtable.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_plugins_priority.it.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_url_options.it.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_plugin_api.it.html" ) diff --git a/doc/ja/CMakeLists.txt b/doc/ja/CMakeLists.txt index d10b62801..b9db7cfb2 100644 --- a/doc/ja/CMakeLists.txt +++ b/doc/ja/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.ja.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.ja.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.ja.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.ja.html" ) @@ -74,6 +78,14 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/../docinfo.html ${CMAKE_CURRENT_SOURCE_DIR}/weechat_plugin_api.ja.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_completions.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_config_priority.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_hdata.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infolists.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos_hashtable.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_plugins_priority.ja.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_url_options.ja.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_plugin_api.ja.html" ) diff --git a/doc/pl/CMakeLists.txt b/doc/pl/CMakeLists.txt index b452a8720..18284ffc0 100644 --- a/doc/pl/CMakeLists.txt +++ b/doc/pl/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.pl.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.pl.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.pl.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.pl.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.pl.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.pl.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.pl.html" ) diff --git a/doc/sr/CMakeLists.txt b/doc/sr/CMakeLists.txt index 5f1aab463..57efa4347 100644 --- a/doc/sr/CMakeLists.txt +++ b/doc/sr/CMakeLists.txt @@ -60,6 +60,10 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/weechat_user.sr.adoc ${CMAKE_CURRENT_SOURCE_DIR}/includes/cmdline_options.sr.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_commands.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_default_aliases.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_irc_colors.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_user_options.sr.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_user.sr.html" ) @@ -74,6 +78,14 @@ if(ENABLE_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/../docinfo.html ${CMAKE_CURRENT_SOURCE_DIR}/weechat_plugin_api.sr.adoc doc-autogen + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_completions.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_config_priority.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_hdata.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infolists.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_infos_hashtable.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_plugins_priority.sr.adoc + ${CMAKE_CURRENT_BINARY_DIR}/../autogen/autogen_api_url_options.sr.adoc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building weechat_plugin_api.sr.html" ) diff --git a/src/core/wee-doc.c b/src/core/wee-doc.c index fa1e3ac28..8e83b13c0 100644 --- a/src/core/wee-doc.c +++ b/src/core/wee-doc.c @@ -23,16 +23,19 @@ #include "config.h" #endif +#include #include #include #include #include #include +#include #include "weechat.h" #include "wee-arraylist.h" #include "wee-command.h" #include "wee-config-file.h" +#include "wee-crypto.h" #include "wee-dir.h" #include "wee-hashtable.h" #include "wee-hdata.h" @@ -89,12 +92,9 @@ doc_gen_open_file (const char *path, const char *doc, const char *name, FILE *file; snprintf (filename, sizeof (filename), - "%s%s" "autogen_%s_%s.%s.adoc", + "%s%s" "autogen_%s_%s.%s.adoc.temp", path, DIR_SEPARATOR, doc, name, lang); - if (weechat_debug_core >= 1) - printf ("Writing: %s\n", filename); - file = fopen (filename, "wb"); if (!file) { @@ -115,6 +115,54 @@ doc_gen_open_file (const char *path, const char *doc, const char *name, return file; } +/* + * Closes the file and renames it without ".temp" suffix, if the target name + * does not exist of if it exists with a different (obsolete) content. + * + * If the target name exists with same content it's kept as-is (so the + * timestamp does not change) and the temporary file is just deleted. + * + * Returns: + * 1: target file has been updated + * 0: target file unchanged + * -1: error + */ + +int +doc_gen_close_file (const char *path, const char *doc, const char *name, + const char *lang, FILE *file) +{ + char filename_temp[PATH_MAX], filename[PATH_MAX]; + char hash_temp[512 / 8], hash[512 / 8]; + int rc_temp, rc; + + fclose (file); + + snprintf (filename_temp, sizeof (filename_temp), + "%s%s" "autogen_%s_%s.%s.adoc.temp", + path, DIR_SEPARATOR, doc, name, lang); + + snprintf (filename, sizeof (filename), + "%s%s" "autogen_%s_%s.%s.adoc", + path, DIR_SEPARATOR, doc, name, lang); + + rc_temp = weecrypto_hash_file (filename_temp, GCRY_MD_SHA512, + &hash_temp, NULL); + if (!rc_temp) + return -1; + + rc = weecrypto_hash_file (filename, GCRY_MD_SHA512, &hash, NULL); + + if (!rc || (memcmp (hash_temp, hash, sizeof (hash)) != 0)) + { + rename (filename_temp, filename); + return 1; + } + + unlink (filename_temp); + return 0; +} + /* * Checks if a command must be documented or not. * @@ -169,8 +217,9 @@ doc_gen_hook_command_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with commands. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -185,7 +234,7 @@ doc_gen_user_commands (const char *path, const char *lang) file = doc_gen_open_file (path, "user", "commands", lang); if (!file) - return 0; + return -1; list_hooks = arraylist_new (64, 1, 0, &doc_gen_hook_command_cmp_cb, NULL, @@ -306,9 +355,7 @@ doc_gen_user_commands (const char *path, const char *lang) arraylist_free (list_hooks); - fclose (file); - - return 1; + return doc_gen_close_file (path, "user", "commands", lang, file); } /* @@ -374,8 +421,9 @@ doc_gen_option_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with commands. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -392,7 +440,7 @@ doc_gen_user_options (const char *path, const char *lang) file = doc_gen_open_file (path, "user", "options", lang); if (!file) - return 0; + return -1; list_options = arraylist_new (64, 1, 0, &doc_gen_option_cmp_cb, NULL, @@ -537,17 +585,16 @@ doc_gen_user_options (const char *path, const char *lang) arraylist_free (list_options); - fclose (file); - - return 1; + return doc_gen_close_file (path, "user", "options", lang, file); } /* * Generates files with default aliases. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -559,7 +606,7 @@ doc_gen_user_default_aliases (const char *path, const char *lang) file = doc_gen_open_file (path, "user", "default_aliases", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -589,17 +636,16 @@ doc_gen_user_default_aliases (const char *path, const char *lang) "|===\n" "// end::default_aliases[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "user", "default_aliases", lang, file); } /* * Generates files with IRC colors. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -610,7 +656,7 @@ doc_gen_user_irc_colors (const char *path, const char *lang) file = doc_gen_open_file (path, "user", "irc_colors", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -637,9 +683,7 @@ doc_gen_user_irc_colors (const char *path, const char *lang) "|===\n" "// end::irc_colors[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "user", "irc_colors", lang, file); } /* @@ -672,8 +716,9 @@ doc_gen_hook_info_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with infos. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -686,7 +731,7 @@ doc_gen_api_infos (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "infos", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -727,9 +772,7 @@ doc_gen_api_infos (const char *path, const char *lang) "|===\n" "// end::infos[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "infos", lang, file); } /* @@ -762,8 +805,9 @@ doc_gen_hook_info_hashtable_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with infos_hashtable. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -776,7 +820,7 @@ doc_gen_api_infos_hashtable (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "infos_hashtable", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -819,9 +863,7 @@ doc_gen_api_infos_hashtable (const char *path, const char *lang) "|===\n" "// end::infos_hashtable[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "infos_hashtable", lang, file); } /* @@ -854,8 +896,9 @@ doc_gen_hook_infolist_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with infolists. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -868,7 +911,7 @@ doc_gen_api_infolists (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "infolists", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -911,9 +954,7 @@ doc_gen_api_infolists (const char *path, const char *lang) "|===\n" "// end::infolists[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "infolists", lang, file); } /* @@ -1141,8 +1182,9 @@ doc_gen_api_hdata_content (FILE *file, struct t_hdata *hdata) * Generates files with hdata. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -1157,7 +1199,7 @@ doc_gen_api_hdata (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "hdata", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -1211,9 +1253,7 @@ doc_gen_api_hdata (const char *path, const char *lang) "|===\n" "// end::hdata[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "hdata", lang, file); } /* @@ -1246,8 +1286,9 @@ doc_gen_hook_completion_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with completions. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -1260,7 +1301,7 @@ doc_gen_api_completions (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "completions", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -1299,17 +1340,16 @@ doc_gen_api_completions (const char *path, const char *lang) "|===\n" "// end::completions[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "completions", lang, file); } /* * Generates files with URL options. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -1321,7 +1361,7 @@ doc_gen_api_url_options (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "url_options", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -1364,9 +1404,7 @@ doc_gen_api_url_options (const char *path, const char *lang) "|===\n" "// end::url_options[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "url_options", lang, file); } /* @@ -1397,8 +1435,9 @@ doc_gen_plugin_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with plugins priority. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -1411,7 +1450,7 @@ doc_gen_api_plugins_priority (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "plugins_priority", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -1451,9 +1490,7 @@ doc_gen_api_plugins_priority (const char *path, const char *lang) "|===\n" "// end::plugins_priority[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "plugins_priority", lang, file); } /* @@ -1484,8 +1521,9 @@ doc_gen_config_cmp_cb (void *data, struct t_arraylist *arraylist, * Generates files with config priority. * * Returns: - * 1: OK - * 0: error + * 1: OK, target file updated + * 0: OK, target file unchanged + * -1: error */ int @@ -1498,7 +1536,7 @@ doc_gen_api_config_priority (const char *path, const char *lang) file = doc_gen_open_file (path, "api", "config_priority", lang); if (!file) - return 0; + return -1; string_fprintf ( file, @@ -1538,9 +1576,7 @@ doc_gen_api_config_priority (const char *path, const char *lang) "|===\n" "// end::config_priority[]\n"); - fclose (file); - - return 1; + return doc_gen_close_file (path, "api", "config_priority", lang, file); } /* @@ -1622,14 +1658,16 @@ doc_generate (const char *path) for (j = 0; doc_gen_functions[j]; j++) { rc = (int) (doc_gen_functions[j] (path, lang)); - if (!rc) + if (rc < 0) goto end; - num_files++; + num_files += rc; } } - printf ("doc generator: build OK: %d files written in %s\n", - num_files, path); + if (num_files > 0) + printf ("doc generator: OK, %d files updated\n", num_files); + else + printf ("doc generator: OK, no changes\n"); rc_doc_gen = 1;