From 329795753d65ff976b057907b5986fdb2aa70104 Mon Sep 17 00:00:00 2001 From: Nicolas Ruflin Date: Wed, 7 Dec 2016 16:23:03 +0100 Subject: [PATCH] Auto generate modules list (#3131) This is to ensure no modules are forgotten in the future --- metricbeat/docs/modules.asciidoc | 23 +------------------- metricbeat/docs/modules_list.asciidoc | 30 +++++++++++++++++++++++++++ metricbeat/scripts/docs_collector.py | 17 +++++++++++++++ 3 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 metricbeat/docs/modules_list.asciidoc diff --git a/metricbeat/docs/modules.asciidoc b/metricbeat/docs/modules.asciidoc index d2e7d8eeaad2..ea572984ff3a 100644 --- a/metricbeat/docs/modules.asciidoc +++ b/metricbeat/docs/modules.asciidoc @@ -7,28 +7,7 @@ This section contains detailed information about the metric collecting modules contained in {beatname_uc}. Each module contains one or multiple metricsets. More details about each module can be found under the links below. - * <> - * <> - * <> - * <> - * <> - * <> - * <> - * <> - * <> - * <> +include::modules_list.asciidoc[] --- - -include::modules/apache.asciidoc[] -include::modules/docker.asciidoc[] -include::modules/haproxy.asciidoc[] -include::modules/mongodb.asciidoc[] -include::modules/mysql.asciidoc[] -include::modules/nginx.asciidoc[] -include::modules/postgresql.asciidoc[] -include::modules/redis.asciidoc[] -include::modules/system.asciidoc[] -include::modules/zookeeper.asciidoc[] diff --git a/metricbeat/docs/modules_list.asciidoc b/metricbeat/docs/modules_list.asciidoc new file mode 100644 index 000000000000..e4e2e8a4a81d --- /dev/null +++ b/metricbeat/docs/modules_list.asciidoc @@ -0,0 +1,30 @@ +//// +This file is generated! See scripts/docs_collector.py +//// + + * <> + * <> + * <> + * <> + * <> + * <> + * <> + * <> + * <> + * <> + * <> + + +-- + +include::modules/apache.asciidoc[] +include::modules/docker.asciidoc[] +include::modules/haproxy.asciidoc[] +include::modules/kafka.asciidoc[] +include::modules/mongodb.asciidoc[] +include::modules/mysql.asciidoc[] +include::modules/nginx.asciidoc[] +include::modules/postgresql.asciidoc[] +include::modules/redis.asciidoc[] +include::modules/system.asciidoc[] +include::modules/zookeeper.asciidoc[] diff --git a/metricbeat/scripts/docs_collector.py b/metricbeat/scripts/docs_collector.py index 544148f70c61..9fb16991afb5 100644 --- a/metricbeat/scripts/docs_collector.py +++ b/metricbeat/scripts/docs_collector.py @@ -16,6 +16,8 @@ def collect(beat_name): """ + modules_list = {} + # Iterate over all modules for module in sorted(os.listdir(base_dir)): @@ -41,6 +43,8 @@ def collect(beat_name): fields = yaml.load(f.read()) title = fields[0]["title"] + modules_list[module] = title + config_file = beat_path + "/config.yml" # Add example config file @@ -131,6 +135,19 @@ def collect(beat_name): with open(os.path.abspath("docs") + "/modules/" + module + ".asciidoc", 'w') as f: f.write(module_file) + module_list_output = generated_note + for m, title in sorted(modules_list.iteritems()): + module_list_output += " * <>\n" + + module_list_output += "\n\n--\n\n" + for m, title in sorted(modules_list.iteritems()): + module_list_output += "include::modules/"+ m + ".asciidoc[]\n" + + # Write module link list + with open(os.path.abspath("docs") + "/modules_list.asciidoc", 'w') as f: + f.write(module_list_output) + + if __name__ == "__main__": parser = argparse.ArgumentParser( description="Collects modules docs")