Skip to content

Commit

Permalink
Docs updates: (#8951)
Browse files Browse the repository at this point in the history
* Docs updates:

- Fix error related to key access
- Fix rendering of settings tables
- Add setting key as mouseover text

* Revert config
  • Loading branch information
SchrodingersGat authored Jan 26, 2025
1 parent ab7e638 commit 640d585
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/docs/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def on_config(config, *args, **kwargs):
# fetch_rtd_versions()

if rtd:
rtd_version = os.environ['READTHEDOCS_VERSION']
rtd_language = os.environ['READTHEDOCS_LANGUAGE']
rtd_version = os.environ.get('READTHEDOCS_VERSION')
rtd_language = os.environ.get('READTHEDOCS_LANGUAGE')

site_url = f'https://docs.inventree.org/{rtd_language}/{rtd_version}'
assets_dir = f'/{rtd_language}/{rtd_version}/assets'
Expand Down
15 changes: 10 additions & 5 deletions docs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'READTHEDOCS_VERSION_NAME',
'READTHEDOCS_VERSION_TYPE',
]:
val = os.environ.get(key) or '-- MISSING --'
val = os.environ.get(key, None) or '-- MISSING --'
print(f' - {key}: {val}')

# Cached settings dict values
Expand Down Expand Up @@ -266,14 +266,19 @@ def templatefile(filename):
return includefile(fn, f'Template: {base}', fmt='html')

@env.macro
def rendersetting(setting: dict):
def rendersetting(key: str, setting: dict):
"""Render a provided setting object into a table row."""
name = setting['name']
description = setting['description']
default = setting.get('default')
units = setting.get('units')

return f'| {name} | {description} | {default if default is not None else ""} | {units if units is not None else ""} |'
default = f'`{default}`' if default else ''
units = f'`{units}`' if units else ''

return (
f'| <div title="{key}">{name}</div> | {description} | {default} | {units} |'
)

@env.macro
def globalsetting(key: str):
Expand All @@ -285,7 +290,7 @@ def globalsetting(key: str):
global GLOBAL_SETTINGS
setting = GLOBAL_SETTINGS[key]

return rendersetting(setting)
return rendersetting(key, setting)

@env.macro
def usersetting(key: str):
Expand All @@ -297,4 +302,4 @@ def usersetting(key: str):
global USER_SETTINGS
setting = USER_SETTINGS[key]

return rendersetting(setting)
return rendersetting(key, setting)

0 comments on commit 640d585

Please sign in to comment.