2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-06-13 18:55:26 +00:00

Add custom hooks

This commit is contained in:
Oliver
2021-10-11 17:58:27 +11:00
parent 606cff7404
commit 173e73eb72
4 changed files with 61 additions and 0 deletions

55
docs/hooks.py Normal file
View File

@ -0,0 +1,55 @@
"""
Custom mkdocs hooks, using the mkdocs-simple-hooks plugin
"""
import os
def on_config(config, *args, **kwargs):
"""
Hosting multiple versions of the documenation on readthedocs.io is complex,
as the required interactions between rtd and mkdocs do not exist.
We want to be able to provide a *dynamic* config.site_url parameter to mkdocs,
which tells it the base url, e.g.
- https://readthedocs.io/en/latest
- https://readthedocs.io/de/0.5.1
Further, we need to know if we are building on readthedocs at all!
readthedocs provides some environment variables:
- https://docs.readthedocs.io/en/stable/builds.html#build-environment
We can use these to determine (at run time) where we are hosting
"""
rtd = os.environ.get('READTHEDOCS', False)
if not rtd:
print("'READTHEDOCS' environment variable not found")
print("Building for localhost configuration!")
else:
rtd_version = os.environ['READTHEDOCS_VERSION']
rtd_language = os.environ['READTHEDOCS_LANGUAGE']
url = f"https://inventree.readthedocs.io/{rtd_language}/{rtd_version}"
config['site_url'] = url
return config
def my_cfg(config, *args, **kwargs):
# print(config.keys())
for k in config.keys():
print(f"- {k}")
print(config['site_url'])
return config

View File

@ -4,6 +4,8 @@ title: Parts
## Part
<b>config.site_url:</b> {{ config.site_url }}
The *Part* is the core element of the InvenTree ecosystem. A Part object is the archetype of any stock item in your inventory. Parts are arranged in heirarchical categories which are used to organise and filter parts by function.
## Part Category