2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-23 23:30:54 +00:00

Build order rules ()

* Add new global setting

* Check if there are open children before completing a build

* Adds management command to export settings definition

* Fix settings export

* Extract settings data into documentation

* Add global settings spec

* User settings

* Revert strict mode

* Tweak unit test

* Remove unreachable code

* Always export settings first

* Remove unused macro

* Remove old images

* Re-add missing docs strings

* Tweak docs

* Remove unused import
This commit is contained in:
Oliver
2024-08-10 09:26:03 +10:00
committed by GitHub
parent 556a3161e8
commit 42183a3a3f
20 changed files with 375 additions and 158 deletions

@ -1,5 +1,6 @@
"""Main entry point for the documentation build process."""
import json
import os
import subprocess
import textwrap
@ -7,6 +8,20 @@ import textwrap
import requests
import yaml
# Cached settings dict values
global GLOBAL_SETTINGS
global USER_SETTINGS
# Read in the InvenTree settings file
here = os.path.dirname(__file__)
settings_file = os.path.join(here, 'inventree_settings.json')
with open(settings_file, 'r') as sf:
settings = json.load(sf)
GLOBAL_SETTINGS = settings['global']
USER_SETTINGS = settings['user']
def get_repo_url(raw=False):
"""Return the repository URL for the current project."""
@ -219,3 +234,37 @@ def define_env(env):
)
return includefile(fn, f'Template: {base}', format='html')
@env.macro
def rendersetting(setting: dict):
"""Render a provided setting object into a table row."""
name = setting['name']
description = setting['description']
default = setting.get('default', None)
units = setting.get('units', None)
return f'| {name} | {description} | {default if default is not None else ""} | {units if units is not None else ""} |'
@env.macro
def globalsetting(key: str):
"""Extract information on a particular global setting.
Arguments:
- key: The name of the global setting to extract information for.
"""
global GLOBAL_SETTINGS
setting = GLOBAL_SETTINGS[key]
return rendersetting(setting)
@env.macro
def usersetting(key: str):
"""Extract information on a particular user setting.
Arguments:
- key: The name of the user setting to extract information for.
"""
global USER_SETTINGS
setting = USER_SETTINGS[key]
return rendersetting(setting)