summaryrefslogtreecommitdiffstats
path: root/rtemsspec/sphinxcontent.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-26 09:04:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-04-28 07:18:33 +0200
commitd3b9142a896f710924f47b4c61c19b4201cb9e8f (patch)
treedba18635f9a4210926a85bce32f4fed47ceda9e5 /rtemsspec/sphinxcontent.py
parentspec: Update /rtems/scheduler/* documentation (diff)
downloadrtems-central-d3b9142a896f710924f47b4c61c19b4201cb9e8f.tar.bz2
spec: Allow multiple interface references
Diffstat (limited to 'rtemsspec/sphinxcontent.py')
-rw-r--r--rtemsspec/sphinxcontent.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py
index af555fb0..3ac0a9b9 100644
--- a/rtemsspec/sphinxcontent.py
+++ b/rtemsspec/sphinxcontent.py
@@ -28,7 +28,7 @@ from contextlib import contextmanager
from typing import Any, Iterable, Iterator, List, Optional, Sequence, Union
from rtemsspec.content import Content, make_lines, to_camel_case
-from rtemsspec.items import Item, ItemGetValueContext, ItemMapper
+from rtemsspec.items import Item, ItemGetValue, ItemGetValueContext, ItemMapper
GenericContent = Union[str, List[str], "Content"]
GenericContentIterable = Union[Iterable[str], Iterable[List[str]],
@@ -229,20 +229,22 @@ def _get_value_sphinx_type(ctx: ItemGetValueContext) -> Any:
return f":c:type:`{ctx.value[ctx.key]}`"
-def _get_value_sphinx_url(ctx: ItemGetValueContext) -> Any:
- return f"`{ctx.value[ctx.key]} <{ctx.item['reference']}>`_"
+def _get_value_sphinx_ref(ctx: ItemGetValueContext,
+ get_value: ItemGetValue) -> Any:
+ if "c-user" in ctx.item["references"]:
+ sphinx_ref = ctx.item["references"]["c-user"]
+ return f":ref:`{ctx.value[ctx.key]} <{sphinx_ref}>`"
+ if "url" in ctx.item["references"]:
+ return f"`{ctx.value[ctx.key]} <{ctx.item['references']['url']}>`_"
+ return get_value(ctx)
def _get_value_sphinx_unspecified_define(ctx: ItemGetValueContext) -> Any:
- if ctx.item["reference"]:
- return _get_value_sphinx_url(ctx)
- return _get_value_sphinx_macro(ctx)
+ return _get_value_sphinx_ref(ctx, _get_value_sphinx_macro)
def _get_value_sphinx_unspecified_type(ctx: ItemGetValueContext) -> Any:
- if ctx.item["reference"]:
- return _get_value_sphinx_url(ctx)
- return _get_value_sphinx_type(ctx)
+ return _get_value_sphinx_ref(ctx, _get_value_sphinx_type)
class SphinxMapper(ItemMapper):