diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-04-26 09:04:50 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-04-28 07:18:33 +0200 |
commit | d3b9142a896f710924f47b4c61c19b4201cb9e8f (patch) | |
tree | dba18635f9a4210926a85bce32f4fed47ceda9e5 /rtemsspec | |
parent | spec: Update /rtems/scheduler/* documentation (diff) | |
download | rtems-central-d3b9142a896f710924f47b4c61c19b4201cb9e8f.tar.bz2 |
spec: Allow multiple interface references
Diffstat (limited to 'rtemsspec')
-rw-r--r-- | rtemsspec/applconfig.py | 7 | ||||
-rw-r--r-- | rtemsspec/sphinxcontent.py | 20 | ||||
-rw-r--r-- | rtemsspec/tests/spec-applconfig/unspec-define-2.yml | 3 | ||||
-rw-r--r-- | rtemsspec/tests/spec-applconfig/unspec-define.yml | 3 | ||||
-rw-r--r-- | rtemsspec/tests/spec-applconfig/unspec-type-2.yml | 3 | ||||
-rw-r--r-- | rtemsspec/tests/spec-applconfig/unspec-type.yml | 2 | ||||
-rw-r--r-- | rtemsspec/tests/test_applconfig.py | 2 |
7 files changed, 23 insertions, 17 deletions
diff --git a/rtemsspec/applconfig.py b/rtemsspec/applconfig.py index 364b1225..a2ef7035 100644 --- a/rtemsspec/applconfig.py +++ b/rtemsspec/applconfig.py @@ -425,17 +425,18 @@ def _get_value_doxygen_reference(_ctx: ItemGetValueContext) -> Any: def _get_value_doxygen_url(ctx: ItemGetValueContext) -> Any: - return f"<a href=\"{ctx.item['reference']}\">{ctx.value[ctx.key]}</a>" + url = ctx.item["references"]["url"] + return f"<a href=\"{url}\">{ctx.value[ctx.key]}</a>" def _get_value_doxygen_unspecfied_define(ctx: ItemGetValueContext) -> Any: - if ctx.item["reference"]: + if "url" in ctx.item["references"]: return _get_value_doxygen_url(ctx) return get_value_hash(ctx) def _get_value_doxygen_unspecfied_type(ctx: ItemGetValueContext) -> Any: - if ctx.item["reference"]: + if "url" in ctx.item["references"]: return _get_value_doxygen_url(ctx) return get_value_double_colon(ctx) 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): diff --git a/rtemsspec/tests/spec-applconfig/unspec-define-2.yml b/rtemsspec/tests/spec-applconfig/unspec-define-2.yml index 017673b5..75acb27b 100644 --- a/rtemsspec/tests/spec-applconfig/unspec-define-2.yml +++ b/rtemsspec/tests/spec-applconfig/unspec-define-2.yml @@ -5,5 +5,6 @@ enabled-by: true interface-type: unspecified-define links: [] name: UNSPEC_DEFINE_2 -reference: https://foo +references: + url: https://foo type: interface diff --git a/rtemsspec/tests/spec-applconfig/unspec-define.yml b/rtemsspec/tests/spec-applconfig/unspec-define.yml index 766b0dec..6ca8998c 100644 --- a/rtemsspec/tests/spec-applconfig/unspec-define.yml +++ b/rtemsspec/tests/spec-applconfig/unspec-define.yml @@ -5,5 +5,6 @@ enabled-by: true interface-type: unspecified-define links: [] name: UNSPEC_DEFINE -reference: null +references: + c-user: SphinxRefTarget type: interface diff --git a/rtemsspec/tests/spec-applconfig/unspec-type-2.yml b/rtemsspec/tests/spec-applconfig/unspec-type-2.yml index f34f63ea..4635d785 100644 --- a/rtemsspec/tests/spec-applconfig/unspec-type-2.yml +++ b/rtemsspec/tests/spec-applconfig/unspec-type-2.yml @@ -5,5 +5,6 @@ enabled-by: true interface-type: unspecified-type links: [] name: unspec_type_2 -reference: https://bar +references: + url: https://bar type: interface diff --git a/rtemsspec/tests/spec-applconfig/unspec-type.yml b/rtemsspec/tests/spec-applconfig/unspec-type.yml index b133d429..249fe301 100644 --- a/rtemsspec/tests/spec-applconfig/unspec-type.yml +++ b/rtemsspec/tests/spec-applconfig/unspec-type.yml @@ -5,5 +5,5 @@ enabled-by: true interface-type: unspecified-type links: [] name: unspec_type -reference: null +references: {} type: interface diff --git a/rtemsspec/tests/test_applconfig.py b/rtemsspec/tests/test_applconfig.py index c99e026e..1e53e83d 100644 --- a/rtemsspec/tests/test_applconfig.py +++ b/rtemsspec/tests/test_applconfig.py @@ -107,7 +107,7 @@ NOTES: * :c:macro:`DEFINE` - * :c:macro:`UNSPEC_DEFINE` + * :ref:`UNSPEC_DEFINE <SphinxRefTarget>` * `UNSPEC_DEFINE_2 <https://foo>`_ |