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:
@ -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
|
||||
#
|
||||
|
Reference in New Issue
Block a user