specware 1.3.7__tar.gz → 1.3.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {specware-1.3.7 → specware-1.3.9}/PKG-INFO +2 -2
- {specware-1.3.7 → specware-1.3.9}/pyproject.toml +2 -2
- {specware-1.3.7 → specware-1.3.9}/src/specware/applconfig.py +22 -5
- {specware-1.3.7 → specware-1.3.9}/src/specware/cliexport.py +12 -4
- {specware-1.3.7 → specware-1.3.9}/src/specware/cliview.py +12 -5
- {specware-1.3.7 → specware-1.3.9}/src/specware/interface.py +10 -2
- {specware-1.3.7 → specware-1.3.9}/src/specware/interfacemapper.py +160 -72
- {specware-1.3.7 → specware-1.3.9}/src/specware/rtems.py +2 -11
- {specware-1.3.7 → specware-1.3.9}/src/specware/spec.pickle +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/util.py +3 -2
- {specware-1.3.7 → specware-1.3.9}/README.md +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/__init__.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/build.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/cliexportheader.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/clifind.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/contentc.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/interfacedoc.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/py.typed +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/registerblock.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/transitionmap.py +0 -0
- {specware-1.3.7 → specware-1.3.9}/src/specware/validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: specware
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.9
|
|
4
4
|
Summary: Provides utilities to specify software.
|
|
5
5
|
Keywords: certification,documentation,markdown,qualification,requirements-management,traceability
|
|
6
6
|
Author: The specware Authors
|
|
@@ -20,7 +20,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
20
20
|
Classifier: Topic :: Software Development :: Testing :: Acceptance
|
|
21
21
|
Classifier: Topic :: Text Processing :: Markup
|
|
22
22
|
Classifier: Typing :: Typed
|
|
23
|
-
Requires-Dist: specitems>=1.7.
|
|
23
|
+
Requires-Dist: specitems>=1.7.3
|
|
24
24
|
Requires-Python: >=3.11
|
|
25
25
|
Project-URL: Source Code, https://github.com/specthings/specware
|
|
26
26
|
Project-URL: Bug Tracker, https://github.com/specthings/specware/issues
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "specware"
|
|
7
|
-
version = "1.3.
|
|
7
|
+
version = "1.3.9"
|
|
8
8
|
description = "Provides utilities to specify software."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "The specware Authors", email = "specthings@embedded-brains.de"}
|
|
@@ -13,7 +13,7 @@ license = "BSD-2-Clause"
|
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
requires-python = ">=3.11"
|
|
15
15
|
dependencies = [
|
|
16
|
-
"specitems >=1.7.
|
|
16
|
+
"specitems >=1.7.3",
|
|
17
17
|
]
|
|
18
18
|
keywords = [
|
|
19
19
|
"certification",
|
|
@@ -30,13 +30,16 @@ import itertools
|
|
|
30
30
|
from typing import Any, Callable, Optional
|
|
31
31
|
|
|
32
32
|
from specitems import (ClangFormatter, ContentContext, EnabledSet,
|
|
33
|
-
GenericContent,
|
|
34
|
-
ItemGetValueContext, ItemMapper,
|
|
33
|
+
GenericContent, get_reference_target, get_value_plural,
|
|
34
|
+
Item, ItemCache, ItemGetValueContext, ItemMapper,
|
|
35
|
+
TextContent)
|
|
35
36
|
|
|
36
37
|
from .contentc import (CContent, DEFAULT_ITEM_MARKER, add_item_marker,
|
|
37
38
|
get_value_double_colon, get_value_doxygen_function,
|
|
38
39
|
get_value_doxygen_group, get_value_doxygen_ref,
|
|
39
40
|
get_value_hash, get_value_header_file)
|
|
41
|
+
from .interfacemapper import (add_reference_transformers,
|
|
42
|
+
get_interface_reference, get_reference_url)
|
|
40
43
|
from .rtems import is_export_affected
|
|
41
44
|
|
|
42
45
|
_GROUP_MEMBER_ROLES = ("appl-config-group-member", "interface-ingroup")
|
|
@@ -315,12 +318,21 @@ def _get_value_doxygen_url(
|
|
|
315
318
|
ctx: ItemGetValueContext,
|
|
316
319
|
get_value: Callable[[ItemGetValueContext],
|
|
317
320
|
str] = _get_value) -> Optional[str]:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
+
target = get_interface_reference(ctx.item)
|
|
322
|
+
if target is not None:
|
|
323
|
+
url = get_reference_url(ctx.mapper, target)
|
|
324
|
+
if url is not None:
|
|
325
|
+
return f"<a href=\"{url}\">{get_value(ctx)}</a>"
|
|
321
326
|
return None
|
|
322
327
|
|
|
323
328
|
|
|
329
|
+
def _get_value_doxygen_reference_location(ctx: ItemGetValueContext) -> str:
|
|
330
|
+
url = get_reference_url(ctx.mapper, get_reference_target(ctx.item))
|
|
331
|
+
if url is None:
|
|
332
|
+
return ctx.value[ctx.key]
|
|
333
|
+
return f"<a href=\"{url}\">{ctx.value[ctx.key]}</a>"
|
|
334
|
+
|
|
335
|
+
|
|
324
336
|
def _get_value_doxygen_unspecified_define(ctx: ItemGetValueContext) -> Any:
|
|
325
337
|
return _get_value_doxygen_url(ctx) or get_value_hash(ctx)
|
|
326
338
|
|
|
@@ -339,6 +351,7 @@ def _get_value_doxygen_unspecfied_type(ctx: ItemGetValueContext) -> Any:
|
|
|
339
351
|
|
|
340
352
|
|
|
341
353
|
def _add_doxygen_get_values(mapper: ItemMapper) -> None:
|
|
354
|
+
add_reference_transformers(mapper)
|
|
342
355
|
for opt in ["feature-enable", "feature", "initializer", "integer"]:
|
|
343
356
|
name = f"interface/appl-config-option/{opt}:/name"
|
|
344
357
|
mapper.add_get_value(name, get_value_doxygen_ref)
|
|
@@ -354,6 +367,8 @@ def _add_doxygen_get_values(mapper: ItemMapper) -> None:
|
|
|
354
367
|
mapper.add_get_value("interface/union:/name", get_value_double_colon)
|
|
355
368
|
mapper.add_get_value("interface/unspecified-define:/name",
|
|
356
369
|
_get_value_doxygen_unspecified_define)
|
|
370
|
+
mapper.add_get_value("interface/unspecified-enumerator:/name",
|
|
371
|
+
_get_value_doxygen_unspecified_define)
|
|
357
372
|
mapper.add_get_value("interface/unspecified-function:/name",
|
|
358
373
|
_get_value_doxygen_unspecified_function)
|
|
359
374
|
mapper.add_get_value("interface/unspecified-group:/name",
|
|
@@ -366,6 +381,8 @@ def _add_doxygen_get_values(mapper: ItemMapper) -> None:
|
|
|
366
381
|
_get_value_doxygen_unspecfied_type)
|
|
367
382
|
mapper.add_get_value("interface/unspecified-union:/name",
|
|
368
383
|
_get_value_doxygen_unspecfied_type)
|
|
384
|
+
mapper.add_get_value("reference-location:/name",
|
|
385
|
+
_get_value_doxygen_reference_location)
|
|
369
386
|
|
|
370
387
|
|
|
371
388
|
def is_application_configuration_affected(config: dict, item_cache: ItemCache,
|
|
@@ -57,13 +57,18 @@ _DOC_FORMAT = {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def _bind_context(
|
|
60
|
+
def _bind_context(
|
|
61
|
+
fmt: str,
|
|
62
|
+
context: ContentContext,
|
|
63
|
+
target_document_uid: Optional[str] = None) -> tuple[Any, Any, Any]:
|
|
61
64
|
"""
|
|
62
65
|
Bind the context to the content and mapper constructors of the format.
|
|
63
66
|
|
|
64
67
|
Args:
|
|
65
68
|
fmt: The documentation format.
|
|
66
69
|
context: The content context of a task.
|
|
70
|
+
target_document_uid: The UID of the target document of the
|
|
71
|
+
documentation of the task.
|
|
67
72
|
|
|
68
73
|
Returns:
|
|
69
74
|
The content constructor, the mapper constructor and the interface
|
|
@@ -78,7 +83,9 @@ def _bind_context(fmt: str, context: ContentContext) -> tuple[Any, Any, Any]:
|
|
|
78
83
|
**kwargs)
|
|
79
84
|
|
|
80
85
|
return (_create_content, functools.partial(create_mapper, context=context),
|
|
81
|
-
functools.partial(create_interface_mapper,
|
|
86
|
+
functools.partial(create_interface_mapper,
|
|
87
|
+
context=context,
|
|
88
|
+
target_document_uid=target_document_uid))
|
|
82
89
|
|
|
83
90
|
|
|
84
91
|
#: The keys of a task which its configuration object takes not.
|
|
@@ -101,7 +108,8 @@ def _generate_appl_config(task: dict, group_uids: list[str],
|
|
|
101
108
|
# The task produces a Doxygen source and documentation sources, and each
|
|
102
109
|
# kind states its own license.
|
|
103
110
|
create_content, _, create_interface_mapper = _bind_context(
|
|
104
|
-
args.format, create_content_context(task, provider, "documentation-")
|
|
111
|
+
args.format, create_content_context(task, provider, "documentation-"),
|
|
112
|
+
task.get("target-document-uid"))
|
|
105
113
|
generate_application_configuration(task,
|
|
106
114
|
group_uids,
|
|
107
115
|
item_cache,
|
|
@@ -322,7 +330,7 @@ def _generate_documentation(item_cache: ItemCache, config: Item,
|
|
|
322
330
|
for task in yield_tasks(config, "interface-documentation"):
|
|
323
331
|
context = create_content_context(task, provider)
|
|
324
332
|
create_content, _, create_interface_mapper = _bind_context(
|
|
325
|
-
args.format, context)
|
|
333
|
+
args.format, context, task.get("target-document-uid"))
|
|
326
334
|
generate_interface_documentation(task, item_cache,
|
|
327
335
|
create_interface_mapper,
|
|
328
336
|
create_content)
|
|
@@ -33,7 +33,8 @@ from typing import Any, Callable, Optional, Iterable
|
|
|
33
33
|
|
|
34
34
|
from specitems import (COL_SPAN, CommonMarkContent, Item, ItemCache,
|
|
35
35
|
ItemGetValueContext, ItemMapper, Link, MarkdownContent,
|
|
36
|
-
ROW_SPAN, SphinxContent, TextContent,
|
|
36
|
+
ROW_SPAN, SphinxContent, TextContent,
|
|
37
|
+
get_reference_work, yield_tasks)
|
|
37
38
|
|
|
38
39
|
from specware import (exit_on_config_file_error, open_tree,
|
|
39
40
|
augment_with_test_case_links, augment_with_test_links,
|
|
@@ -165,7 +166,11 @@ def _view(item: Item, mapper: ItemMapper, level: int, link: Optional[Link],
|
|
|
165
166
|
# The cited work appears under the requirement which references it. A
|
|
166
167
|
# refinement of the requirement places it in the tree.
|
|
167
168
|
for link_2 in item.links_to_parents("reference"):
|
|
168
|
-
_visit_item(link_2.item, mapper, level + 1, link_2,
|
|
169
|
+
if _visit_item(link_2.item, mapper, level + 1, link_2,
|
|
170
|
+
validated_filter):
|
|
171
|
+
for link_3 in link_2.item.links_to_parents("reference-location"):
|
|
172
|
+
_visit_item(link_3.item, mapper, level + 2, link_3,
|
|
173
|
+
validated_filter)
|
|
169
174
|
_view_interface_placment(item, mapper, level + 1, validated_filter)
|
|
170
175
|
for link_2 in itertools.chain(
|
|
171
176
|
item.links_to_children(_VIEW_CHILD_ROLES),
|
|
@@ -573,8 +578,9 @@ def _register_block(item: Item) -> tuple[int, int]:
|
|
|
573
578
|
size = item["register-block-size"]
|
|
574
579
|
if size is not None:
|
|
575
580
|
parts.append(f"size {size}")
|
|
576
|
-
parts.extend(
|
|
577
|
-
|
|
581
|
+
parts.extend(
|
|
582
|
+
get_reference_work(link.item)["title"]
|
|
583
|
+
for link in item.links_to_parents("reference", _any_link))
|
|
578
584
|
print(" ".join(parts))
|
|
579
585
|
layout = get_register_block_layout(item)
|
|
580
586
|
includes = dict(
|
|
@@ -635,7 +641,8 @@ def _validate(_item: Item, validated: bool) -> bool:
|
|
|
635
641
|
def _prepare_mapper(mapper: ItemMapper) -> None:
|
|
636
642
|
for type_path_key in (
|
|
637
643
|
"interface:/spec", "glossary/term:/plural", "reference:/cite",
|
|
638
|
-
"reference:/cite-long",
|
|
644
|
+
"reference:/cite-long", "reference-location:/cite",
|
|
645
|
+
"reference-location:/cite-long",
|
|
639
646
|
"requirement/functional/action:/text-template",
|
|
640
647
|
"requirement/non-functional/performance-runtime:/environment",
|
|
641
648
|
"requirement/non-functional/performance-runtime:/limit-condition",
|
|
@@ -78,9 +78,15 @@ def _get_domains(item: Item) -> set[str]:
|
|
|
78
78
|
return domains
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
def _is_hosted_in_second_domain(item: Item) -> bool:
|
|
82
|
+
return any(True for _ in item.links_to_children("interface-host")) or (
|
|
83
|
+
bool(get_register_block_hosts(item))
|
|
84
|
+
and any(True for _ in item.parents("interface-placement")))
|
|
85
|
+
|
|
86
|
+
|
|
81
87
|
def _get_ingroups_of_node(item: Item, domain: Item) -> _ItemMap:
|
|
82
88
|
ingroups = _get_ingroups(item)
|
|
83
|
-
if
|
|
89
|
+
if _is_hosted_in_second_domain(item):
|
|
84
90
|
return {
|
|
85
91
|
uid: group
|
|
86
92
|
for uid, group in ingroups.items()
|
|
@@ -700,8 +706,10 @@ class _Node:
|
|
|
700
706
|
ctx.regs[name] = {}
|
|
701
707
|
ctx.regs[name]["size"] = link.item["register-block-size"]
|
|
702
708
|
ctx.regs[name]["type"] = link.item["name"]
|
|
709
|
+
host = self.header_file.get_host(
|
|
710
|
+
link.item) if _is_hosted_in_second_domain(link.item) else None
|
|
703
711
|
ctx.regs[name]["group"] = get_register_block_identifier(
|
|
704
|
-
link.item,
|
|
712
|
+
link.item, host)
|
|
705
713
|
|
|
706
714
|
def _get_register_member_info(self, ctx: _RegisterMemberContext) -> None:
|
|
707
715
|
offset = -1
|
|
@@ -24,9 +24,12 @@
|
|
|
24
24
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
25
25
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
26
26
|
|
|
27
|
+
from typing import Callable, Optional
|
|
28
|
+
|
|
27
29
|
from specitems import (BibTeXCitationProvider, ContentContext, Item,
|
|
28
|
-
ItemGetValue, ItemGetValueContext,
|
|
29
|
-
|
|
30
|
+
ItemGetValue, ItemGetValueContext, ItemMapper,
|
|
31
|
+
MarkdownMapper, ReferenceTarget, SphinxMapper,
|
|
32
|
+
get_reference, get_reference_target, make_label)
|
|
30
33
|
|
|
31
34
|
from .contentc import get_value_header_file
|
|
32
35
|
|
|
@@ -36,6 +39,119 @@ def sanitize_name(name: str) -> str:
|
|
|
36
39
|
return name.lstrip("_")
|
|
37
40
|
|
|
38
41
|
|
|
42
|
+
def get_interface_reference(item: Item) -> Optional[ReferenceTarget]:
|
|
43
|
+
"""
|
|
44
|
+
Get the target of the reference link of the interface.
|
|
45
|
+
|
|
46
|
+
Return None, if the interface has no reference link.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
ValueError: The interface has more than one reference link.
|
|
50
|
+
"""
|
|
51
|
+
links = list(item.links_to_parents("reference"))
|
|
52
|
+
if not links:
|
|
53
|
+
return None
|
|
54
|
+
if len(links) > 1:
|
|
55
|
+
raise ValueError(f"{item.uid}: an interface shall have at most one "
|
|
56
|
+
"reference link")
|
|
57
|
+
return get_reference_target(links[0].item, links[0])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def get_reference_url(mapper: ItemMapper,
|
|
61
|
+
target: ReferenceTarget) -> Optional[str]:
|
|
62
|
+
"""
|
|
63
|
+
Get the URL of the reference target substituted in the context of the
|
|
64
|
+
referenced work.
|
|
65
|
+
"""
|
|
66
|
+
if target.url is None:
|
|
67
|
+
return None
|
|
68
|
+
return mapper.substitute(target.url, target.work)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _relpath(_ctx: ItemGetValueContext, value: str) -> str:
|
|
72
|
+
return value
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def add_reference_transformers(mapper: ItemMapper) -> None:
|
|
76
|
+
"""
|
|
77
|
+
Add the value transformers which the URLs of references may use.
|
|
78
|
+
|
|
79
|
+
Outside a package build, the relpath transformer returns the path
|
|
80
|
+
unchanged.
|
|
81
|
+
"""
|
|
82
|
+
mapper.add_value_transformer("relpath", _relpath)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
#: Formats a reference to a label with an optional name.
|
|
86
|
+
FormatLabel = Callable[[Optional[str], str], str]
|
|
87
|
+
|
|
88
|
+
#: Formats a hyperlink with a name to an URL.
|
|
89
|
+
FormatLink = Callable[[str, str], str]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _format_reference(ctx: ItemGetValueContext,
|
|
93
|
+
target: Optional[ReferenceTarget], name: Optional[str],
|
|
94
|
+
fallback: str) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Format a reference to the target.
|
|
97
|
+
|
|
98
|
+
Inside the target document, a target with a label yields a reference to
|
|
99
|
+
the label. Elsewhere, a target with an URL yields a hyperlink. A name of
|
|
100
|
+
None makes the reference to the label take the title of the label target.
|
|
101
|
+
"""
|
|
102
|
+
if target is None:
|
|
103
|
+
return fallback
|
|
104
|
+
mapper = ctx.mapper
|
|
105
|
+
assert isinstance(mapper, (SphinxInterfaceMapper, MarkdownInterfaceMapper))
|
|
106
|
+
if (target.label is not None
|
|
107
|
+
and mapper.target_document_uid == target.work.uid):
|
|
108
|
+
return mapper.format_reference_label(name, target.label)
|
|
109
|
+
url = get_reference_url(mapper, target)
|
|
110
|
+
if url is None:
|
|
111
|
+
return fallback
|
|
112
|
+
return mapper.format_reference_link(fallback if name is None else name,
|
|
113
|
+
url)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _get_value_ref(ctx: ItemGetValueContext,
|
|
117
|
+
get_value: ItemGetValue,
|
|
118
|
+
postfix: str = "",
|
|
119
|
+
prefix: str = "") -> str:
|
|
120
|
+
return _format_reference(ctx, get_interface_reference(ctx.item),
|
|
121
|
+
f"{prefix}{ctx.value[ctx.key]}{postfix}",
|
|
122
|
+
get_value(ctx))
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _get_value_unspecified_group(ctx: ItemGetValueContext) -> str:
|
|
126
|
+
return _format_reference(ctx, get_interface_reference(ctx.item), None,
|
|
127
|
+
ctx.value[ctx.key])
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _get_value_reference_location(ctx: ItemGetValueContext) -> str:
|
|
131
|
+
return _format_reference(ctx, get_reference_target(ctx.item), None,
|
|
132
|
+
ctx.value[ctx.key])
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _format_sphinx_label(name: Optional[str], label: str) -> str:
|
|
136
|
+
if name is None:
|
|
137
|
+
return f":ref:`{label}`"
|
|
138
|
+
return f":ref:`{name} <{label}>`"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _format_sphinx_link(name: str, url: str) -> str:
|
|
142
|
+
return f"`{name} <{url}>`_"
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _format_markdown_label(name: Optional[str], label: str) -> str:
|
|
146
|
+
if name is None:
|
|
147
|
+
return f"{{ref}}`{label}`"
|
|
148
|
+
return f"{{ref}}`{name} <{label}>`"
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _format_markdown_link(name: str, url: str) -> str:
|
|
152
|
+
return f"[{name}]({url})"
|
|
153
|
+
|
|
154
|
+
|
|
39
155
|
def _compound_kind(ctx: ItemGetValueContext) -> str:
|
|
40
156
|
type_name = ctx.item.type
|
|
41
157
|
return f"{type_name[type_name.rfind('-') + 1:]} "
|
|
@@ -61,48 +177,22 @@ def _get_value_sphinx_compound(ctx: ItemGetValueContext) -> str:
|
|
|
61
177
|
return f"``{_compound_kind(ctx)}{ctx.value[ctx.key]}``"
|
|
62
178
|
|
|
63
179
|
|
|
64
|
-
def _get_value_sphinx_ref(ctx: ItemGetValueContext,
|
|
65
|
-
get_value: ItemGetValue,
|
|
66
|
-
postfix: str = "",
|
|
67
|
-
prefix: str = "") -> str:
|
|
68
|
-
for ref in ctx.item.get("references", []):
|
|
69
|
-
ref_type = ref["type"]
|
|
70
|
-
identifier = ref["identifier"]
|
|
71
|
-
name_ref = f"`{prefix}{ctx.value[ctx.key]}{postfix} <{identifier}>`"
|
|
72
|
-
if ref_type == "document" and ref["name"] == "c-user":
|
|
73
|
-
return f":ref:{name_ref}"
|
|
74
|
-
if ref_type == "url":
|
|
75
|
-
return f"{name_ref}_"
|
|
76
|
-
return get_value(ctx)
|
|
77
|
-
|
|
78
|
-
|
|
79
180
|
def _get_value_sphinx_unspecified_define(ctx: ItemGetValueContext) -> str:
|
|
80
|
-
return
|
|
181
|
+
return _get_value_ref(ctx, _get_value_sphinx_macro)
|
|
81
182
|
|
|
82
183
|
|
|
83
184
|
def _get_value_sphinx_unspecified_function(ctx: ItemGetValueContext) -> str:
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def _get_value_sphinx_unspecified_group(ctx: ItemGetValueContext) -> str:
|
|
88
|
-
for ref in ctx.item.get("references", []):
|
|
89
|
-
ref_type = ref["type"]
|
|
90
|
-
identifier = ref["identifier"]
|
|
91
|
-
if ref_type == "document" and ref["name"] == "c-user":
|
|
92
|
-
return f":ref:`{identifier}`"
|
|
93
|
-
if ref_type == "url":
|
|
94
|
-
return f"`{ctx.value[ctx.key]} <{identifier}>`_"
|
|
95
|
-
return ctx.value[ctx.key]
|
|
185
|
+
return _get_value_ref(ctx, _get_value_sphinx_function, "()")
|
|
96
186
|
|
|
97
187
|
|
|
98
188
|
def _get_value_sphinx_unspecified_type(ctx: ItemGetValueContext) -> str:
|
|
99
|
-
return
|
|
189
|
+
return _get_value_ref(ctx, _get_value_sphinx_type)
|
|
100
190
|
|
|
101
191
|
|
|
102
192
|
def _get_value_sphinx_unspecified_compound(ctx: ItemGetValueContext) -> str:
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
|
|
193
|
+
return _get_value_ref(ctx,
|
|
194
|
+
_get_value_sphinx_compound,
|
|
195
|
+
prefix=_compound_kind(ctx))
|
|
106
196
|
|
|
107
197
|
|
|
108
198
|
def get_value_sphinx_param(ctx: ItemGetValueContext) -> str:
|
|
@@ -118,11 +208,23 @@ def get_value_sphinx_header_file(ctx: ItemGetValueContext) -> str:
|
|
|
118
208
|
class SphinxInterfaceMapper(SphinxMapper):
|
|
119
209
|
""" Sphinx item mapper for the interface documentation. """
|
|
120
210
|
|
|
121
|
-
def __init__(self,
|
|
122
|
-
|
|
211
|
+
def __init__(self,
|
|
212
|
+
item: Item,
|
|
213
|
+
group_uids: list[str],
|
|
214
|
+
context: str | ContentContext,
|
|
215
|
+
target_document_uid: Optional[str] = None):
|
|
123
216
|
super().__init__(item, context)
|
|
124
217
|
self._group_uids = set(group_uids)
|
|
218
|
+
|
|
219
|
+
#: The UID of the target document of the mapper.
|
|
220
|
+
self.target_document_uid = target_document_uid
|
|
221
|
+
|
|
222
|
+
self.format_reference_label: FormatLabel = _format_sphinx_label
|
|
223
|
+
self.format_reference_link: FormatLink = _format_sphinx_link
|
|
125
224
|
BibTeXCitationProvider(self)
|
|
225
|
+
add_reference_transformers(self)
|
|
226
|
+
self.add_get_value("reference-location:/name",
|
|
227
|
+
_get_value_reference_location)
|
|
126
228
|
self.add_get_value("interface/appl-config-option/feature-enable:/name",
|
|
127
229
|
_get_value_sphinx_appl_config_option)
|
|
128
230
|
self.add_get_value("interface/appl-config-option/feature:/name",
|
|
@@ -156,7 +258,7 @@ class SphinxInterfaceMapper(SphinxMapper):
|
|
|
156
258
|
self.add_get_value("interface/unspecified-function:/name",
|
|
157
259
|
_get_value_sphinx_unspecified_function)
|
|
158
260
|
self.add_get_value("interface/unspecified-group:/name",
|
|
159
|
-
|
|
261
|
+
_get_value_unspecified_group)
|
|
160
262
|
self.add_get_value("interface/unspecified-enum:/name",
|
|
161
263
|
_get_value_sphinx_unspecified_type)
|
|
162
264
|
self.add_get_value("interface/unspecified-struct:/name",
|
|
@@ -215,48 +317,22 @@ def _get_value_markdown_compound(ctx: ItemGetValueContext) -> str:
|
|
|
215
317
|
return f"{{c:type}}`{_compound_kind(ctx)}{ctx.value[ctx.key]}`"
|
|
216
318
|
|
|
217
319
|
|
|
218
|
-
def _get_value_markdown_ref(ctx: ItemGetValueContext,
|
|
219
|
-
get_value: ItemGetValue,
|
|
220
|
-
postfix: str = "",
|
|
221
|
-
prefix: str = "") -> str:
|
|
222
|
-
for ref in ctx.item.get("references", []):
|
|
223
|
-
ref_type = ref["type"]
|
|
224
|
-
identifier = ref["identifier"]
|
|
225
|
-
name = f"{prefix}{ctx.value[ctx.key]}{postfix}"
|
|
226
|
-
if ref_type == "document" and ref["name"] == "c-user":
|
|
227
|
-
return f"{{ref}}`{name} <{identifier}>`"
|
|
228
|
-
if ref_type == "url":
|
|
229
|
-
return f"[{name}]({identifier})"
|
|
230
|
-
return get_value(ctx)
|
|
231
|
-
|
|
232
|
-
|
|
233
320
|
def _get_value_markdown_unspecified_define(ctx: ItemGetValueContext) -> str:
|
|
234
|
-
return
|
|
321
|
+
return _get_value_ref(ctx, _get_value_markdown_macro)
|
|
235
322
|
|
|
236
323
|
|
|
237
324
|
def _get_value_markdown_unspecified_function(ctx: ItemGetValueContext) -> str:
|
|
238
|
-
return
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
def _get_value_markdown_unspecified_group(ctx: ItemGetValueContext) -> str:
|
|
242
|
-
for ref in ctx.item.get("references", []):
|
|
243
|
-
ref_type = ref["type"]
|
|
244
|
-
identifier = ref["identifier"]
|
|
245
|
-
if ref_type == "document" and ref["name"] == "c-user":
|
|
246
|
-
return f"{{ref}}`{identifier}`"
|
|
247
|
-
if ref_type == "url":
|
|
248
|
-
return f"[{ctx.value[ctx.key]}]({identifier})"
|
|
249
|
-
return ctx.value[ctx.key]
|
|
325
|
+
return _get_value_ref(ctx, _get_value_markdown_function, "()")
|
|
250
326
|
|
|
251
327
|
|
|
252
328
|
def _get_value_markdown_unspecified_type(ctx: ItemGetValueContext) -> str:
|
|
253
|
-
return
|
|
329
|
+
return _get_value_ref(ctx, _get_value_markdown_type)
|
|
254
330
|
|
|
255
331
|
|
|
256
332
|
def _get_value_markdown_unspecified_compound(ctx: ItemGetValueContext) -> str:
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
333
|
+
return _get_value_ref(ctx,
|
|
334
|
+
_get_value_markdown_compound,
|
|
335
|
+
prefix=_compound_kind(ctx))
|
|
260
336
|
|
|
261
337
|
|
|
262
338
|
def get_value_markdown_param(ctx: ItemGetValueContext) -> str:
|
|
@@ -267,11 +343,23 @@ def get_value_markdown_param(ctx: ItemGetValueContext) -> str:
|
|
|
267
343
|
class MarkdownInterfaceMapper(MarkdownMapper):
|
|
268
344
|
""" Markdown item mapper for the interface documentation. """
|
|
269
345
|
|
|
270
|
-
def __init__(self,
|
|
271
|
-
|
|
346
|
+
def __init__(self,
|
|
347
|
+
item: Item,
|
|
348
|
+
group_uids: list[str],
|
|
349
|
+
context: str | ContentContext,
|
|
350
|
+
target_document_uid: Optional[str] = None):
|
|
272
351
|
super().__init__(item, context)
|
|
273
352
|
self._group_uids = set(group_uids)
|
|
353
|
+
|
|
354
|
+
#: The UID of the target document of the mapper.
|
|
355
|
+
self.target_document_uid = target_document_uid
|
|
356
|
+
|
|
357
|
+
self.format_reference_label: FormatLabel = _format_markdown_label
|
|
358
|
+
self.format_reference_link: FormatLink = _format_markdown_link
|
|
274
359
|
BibTeXCitationProvider(self)
|
|
360
|
+
add_reference_transformers(self)
|
|
361
|
+
self.add_get_value("reference-location:/name",
|
|
362
|
+
_get_value_reference_location)
|
|
275
363
|
self.add_get_value("interface/appl-config-option/feature-enable:/name",
|
|
276
364
|
_get_value_markdown_appl_config_option)
|
|
277
365
|
self.add_get_value("interface/appl-config-option/feature:/name",
|
|
@@ -305,7 +393,7 @@ class MarkdownInterfaceMapper(MarkdownMapper):
|
|
|
305
393
|
self.add_get_value("interface/unspecified-function:/name",
|
|
306
394
|
_get_value_markdown_unspecified_function)
|
|
307
395
|
self.add_get_value("interface/unspecified-group:/name",
|
|
308
|
-
|
|
396
|
+
_get_value_unspecified_group)
|
|
309
397
|
self.add_get_value("interface/unspecified-enum:/name",
|
|
310
398
|
_get_value_markdown_unspecified_type)
|
|
311
399
|
self.add_get_value("interface/unspecified-struct:/name",
|
|
@@ -56,12 +56,6 @@ _ENABLEMENT_CHILD_ROLES = ("interface-host", "interface-group-member",
|
|
|
56
56
|
"register-block-base", "register-block-host",
|
|
57
57
|
"register-block-include")
|
|
58
58
|
|
|
59
|
-
# A host of an interface with a placement does not decide its enablement. The
|
|
60
|
-
# placement serves the domain of the placement whatever the hosts are.
|
|
61
|
-
_ENABLEMENT_PLACED_CHILD_ROLES = tuple(role for role in _ENABLEMENT_CHILD_ROLES
|
|
62
|
-
if role not in ("interface-host",
|
|
63
|
-
"register-block-host"))
|
|
64
|
-
|
|
65
59
|
|
|
66
60
|
def recursive_is_enabled(enabled_set: EnabledSet, item: Item) -> bool:
|
|
67
61
|
"""
|
|
@@ -71,13 +65,10 @@ def recursive_is_enabled(enabled_set: EnabledSet, item: Item) -> bool:
|
|
|
71
65
|
if not item.is_enabled(enabled_set):
|
|
72
66
|
return False
|
|
73
67
|
result = True
|
|
74
|
-
if any(True for _ in item.parents("interface-placement")):
|
|
75
|
-
child_roles = _ENABLEMENT_PLACED_CHILD_ROLES
|
|
76
|
-
else:
|
|
77
|
-
child_roles = _ENABLEMENT_CHILD_ROLES
|
|
78
68
|
for parent in itertools.chain(
|
|
79
69
|
item.parents(_ENABLEMENT_ROLES, is_link_enabled=link_is_enabled),
|
|
80
|
-
item.children(
|
|
70
|
+
item.children(_ENABLEMENT_CHILD_ROLES,
|
|
71
|
+
is_link_enabled=link_is_enabled)):
|
|
81
72
|
if recursive_is_enabled(enabled_set, parent):
|
|
82
73
|
return True
|
|
83
74
|
result = False
|
|
Binary file
|
|
@@ -37,8 +37,8 @@ from typing import (Any, Callable, Iterator, NamedTuple, Optional, TypeVar,
|
|
|
37
37
|
|
|
38
38
|
from specitems import (ClangFormatter, IsEnabled, Item, ItemCache,
|
|
39
39
|
ItemCacheConfig, ItemDataByUID, SpecTypeProvider,
|
|
40
|
-
create_config, create_type_provider,
|
|
41
|
-
load_config_item, monitor_logging,
|
|
40
|
+
add_inline_items, create_config, create_type_provider,
|
|
41
|
+
find_config_file, load_config_item, monitor_logging,
|
|
42
42
|
pickle_load_data_by_uid)
|
|
43
43
|
|
|
44
44
|
|
|
@@ -303,4 +303,5 @@ def open_tree(config_file: Optional[str],
|
|
|
303
303
|
item_cache = ItemCache(item_cache_config,
|
|
304
304
|
is_item_enabled=is_item_enabled,
|
|
305
305
|
type_provider=type_provider)
|
|
306
|
+
add_inline_items(config, item_cache)
|
|
306
307
|
yield Tree(config, item_cache, directory)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|