Files
scylladb/docs/_ext/scylladb_include_flag.py
David Garcia f555a2cb05 docs: dynamic include based on flag
docs: extend include options

Closes scylladb/scylladb#16753
2024-01-17 09:33:40 +02:00

26 lines
805 B
Python

from sphinx.directives.other import Include
from docutils.parsers.rst import directives
class IncludeFlagDirective(Include):
option_spec = Include.option_spec.copy()
option_spec['base_path'] = directives.unchanged
def run(self):
env = self.state.document.settings.env
base_path = self.options.get('base_path', '_common')
if env.app.tags.has('enterprise'):
self.arguments[0] = base_path + "_enterprise/" + self.arguments[0]
else:
self.arguments[0] = base_path + "/" + self.arguments[0]
return super().run()
def setup(app):
app.add_directive('scylladb_include_flag', IncludeFlagDirective, override=True)
return {
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}