@cryptotaxi247 / netdata-1 / commits / dd17442f8

[Integrations Docs] Add a badge for either netdata or community maintained (#16073)

Fotis Voutsas committed Sep 29, 2023 at 13:48 UTC dd17442f81ca4bbb97c5b93c7a5525ce4946fbb1
1 file changed +23 -11
integrations/gen_docs_integrations.py
+23 -11
@@ -223,7 +223,12 @@ endmeta-->
223 except Exception as e:
224 print("Exception in notification md construction", e, integration['id'])
225
226 - return meta_yaml, sidebar_label, learn_rel_path, md
226 + if "community" in integration['meta'].keys():
227 + community = "<img src=\"https://img.shields.io/badge/maintained%20by-Community-blue\" />"
228 + else:
229 + community = "<img src=\"https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44\" />"
230 +
231 + return meta_yaml, sidebar_label, learn_rel_path, md, community
232
233
234 def build_path(meta_yaml_link):
@@ -236,10 +241,15 @@ def build_path(meta_yaml_link):
241 .replace("/metadata.yaml", "")
242
243
239 -def write_to_file(path, md, meta_yaml, sidebar_label, mode='default'):
244 +def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default'):
245 """
246 takes the arguments needed to write the integration markdown to the proper file.
247 """
248 +
249 + upper, lower = md.split("##", 1)
250 +
251 + md = upper + community + f"\n\n##{lower}"
252 +
253 if mode == 'default':
254 # Only if the path exists, this caters for running the same script on both the go and netdata repos.
255 if Path(path).exists():
@@ -251,7 +261,7 @@ def write_to_file(path, md, meta_yaml, sidebar_label, mode='default'):
261 clean_and_write(
262 md,
263 Path(f'{path}/integrations/{clean_string(sidebar_label)}.md')
254 - )
264 + )
265
266 except FileNotFoundError as e:
267 print("Exception in writing to file", e)
@@ -287,12 +297,12 @@ def write_to_file(path, md, meta_yaml, sidebar_label, mode='default'):
297 md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='agent-notifications')
298
299 finalpath = f'{path}/README.md'
290 -
300 +
301 try:
302 clean_and_write(
303 md,
304 Path(finalpath)
295 - )
305 + )
306
307 except FileNotFoundError as e:
308 print("Exception in writing to file", e)
@@ -327,25 +337,27 @@ for integration in integrations:
337
338 if integration['integration_type'] == "collector":
339
330 - meta_yaml, sidebar_label, learn_rel_path, md = build_readme_from_integration(integration, mode='collector')
340 + meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
341 + integration, mode='collector')
342 path = build_path(meta_yaml)
332 - write_to_file(path, md, meta_yaml, sidebar_label)
343 + write_to_file(path, md, meta_yaml, sidebar_label, community)
344
345 elif not am_i_inside_go:
346 # kind of specific if clause, so we can avoid running excessive code in the go repo
347 if integration['integration_type'] == "exporter":
348
338 - meta_yaml, sidebar_label, learn_rel_path, md = build_readme_from_integration(integration, mode='exporter')
349 + meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
350 + integration, mode='exporter')
351 path = build_path(meta_yaml)
340 - write_to_file(path, md, meta_yaml, sidebar_label)
352 + write_to_file(path, md, meta_yaml, sidebar_label, community)
353
354 # kind of specific if clause, so we can avoid running excessive code in the go repo
355 elif integration['integration_type'] == "notification":
356
345 - meta_yaml, sidebar_label, learn_rel_path, md = build_readme_from_integration(
357 + meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
358 integration, mode='notification')
359 path = build_path(meta_yaml)
348 - write_to_file(path, md, meta_yaml, sidebar_label, mode='notification')
360 + write_to_file(path, md, meta_yaml, sidebar_label, community, mode='notification')
361
362
363 make_symlinks(symlink_dict)