Add icons to integrations markdown files (#16169)
Fotis Voutsas committed
Oct 13, 2023 at 10:07 UTC
141647b2913a943ee6b25e9472a043417a51dd80
1 file changed
+26
-6
integrations/gen_docs_integrations.py
+26
-6
@@ -1,6 +1,7 @@
1
import json
2
import shutil
3
from pathlib import Path
4
+import re
5
6
# Dictionary responsible for making the symbolic links at the end of the script's run.
7
symlink_dict = {}
@@ -116,6 +117,25 @@ def read_integrations_js(path_to_file):
117
print("Exception", e)
118
119
120
+def create_overview(integration, filename):
121
+
122
+ split = re.split(r'(#.*\n)', integration['overview'], 1)
123
+
124
+ first_overview_part = split[1]
125
+ rest_overview_part = split[2]
126
+
127
+ if len(filename) > 0:
128
+ return f"""{first_overview_part}
129
+
130
+<img src="https://netdata.cloud/img/{filename}" width="150"/>
131
+
132
+{rest_overview_part}
133
+"""
134
+ else:
135
+ return f"""{first_overview_part}{rest_overview_part}
136
+"""
137
+
138
+
139
def build_readme_from_integration(integration, mode=''):
140
# COLLECTORS
141
if mode == 'collector':
@@ -127,6 +147,7 @@ def build_readme_from_integration(integration, mode=''):
147
learn_rel_path = generate_category_from_name(
148
integration['meta']['monitored_instance']['categories'][0].split("."), categories)
149
# build the markdown string
150
+
151
md = \
152
f"""<!--startmeta
153
meta_yaml: "{meta_yaml}"
@@ -136,8 +157,7 @@ learn_rel_path: "{learn_rel_path}"
157
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
158
endmeta-->
159
139
-{integration['overview']}
140
-"""
160
+{create_overview(integration, integration['meta']['monitored_instance']['icon_filename'])}"""
161
162
if integration['metrics']:
163
md += f"""
@@ -168,6 +188,7 @@ endmeta-->
188
meta_yaml = integration['edit_link'].replace("blob", "edit")
189
sidebar_label = integration['meta']['name']
190
learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
191
+
192
# build the markdown string
193
md = \
194
f"""<!--startmeta
@@ -178,8 +199,7 @@ learn_rel_path: "Exporting"
199
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE EXPORTER'S metadata.yaml FILE"
200
endmeta-->
201
181
-{integration['overview']}
182
-"""
202
+{create_overview(integration, integration['meta']['icon_filename'])}"""
203
204
if integration['setup']:
205
md += f"""
@@ -200,6 +220,7 @@ endmeta-->
220
meta_yaml = integration['edit_link'].replace("blob", "edit")
221
sidebar_label = integration['meta']['name']
222
learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
223
+
224
# build the markdown string
225
md = \
226
f"""<!--startmeta
@@ -210,8 +231,7 @@ learn_rel_path: "{learn_rel_path.replace("notifications", "Alerting/Notification
231
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
232
endmeta-->
233
213
-{integration['overview']}
214
-"""
234
+{create_overview(integration, integration['meta']['icon_filename'])}"""
235
236
if integration['setup']:
237
md += f"""