From be254b4ed43650c3f0bb902394768ee773f4cb47 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 15 Sep 2021 21:11:56 +0200 Subject: spec: Use external references for interfaces --- rtemsspec/sphinxcontent.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'rtemsspec/sphinxcontent.py') diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py index 1d72ae7c..e0084af8 100644 --- a/rtemsspec/sphinxcontent.py +++ b/rtemsspec/sphinxcontent.py @@ -229,12 +229,13 @@ def _get_value_sphinx_type(ctx: ItemGetValueContext) -> Any: def _get_value_sphinx_ref(ctx: ItemGetValueContext, get_value: ItemGetValue, postfix: str) -> Any: - if "c-user" in ctx.item["references"]: - sphinx_ref = ctx.item["references"]["c-user"] - return f":ref:`{ctx.value[ctx.key]}{postfix} <{sphinx_ref}>`" - if "url" in ctx.item["references"]: - url = ctx.item["references"]["url"] - return f"`{ctx.value[ctx.key]}{postfix} <{url}>`_" + for ref in ctx.item["references"]: + ref_type = ref["type"] + identifier = ref["identifier"] + if ref_type == "document" and ref["name"] == "c-user": + return f":ref:`{ctx.value[ctx.key]}{postfix} <{identifier}>`" + if ref_type == "url": + return f"`{ctx.value[ctx.key]}{postfix} <{identifier}>`_" return get_value(ctx) @@ -247,11 +248,13 @@ def _get_value_sphinx_unspecified_function(ctx: ItemGetValueContext) -> Any: def _get_value_sphinx_unspecified_group(ctx: ItemGetValueContext) -> Any: - if "c-user" in ctx.item["references"]: - return f":ref:`{ctx.item['references']['c-user']}`" - if "url" in ctx.item["references"]: - url = ctx.item["references"]["url"] - return f"`{ctx.value[ctx.key]} <{url}>`_" + for ref in ctx.item["references"]: + ref_type = ref["type"] + identifier = ref["identifier"] + if ref_type == "document" and ref["name"] == "c-user": + return f":ref:`{identifier}`" + if ref_type == "url": + return f"`{ctx.value[ctx.key]} <{identifier}>`_" return ctx.value[ctx.key] -- cgit v1.2.3