diff --git a/docs/_ext/scylladb_include_flag.py b/docs/_ext/scylladb_include_flag.py new file mode 100644 index 0000000000..4bd429cee1 --- /dev/null +++ b/docs/_ext/scylladb_include_flag.py @@ -0,0 +1,25 @@ +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, + } diff --git a/docs/conf.py b/docs/conf.py index db8ee72483..517749fcfb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,7 +39,8 @@ extensions = [ "sphinx_scylladb_markdown", "sphinxcontrib.datatemplates", "scylladb_cc_properties", - "scylladb_aws_images" + "scylladb_aws_images", + "scylladb_include_flag" ] # The suffix(es) of source filenames.