specware 1.2.3__tar.gz → 1.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: specware
3
- Version: 1.2.3
3
+ Version: 1.2.5
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.4.5
23
+ Requires-Dist: specitems>=1.6.0
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.2.3"
7
+ version = "1.2.5"
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.4.5",
16
+ "specitems >=1.6.0",
17
17
  ]
18
18
  keywords = [
19
19
  "certification",
@@ -46,7 +46,7 @@ from specware import (MarkdownInterfaceMapper, SpecWareTypeProvider,
46
46
  generate_validation, load_specware_config)
47
47
 
48
48
  _DOC_FORMAT = {
49
- "markdown": (MarkdownContent, MarkdownMapper, MarkdownInterfaceMapper),
49
+ "myst": (MarkdownContent, MarkdownMapper, MarkdownInterfaceMapper),
50
50
  "rest": (SphinxContent, SphinxMapper, SphinxInterfaceMapper)
51
51
  }
52
52
 
@@ -58,9 +58,9 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
58
58
  default=None,
59
59
  help="use this configuration file")
60
60
  parser.add_argument("--format",
61
- choices=["markdown", "rest"],
61
+ choices=["myst", "rest"],
62
62
  type=str.lower,
63
- default="markdown",
63
+ default="myst",
64
64
  help="the output format of documentation files")
65
65
  parser.add_argument("--no-application-configuration-code",
66
66
  action="store_true",
@@ -28,17 +28,24 @@ import argparse
28
28
  import contextlib
29
29
  import itertools
30
30
  import sys
31
- from typing import Any, Optional, Iterable
31
+ from typing import Any, Callable, Optional, Iterable
32
32
 
33
- from specitems import (COL_SPAN, Item, ItemCache, ItemCacheConfig,
34
- ItemGetValueContext, ItemMapper, ROW_SPAN,
35
- SphinxContent, create_config)
33
+ from specitems import (COL_SPAN, CommonMarkContent, Item, ItemCache,
34
+ ItemCacheConfig, ItemGetValueContext, ItemMapper,
35
+ MarkdownContent, ROW_SPAN, SphinxContent, TextContent,
36
+ create_config)
36
37
 
37
38
  from specware import (augment_with_test_case_links, augment_with_test_links,
38
39
  gather_api_items, gather_build_files,
39
40
  load_specware_config, recursive_is_enabled, Transition,
40
41
  TransitionMap, validate, SpecWareTypeProvider)
41
42
 
43
+ _DOC_FORMAT = {
44
+ "commonmark": CommonMarkContent,
45
+ "myst": MarkdownContent,
46
+ "rest": SphinxContent,
47
+ }
48
+
42
49
  _CHILD_ROLES = [
43
50
  "requirement-refinement", "interface-ingroup", "interface-ingroup-hidden",
44
51
  "interface-function", "glossary-member", "performance-runtime-limits",
@@ -230,7 +237,8 @@ def _make_row(transition_map: TransitionMap, map_idx: int, variant: Transition,
230
237
  for co_idx, st_idx in enumerate(variant.post_cond))))
231
238
 
232
239
 
233
- def _action_table(item: Item, show_skip: bool) -> None:
240
+ def _action_table(item: Item, show_skip: bool,
241
+ create_content: Callable[[], TextContent]) -> None:
234
242
  header = ["Entry", "Descriptor"]
235
243
  if show_skip:
236
244
  header.append("Skip")
@@ -246,7 +254,7 @@ def _action_table(item: Item, show_skip: bool) -> None:
246
254
  item.cache.enabled_set):
247
255
  if show_skip or not variant.skip:
248
256
  rows.append(_make_row(transition_map, map_idx, variant, show_skip))
249
- content = SphinxContent()
257
+ content = create_content()
250
258
  content.add_simple_table(rows)
251
259
  print(str(content))
252
260
 
@@ -258,12 +266,13 @@ def _states(transition_map: TransitionMap, co_idx: int,
258
266
  for st_idx in set(states))
259
267
 
260
268
 
261
- def _action_compact_table(item: Item) -> None:
269
+ def _action_compact_table(item: Item,
270
+ create_content: Callable[[], TextContent]) -> None:
262
271
  transition_map = TransitionMap(item, "N/A")
263
272
  rows: list[Iterable[str | int]] = [
264
- ("Pre-Conditions", ) + (ROW_SPAN, ) *
273
+ ("Pre-Conditions", ) + (COL_SPAN, ) *
265
274
  (transition_map.pre_co_count - 1) + ("Post-Conditions", ) +
266
- (ROW_SPAN, ) * (transition_map.post_co_count - 1)
275
+ (COL_SPAN, ) * (transition_map.post_co_count - 1)
267
276
  ]
268
277
  rows.append(
269
278
  tuple(
@@ -274,23 +283,23 @@ def _action_compact_table(item: Item) -> None:
274
283
  item.cache.enabled_set):
275
284
  if post_co[0]:
276
285
  post_co_row = ((transition_map.skip_idx_to_name(post_co[0]), ) +
277
- (ROW_SPAN, ) * (transition_map.post_co_count - 1))
286
+ (COL_SPAN, ) * (transition_map.post_co_count - 1))
278
287
  post_co_col_span: tuple[str | int,
279
- ...] = ((COL_SPAN, ) +
280
- (COL_SPAN | ROW_SPAN, ) *
288
+ ...] = ((ROW_SPAN, ) +
289
+ (ROW_SPAN | COL_SPAN, ) *
281
290
  (transition_map.post_co_count - 1))
282
291
  else:
283
292
  post_co_row = tuple(
284
293
  transition_map.post_co_idx_st_idx_to_st_name(co_idx, st_idx)
285
294
  for co_idx, st_idx in enumerate(post_co[1:]))
286
- post_co_col_span = (COL_SPAN, ) * transition_map.post_co_count
295
+ post_co_col_span = (ROW_SPAN, ) * transition_map.post_co_count
287
296
  for pre_co in pre_co_collection:
288
297
  pre_co_row = tuple(
289
298
  _states(transition_map, co_idx, co_states)
290
299
  for co_idx, co_states in enumerate(pre_co))
291
300
  rows.append(pre_co_row + post_co_row)
292
301
  post_co_row = post_co_col_span
293
- content = SphinxContent()
302
+ content = create_content()
294
303
  content.add_grid_table(rows, header_rows=2)
295
304
  print(str(content))
296
305
 
@@ -365,10 +374,7 @@ def _prepare_mapper(mapper: ItemMapper) -> None:
365
374
  mapper.add_get_value(type_path_key, _get_value_dummy)
366
375
 
367
376
 
368
- def cliview(argv: list[str] = sys.argv):
369
- """ View the specification. """
370
-
371
- # pylint: disable=too-many-branches
377
+ def _parse_args(argv: list[str]) -> argparse.Namespace:
372
378
  parser = argparse.ArgumentParser()
373
379
  parser.add_argument("--config-file",
374
380
  type=str,
@@ -393,11 +399,23 @@ def cliview(argv: list[str] = sys.argv):
393
399
  "--enabled",
394
400
  help=("a comma separated list of enabled options used to evaluate "
395
401
  "enabled-by expressions"))
402
+ parser.add_argument("--format",
403
+ choices=["commonmark", "myst", "rest"],
404
+ type=str.lower,
405
+ default="rest",
406
+ help="the output format used to render tables")
396
407
  parser.add_argument("UIDs",
397
408
  metavar="UID",
398
409
  nargs="*",
399
410
  help="an UID of a specification item")
400
- args = parser.parse_args(argv[1:])
411
+ return parser.parse_args(argv[1:])
412
+
413
+
414
+ def cliview(argv: list[str] = sys.argv):
415
+ """ View the specification. """
416
+
417
+ # pylint: disable=too-many-branches
418
+ args = _parse_args(argv)
401
419
  config, working_directory = load_specware_config(args.config_file)
402
420
  with contextlib.chdir(working_directory):
403
421
  item_cache_config = create_config(config["spec"], ItemCacheConfig)
@@ -412,16 +430,17 @@ def cliview(argv: list[str] = sys.argv):
412
430
  root = item_cache["/req/root"]
413
431
  mapper = ItemMapper(root)
414
432
  _prepare_mapper(mapper)
433
+ create_content = _DOC_FORMAT[args.format]
415
434
 
416
435
  if args.filter == "action-table":
417
436
  for uid in args.UIDs:
418
- _action_table(item_cache[uid], False)
437
+ _action_table(item_cache[uid], False, create_content)
419
438
  elif args.filter == "action-table-show-skip":
420
439
  for uid in args.UIDs:
421
- _action_table(item_cache[uid], True)
440
+ _action_table(item_cache[uid], True, create_content)
422
441
  elif args.filter == "action-compact-table":
423
442
  for uid in args.UIDs:
424
- _action_compact_table(item_cache[uid])
443
+ _action_compact_table(item_cache[uid], create_content)
425
444
  elif args.filter == "action-list":
426
445
  for uid in args.UIDs:
427
446
  _action_list(item_cache[uid])
File without changes
File without changes
File without changes
File without changes
File without changes