mirror of
https://github.com/netdata/netdata.git
synced 2025-04-17 03:02:41 +00:00
Add icons to integrations markdown files (#16169)
This commit is contained in:
parent
07635ec614
commit
141647b291
1 changed files with 26 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
# Dictionary responsible for making the symbolic links at the end of the script's run.
|
||||
symlink_dict = {}
|
||||
|
@ -116,6 +117,25 @@ def read_integrations_js(path_to_file):
|
|||
print("Exception", e)
|
||||
|
||||
|
||||
def create_overview(integration, filename):
|
||||
|
||||
split = re.split(r'(#.*\n)', integration['overview'], 1)
|
||||
|
||||
first_overview_part = split[1]
|
||||
rest_overview_part = split[2]
|
||||
|
||||
if len(filename) > 0:
|
||||
return f"""{first_overview_part}
|
||||
|
||||
<img src="https://netdata.cloud/img/{filename}" width="150"/>
|
||||
|
||||
{rest_overview_part}
|
||||
"""
|
||||
else:
|
||||
return f"""{first_overview_part}{rest_overview_part}
|
||||
"""
|
||||
|
||||
|
||||
def build_readme_from_integration(integration, mode=''):
|
||||
# COLLECTORS
|
||||
if mode == 'collector':
|
||||
|
@ -127,6 +147,7 @@ def build_readme_from_integration(integration, mode=''):
|
|||
learn_rel_path = generate_category_from_name(
|
||||
integration['meta']['monitored_instance']['categories'][0].split("."), categories)
|
||||
# build the markdown string
|
||||
|
||||
md = \
|
||||
f"""<!--startmeta
|
||||
meta_yaml: "{meta_yaml}"
|
||||
|
@ -136,8 +157,7 @@ learn_rel_path: "{learn_rel_path}"
|
|||
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
|
||||
endmeta-->
|
||||
|
||||
{integration['overview']}
|
||||
"""
|
||||
{create_overview(integration, integration['meta']['monitored_instance']['icon_filename'])}"""
|
||||
|
||||
if integration['metrics']:
|
||||
md += f"""
|
||||
|
@ -168,6 +188,7 @@ endmeta-->
|
|||
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
||||
sidebar_label = integration['meta']['name']
|
||||
learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
|
||||
|
||||
# build the markdown string
|
||||
md = \
|
||||
f"""<!--startmeta
|
||||
|
@ -178,8 +199,7 @@ learn_rel_path: "Exporting"
|
|||
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE EXPORTER'S metadata.yaml FILE"
|
||||
endmeta-->
|
||||
|
||||
{integration['overview']}
|
||||
"""
|
||||
{create_overview(integration, integration['meta']['icon_filename'])}"""
|
||||
|
||||
if integration['setup']:
|
||||
md += f"""
|
||||
|
@ -200,6 +220,7 @@ endmeta-->
|
|||
meta_yaml = integration['edit_link'].replace("blob", "edit")
|
||||
sidebar_label = integration['meta']['name']
|
||||
learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
|
||||
|
||||
# build the markdown string
|
||||
md = \
|
||||
f"""<!--startmeta
|
||||
|
@ -210,8 +231,7 @@ learn_rel_path: "{learn_rel_path.replace("notifications", "Alerting/Notification
|
|||
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
|
||||
endmeta-->
|
||||
|
||||
{integration['overview']}
|
||||
"""
|
||||
{create_overview(integration, integration['meta']['icon_filename'])}"""
|
||||
|
||||
if integration['setup']:
|
||||
md += f"""
|
||||
|
|
Loading…
Add table
Reference in a new issue