2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 19:15:41 +00:00

feat(backend): improve tag docs (#8960)

* add admindocs

* add tag export command

* add filter export

* switch to yaml

* upload meta info to artifacts

* format workflow file

* fix creation command

* keep all artifacts in schema repo

* fix namespace

* use one command for export

* include tags and filters in docs

* change default filename

* fix call

* fix itteration syntax

* clean up rendering

* fix formatting

* simple escape
This commit is contained in:
Matthias Mair
2025-01-27 23:42:13 +01:00
committed by GitHub
parent 16b03a7371
commit f7f6e27c6e
11 changed files with 216 additions and 9 deletions

View File

@ -512,3 +512,9 @@ A [Part Parameter](../part/parameter.md) has the following available attributes:
| Data | The *value* of the parameter (e.g. "123.4") |
| Units | The *units* of the parameter (e.g. "km") |
| Template | A reference to a [PartParameterTemplate](../part/parameter.md#parameter-templates) |
## List of tags and filters
The following tags and filters are available.
{{ tags_and_filters() }}

View File

@ -31,6 +31,8 @@ for key in [
# Cached settings dict values
global GLOBAL_SETTINGS
global USER_SETTINGS
global TAGS
global FILTERS
# Read in the InvenTree settings file
here = os.path.dirname(__file__)
@ -42,6 +44,13 @@ with open(settings_file, encoding='utf-8') as sf:
GLOBAL_SETTINGS = settings['global']
USER_SETTINGS = settings['user']
# Tags
with open(os.path.join(here, 'inventree_tags.yml'), encoding='utf-8') as f:
TAGS = yaml.load(f, yaml.BaseLoader)
# Filters
with open(os.path.join(here, 'inventree_filters.yml'), encoding='utf-8') as f:
FILTERS = yaml.load(f, yaml.BaseLoader)
def get_repo_url(raw=False):
"""Return the repository URL for the current project."""
@ -303,3 +312,25 @@ def define_env(env):
setting = USER_SETTINGS[key]
return rendersetting(key, setting)
@env.macro
def tags_and_filters():
"""Return a list of all tags and filters."""
global TAGS
global FILTERS
ret_data = ''
for ref in [['Tags', TAGS], ['Filters', FILTERS]]:
ret_data += f'### {ref[0]}\n\n| Namespace | Name | Description |\n| --- | --- | --- |\n'
for value in ref[1]:
title = (
value['title']
.replace('\n', ' ')
.replace('<', '&lt;')
.replace('>', '&gt;')
)
ret_data += f'| {value["library"]} | {value["name"]} | {title} |\n'
ret_data += '\n'
ret_data += '\n'
return ret_data