specitems 1.4.0__tar.gz → 1.4.2__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.
Files changed (24) hide show
  1. {specitems-1.4.0 → specitems-1.4.2}/PKG-INFO +1 -1
  2. {specitems-1.4.0 → specitems-1.4.2}/pyproject.toml +1 -1
  3. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/contentmarkdown.py +33 -7
  4. {specitems-1.4.0 → specitems-1.4.2}/README.md +0 -0
  5. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/__init__.py +0 -0
  6. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/cite.py +0 -0
  7. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/clihash.py +0 -0
  8. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/clipickle.py +0 -0
  9. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/clispecdoc.py +0 -0
  10. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/cliutil.py +0 -0
  11. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/cliyamlquery.py +0 -0
  12. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/content.py +0 -0
  13. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/contentsphinx.py +0 -0
  14. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/contenttext.py +0 -0
  15. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/getvaluesubprocess.py +0 -0
  16. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/glossary.py +0 -0
  17. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/hashutil.py +0 -0
  18. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/itemmapper.py +0 -0
  19. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/items.py +0 -0
  20. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/py.typed +0 -0
  21. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/spec.pickle +0 -0
  22. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/specdoc.py +0 -0
  23. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/specverify.py +0 -0
  24. {specitems-1.4.0 → specitems-1.4.2}/src/specitems/subprocessaction.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: specitems
3
- Version: 1.4.0
3
+ Version: 1.4.2
4
4
  Summary: Provides interfaces to work with specification items.
5
5
  Keywords: certification,documentation,markdown,qualification,requirements-management,traceability
6
6
  Author: The specitems Authors
@@ -4,7 +4,7 @@
4
4
 
5
5
  [project]
6
6
  name = "specitems"
7
- version = "1.4.0"
7
+ version = "1.4.2"
8
8
  description = "Provides interfaces to work with specification items."
9
9
  authors = [
10
10
  {name = "The specitems Authors", email = "specthings@embedded-brains.de"}
@@ -46,12 +46,17 @@ def _md_escape(match: Match) -> str:
46
46
  return f"\\{match.group(0)}"
47
47
 
48
48
 
49
+ def _simple_row(row: Iterable[str], maxi: Iterable[int]) -> str:
50
+ line = " | ".join(f"{cell:{width}}" for cell, width in zip(row, maxi))
51
+ return f" | {line} |"
52
+
53
+
49
54
  class MarkdownContent(TextContent):
50
55
  """ This class builds MyST Markdown content. """
51
56
 
52
57
  # pylint: disable=too-many-public-methods
53
58
  def __init__(self,
54
- section_level: int = 1,
59
+ section_level: int = 0,
55
60
  the_license: str | set[str] | None = None):
56
61
  super().__init__(section_level, the_license)
57
62
  self.set_pop_indent_gap(True)
@@ -91,10 +96,13 @@ class MarkdownContent(TextContent):
91
96
  def add_label(self, label: str) -> None:
92
97
  self.add(f"({label.strip()})=")
93
98
 
94
- def add_header(self, name, level=1, label=None) -> None:
99
+ def add_header(self,
100
+ name: str,
101
+ level: int = 0,
102
+ label: Optional[str] = None) -> None:
95
103
  if label is not None:
96
104
  self.add_label(label)
97
- self.add([f"{level * '#'} {name.strip()}", ""])
105
+ self.add([f"#{level * '#'} {name.strip()}", ""])
98
106
 
99
107
  def add_rubric(self, name: str) -> None:
100
108
  self.add(["```{eval-rst}", f".. rubric:: {name}", "```", ""])
@@ -125,10 +133,28 @@ class MarkdownContent(TextContent):
125
133
  font_size: Optional[str | int] = None) -> None:
126
134
  if not rows:
127
135
  return
128
- with self.directive("eval-rst"):
129
- table = SphinxContent()
130
- table.add_simple_table(rows, widths, font_size)
131
- self.add(table)
136
+ if not widths and font_size is None:
137
+ escaped_rows: list[tuple[str, ...]] = []
138
+ maxi = tuple(map(len, rows[0]))
139
+ for row in rows:
140
+ escaped_row = tuple(cell.replace("|", "\\|") for cell in row)
141
+ escaped_rows.append(escaped_row)
142
+ row_lengths = tuple(map(len, escaped_row))
143
+ maxi = tuple(map(max, zip(maxi, row_lengths)))
144
+
145
+ # At least three dashes are required for a table
146
+ maxi = tuple(max(width, 3) for width in maxi)
147
+
148
+ sep = " | ".join(f"{'-' * width}" for width in maxi)
149
+ sep = f" | {sep} |"
150
+ lines = [_simple_row(escaped_rows[0], maxi), sep]
151
+ lines.extend(_simple_row(row, maxi) for row in escaped_rows[1:])
152
+ self.add(lines)
153
+ else:
154
+ with self.directive("eval-rst"):
155
+ table = SphinxContent()
156
+ table.add_simple_table(rows, widths, font_size)
157
+ self.add(table)
132
158
 
133
159
  def add_grid_table(self,
134
160
  rows: Sequence[Iterable[str | int]],
File without changes