1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce get_docs() template filter for models

This commit is contained in:
Jeremy Stretch
2020-03-05 13:52:34 -05:00
parent 8a23811831
commit defe59d79e

View File

@ -216,6 +216,20 @@ def percentage(x, y):
return round(x / y * 100)
@register.filter()
def get_docs(model):
"""
Render and return documentation for the specified model.
"""
path = '../docs/models/{}/{}.md'.format(model._meta.app_label, model._meta.model_name)
with open(path) as docfile:
content = docfile.read()
content = markdown(content, extensions=['mdx_gfm'])
return mark_safe(content)
#
# Tags
#