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:
@ -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() }}
|
||||
|
31
docs/main.py
31
docs/main.py
@ -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('<', '<')
|
||||
.replace('>', '>')
|
||||
)
|
||||
ret_data += f'| {value["library"]} | {value["name"]} | {title} |\n'
|
||||
ret_data += '\n'
|
||||
ret_data += '\n'
|
||||
|
||||
return ret_data
|
||||
|
Reference in New Issue
Block a user