I am using mkdocs system which is configured using yaml file, parsed via PyYml. I want to be able to specificy environment variable in its mkdocs.yml
which is not possible in mkdocs ecosystem, but workaround exists using PyYml special !!python/object/apply:os.getenv
syntax which works great for yaml keys of type string.
However, this doesn't work:
plugins:
- search
- pdf-export:
combined: !!python/object/apply:os.getenv ["PDF_EXPORT_COMBINED"]
The build complains that string is not bool value:
PS> $Env:PDF_EXPORT_COMBINED='true'
PS> mkdocs build
...
ERROR - Config value: 'plugins'. Error: Plugin value: 'combined'.
Expected type: <class 'bool'> but received: <class 'str'>
I looked into PyYAML section YAML tags and Python types^1 to no avail. I guess form:
!python/object/apply:module.f | value of f(...)
could be used as I need pythons distutils.util.strtobool( os.getenv("PDF_EXPORT_COMBINED") )
but not sure if that is possible using that syntax.