Skip to content

Commit

Permalink
docs: improve include flag directive
Browse files Browse the repository at this point in the history
The include flag directive now treats missing content as info logs instead of warnings. This prevents build failures when the enterprise-specific content isn't yet available.

If the enterprise content is undefined, the directive automatically loads the open-source content. This ensures the end user has access to some content.

address comments

Closes scylladb#19804
  • Loading branch information
dgarcia360 authored and denesb committed Aug 20, 2024
1 parent 9a10c33 commit fea7070
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions docs/_ext/scylladb_include_flag.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import os
from sphinx.directives.other import Include
from sphinx.util import logging
from docutils.parsers.rst import directives

LOGGER = logging.getLogger(__name__)

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')
file_path = self.arguments[0]

if env.app.tags.has('enterprise'):
self.arguments[0] = base_path + "_enterprise/" + self.arguments[0]
enterprise_path = os.path.join(base_path + "_enterprise", file_path)
_, enterprise_abs_path = env.relfn2path(enterprise_path)
if os.path.exists(enterprise_abs_path):
self.arguments[0] = enterprise_path
else:
LOGGER.info(f"Enterprise content not found: Skipping inclusion of {file_path}")
return []
else:
self.arguments[0] = base_path + "/" + self.arguments[0]
self.arguments[0] = os.path.join(base_path, file_path)
return super().run()

def setup(app):
Expand Down

0 comments on commit fea7070

Please sign in to comment.