doc: _extensions: :zephyr-app:'s should be valid paths

Add a check so that we hopefuly keep all zephyr-app-commands free of
references to non-existing paths.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2024-09-05 17:58:22 +02:00 committed by Anas Nashif
parent 25fa25a5a9
commit dcd91a92bc

View File

@ -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']