diff --git a/doc/_extensions/zephyr/application.py b/doc/_extensions/zephyr/application.py index d6f9a62b5bc..88d2f8fc333 100644 --- a/doc/_extensions/zephyr/application.py +++ b/doc/_extensions/zephyr/application.py @@ -7,8 +7,11 @@ from docutils import nodes from docutils.parsers.rst import Directive from docutils.parsers.rst import directives +from pathlib import Path +ZEPHYR_BASE = Path(__file__).parents[3] + # TODO: extend and modify this for Windows. # # This could be as simple as generating a couple of sets of instructions, one @@ -186,6 +189,16 @@ class ZephyrAppCommandsDirective(Directive): if compact and skip_config: raise self.error('Both compact and maybe-skip-config options were given.') + if zephyr_app: + # as folks might use "<...>" notation to indicate a variable portion of the path, we + # deliberately don't check for the validity of such paths. + if not any([x in zephyr_app for x in ["<", ">"]]): + app_path = ZEPHYR_BASE / zephyr_app + if not app_path.is_dir(): + raise self.error( + f"zephyr-app: {zephyr_app} is not a valid folder in the zephyr tree." + ) + app = app or zephyr_app in_tree = self.IN_TREE_STR if zephyr_app else None # Allow build directories which are nested. @@ -262,7 +275,6 @@ class ZephyrAppCommandsDirective(Directive): literal['language'] = 'shell' return literal - def _generate_west(self, **kwargs): content = [] generator = kwargs['generator']