generated from jCloud/repository-template
Compare commits
10
Commits
v0.2.2-rc0
...
v0.2.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
347bff5dac
|
||
|
|
7ff849387a
|
||
|
|
2b31b82a06
|
||
|
|
92dc2fcd47 | ||
|
|
b1727c100f
|
||
|
|
6ddbd17497
|
||
|
|
36bc14185a
|
||
|
|
39d3b0ace4
|
||
|
|
3f74e6457e
|
||
|
|
a6b5e8f1c9
|
No files matched your search
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.2.3] - 2026-10-21
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Escape sequences for pipe characters in values of Markdown table cells
|
||||||
|
|
||||||
## [0.2.2] - 2026-10-14
|
## [0.2.2] - 2026-10-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -116,106 +116,6 @@ Returns a list of the arguments as strings for a function signature.
|
|||||||
:return: The list of function signature argument strings.
|
:return: The list of function signature argument strings.
|
||||||
:rtype: list[str]
|
:rtype: list[str]
|
||||||
|
|
||||||
## Function `_fit_row_length`
|
|
||||||
|
|
||||||
Fits the row length to the expected length.
|
|
||||||
|
|
||||||
If the row is too long, the tail, that makes it too long, is omitted.
|
|
||||||
If it is too short, it is filled with ``None`` (at the end).
|
|
||||||
|
|
||||||
### Function signature
|
|
||||||
|
|
||||||
```python
|
|
||||||
_fit_row_length(expected: int, row: tuple) -> tuple
|
|
||||||
```
|
|
||||||
|
|
||||||
### Returns
|
|
||||||
|
|
||||||
Return type: `tuple`
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Kind | Default value | Description |
|
|
||||||
| --- | --- | --- | --- | --- |
|
|
||||||
| `expected` | `int` | normal | -- | The expected length. |
|
|
||||||
| `row` | `tuple` | normal | -- | The row. |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Docstring
|
|
||||||
|
|
||||||
Fits the row length to the expected length.
|
|
||||||
|
|
||||||
If the row is too long, the tail, that makes it too long, is omitted.
|
|
||||||
If it is too short, it is filled with ``None`` (at the end).
|
|
||||||
|
|
||||||
:param expected: The expected length.
|
|
||||||
:type expected: int
|
|
||||||
:param row: The row.
|
|
||||||
:type row: tuple
|
|
||||||
|
|
||||||
## Function `_markdown_table`
|
|
||||||
|
|
||||||
Generates a table.
|
|
||||||
|
|
||||||
If ``allow_markdown_table`` is ``False``, an alternative
|
|
||||||
representation is used.
|
|
||||||
|
|
||||||
### Function signature
|
|
||||||
|
|
||||||
```python
|
|
||||||
_markdown_table(header: tuple, body: list[tuple], *, allow_markdown_table: bool = False, force_row_lengths: bool = False, one_line_values: bool = True, missing_value: str = '--') -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
### Returns
|
|
||||||
|
|
||||||
Return type: `str`
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Kind | Default value | Description |
|
|
||||||
| --- | --- | --- | --- | --- |
|
|
||||||
| `header` | `tuple` | normal | -- | -- |
|
|
||||||
| `body` | `list[tuple]` | normal | -- | The table body. |
|
|
||||||
| `allow_markdown_table` | `bool` | keyword-only | `False` | Controls whether a markdown table may be used. |
|
|
||||||
| `force_row_lengths` | `bool` | keyword-only | `False` | Controls whether an exception is raised if a row does not have the correct length. |
|
|
||||||
| `one_line_values` | `bool` | keyword-only | `True` | Controls whether all newlines in all values are replaced with spaces. |
|
|
||||||
| `missing_value` | `str` | keyword-only | `'--'` | The string that is used if a value is missing (only if ``force_row_lengths`` is ``False``). |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Docstring
|
|
||||||
|
|
||||||
Generates a table.
|
|
||||||
|
|
||||||
If ``allow_markdown_table`` is ``False``, an alternative
|
|
||||||
representation is used.
|
|
||||||
|
|
||||||
:param headers: The table headers.
|
|
||||||
:type headers: tuple
|
|
||||||
:param body: The table body.
|
|
||||||
:type body: list[tuple]
|
|
||||||
:param allow_markdown_table: Controls whether a markdown table may be
|
|
||||||
used.
|
|
||||||
:type allow_markdown_table: bool
|
|
||||||
:param force_row_lengths: Controls whether an exception is raised if
|
|
||||||
a row does not have the correct length.
|
|
||||||
:type force_row_lengths: bool
|
|
||||||
:param one_line_values: Controls whether all newlines in all values
|
|
||||||
are replaced with spaces.
|
|
||||||
:type one_line_values: bool
|
|
||||||
:param missing_value: The string that is used if a value is missing
|
|
||||||
(only if ``force_row_lengths`` is ``False``).
|
|
||||||
:type missing_value: str
|
|
||||||
|
|
||||||
## Function `_is_docstring`
|
## Function `_is_docstring`
|
||||||
|
|
||||||
Checks whether the docstring is a docstring or an empty docstring.
|
Checks whether the docstring is a docstring or an empty docstring.
|
||||||
|
|||||||
@@ -340,4 +340,104 @@ Returns the path segments relative to ``root``.
|
|||||||
:type root: pathlib.Path
|
:type root: pathlib.Path
|
||||||
|
|
||||||
:return: The path segments relative to ``root``.
|
:return: The path segments relative to ``root``.
|
||||||
:rtype: list[str]
|
:rtype: list[str]
|
||||||
|
|
||||||
|
## Function `fit_row_length`
|
||||||
|
|
||||||
|
Fits the row length to the expected length.
|
||||||
|
|
||||||
|
If the row is too long, the tail, that makes it too long, is omitted.
|
||||||
|
If it is too short, it is filled with ``None`` (at the end).
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```python
|
||||||
|
fit_row_length(expected: int, row: tuple) -> tuple
|
||||||
|
```
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
|
Return type: `tuple`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Kind | Default value | Description |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| `expected` | `int` | normal | -- | The expected length. |
|
||||||
|
| `row` | `tuple` | normal | -- | The row. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Docstring
|
||||||
|
|
||||||
|
Fits the row length to the expected length.
|
||||||
|
|
||||||
|
If the row is too long, the tail, that makes it too long, is omitted.
|
||||||
|
If it is too short, it is filled with ``None`` (at the end).
|
||||||
|
|
||||||
|
:param expected: The expected length.
|
||||||
|
:type expected: int
|
||||||
|
:param row: The row.
|
||||||
|
:type row: tuple
|
||||||
|
|
||||||
|
## Function `markdown_table`
|
||||||
|
|
||||||
|
Generates a table.
|
||||||
|
|
||||||
|
If ``allow_markdown_table`` is ``False``, an alternative
|
||||||
|
representation is used.
|
||||||
|
|
||||||
|
### Function signature
|
||||||
|
|
||||||
|
```python
|
||||||
|
markdown_table(header: tuple, body: list[tuple], *, allow_markdown_table: bool = False, force_row_lengths: bool = False, one_line_values: bool = True, missing_value: str = '--') -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
|
Return type: `str`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Parameter | Type | Kind | Default value | Description |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| `header` | `tuple` | normal | -- | -- |
|
||||||
|
| `body` | `list[tuple]` | normal | -- | The table body. |
|
||||||
|
| `allow_markdown_table` | `bool` | keyword-only | `False` | Controls whether a markdown table may be used. |
|
||||||
|
| `force_row_lengths` | `bool` | keyword-only | `False` | Controls whether an exception is raised if a row does not have the correct length. |
|
||||||
|
| `one_line_values` | `bool` | keyword-only | `True` | Controls whether all newlines in all values are replaced with spaces. |
|
||||||
|
| `missing_value` | `str` | keyword-only | `'--'` | The string that is used if a value is missing (only if ``force_row_lengths`` is ``False``). |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Docstring
|
||||||
|
|
||||||
|
Generates a table.
|
||||||
|
|
||||||
|
If ``allow_markdown_table`` is ``False``, an alternative
|
||||||
|
representation is used.
|
||||||
|
|
||||||
|
:param headers: The table headers.
|
||||||
|
:type headers: tuple
|
||||||
|
:param body: The table body.
|
||||||
|
:type body: list[tuple]
|
||||||
|
:param allow_markdown_table: Controls whether a markdown table may be
|
||||||
|
used.
|
||||||
|
:type allow_markdown_table: bool
|
||||||
|
:param force_row_lengths: Controls whether an exception is raised if
|
||||||
|
a row does not have the correct length.
|
||||||
|
:type force_row_lengths: bool
|
||||||
|
:param one_line_values: Controls whether all newlines in all values
|
||||||
|
are replaced with spaces.
|
||||||
|
:type one_line_values: bool
|
||||||
|
:param missing_value: The string that is used if a value is missing
|
||||||
|
(only if ``force_row_lengths`` is ``False``).
|
||||||
|
:type missing_value: str
|
||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "jcloud-docsgen"
|
name = "jcloud-docsgen"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
description = "A tool that generates Markdown documentation for software project source code"
|
description = "A tool that generates Markdown documentation for software project source code"
|
||||||
dependencies = ["docstring-parser", "typing-extensions (>=4.16.0,<5.0.0)"]
|
dependencies = ["docstring-parser", "typing-extensions (>=4.16.0,<5.0.0)"]
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from ...exceptions import (
|
|||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
PythonArgumentStructureError,
|
PythonArgumentStructureError,
|
||||||
)
|
)
|
||||||
from ...utils import get_relative_path_segments, non_empty_str
|
from ...utils import get_relative_path_segments, markdown_table, non_empty_str
|
||||||
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
||||||
from .definitions import (
|
from .definitions import (
|
||||||
PythonAsyncFunctionDefinition,
|
PythonAsyncFunctionDefinition,
|
||||||
@@ -184,128 +184,6 @@ def _signature_argument_list(
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def _fit_row_length(expected: int, row: tuple) -> tuple:
|
|
||||||
"""
|
|
||||||
Fits the row length to the expected length.
|
|
||||||
|
|
||||||
If the row is too long, the tail, that makes it too long, is omitted.
|
|
||||||
If it is too short, it is filled with ``None`` (at the end).
|
|
||||||
|
|
||||||
:param expected: The expected length.
|
|
||||||
:type expected: int
|
|
||||||
:param row: The row.
|
|
||||||
:type row: tuple
|
|
||||||
"""
|
|
||||||
|
|
||||||
if expected < 0:
|
|
||||||
raise ValueError('expected must be larger than or equal 0.')
|
|
||||||
|
|
||||||
if len(row) > expected:
|
|
||||||
return row[:expected]
|
|
||||||
else:
|
|
||||||
return row + (None,) * (expected - len(row))
|
|
||||||
|
|
||||||
|
|
||||||
def _markdown_table(
|
|
||||||
header: tuple,
|
|
||||||
body: list[tuple],
|
|
||||||
*,
|
|
||||||
allow_markdown_table: bool = False,
|
|
||||||
force_row_lengths: bool = False,
|
|
||||||
one_line_values: bool = True,
|
|
||||||
missing_value: str = '--',
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Generates a table.
|
|
||||||
|
|
||||||
If ``allow_markdown_table`` is ``False``, an alternative
|
|
||||||
representation is used.
|
|
||||||
|
|
||||||
:param headers: The table headers.
|
|
||||||
:type headers: tuple
|
|
||||||
:param body: The table body.
|
|
||||||
:type body: list[tuple]
|
|
||||||
:param allow_markdown_table: Controls whether a markdown table may be
|
|
||||||
used.
|
|
||||||
:type allow_markdown_table: bool
|
|
||||||
:param force_row_lengths: Controls whether an exception is raised if
|
|
||||||
a row does not have the correct length.
|
|
||||||
:type force_row_lengths: bool
|
|
||||||
:param one_line_values: Controls whether all newlines in all values
|
|
||||||
are replaced with spaces.
|
|
||||||
:type one_line_values: bool
|
|
||||||
:param missing_value: The string that is used if a value is missing
|
|
||||||
(only if ``force_row_lengths`` is ``False``).
|
|
||||||
:type missing_value: str
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not header or not body:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
header_len = len(header)
|
|
||||||
|
|
||||||
if allow_markdown_table:
|
|
||||||
table = (
|
|
||||||
'| ' + ' | '.join(header) + ' |\n|' + ' --- |' * len(header) + '\n'
|
|
||||||
)
|
|
||||||
|
|
||||||
for row in body:
|
|
||||||
if len(row) != header_len:
|
|
||||||
if force_row_lengths:
|
|
||||||
raise ValueError(
|
|
||||||
f'expected {header_len} value'
|
|
||||||
f'{"s" if header_len > 1 else ""}, got {len(row)}'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
row = _fit_row_length(header_len, row)
|
|
||||||
|
|
||||||
table += (
|
|
||||||
'| '
|
|
||||||
+ ' | '.join(
|
|
||||||
[
|
|
||||||
str(col if col is not None else missing_value).replace(
|
|
||||||
'\n', ' '
|
|
||||||
)
|
|
||||||
if one_line_values
|
|
||||||
else str(col if col is not None else missing_value)
|
|
||||||
for col in row
|
|
||||||
]
|
|
||||||
)
|
|
||||||
+ ' |\n'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
table = ''
|
|
||||||
|
|
||||||
for row in body:
|
|
||||||
if len(row) != header_len:
|
|
||||||
if force_row_lengths:
|
|
||||||
raise ValueError(
|
|
||||||
f'expected {header_len} value'
|
|
||||||
f'{"s" if header_len > 1 else ""}, got {len(row)}'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
row = _fit_row_length(header_len, row)
|
|
||||||
|
|
||||||
sep = '- '
|
|
||||||
for i, col in enumerate(row):
|
|
||||||
table += (
|
|
||||||
sep
|
|
||||||
+ header[i]
|
|
||||||
+ ': '
|
|
||||||
+ (
|
|
||||||
str(col if col is not None else missing_value).replace(
|
|
||||||
'\n', ' '
|
|
||||||
)
|
|
||||||
if one_line_values
|
|
||||||
else str(col if col is not None else missing_value)
|
|
||||||
)
|
|
||||||
+ '\n\n'
|
|
||||||
)
|
|
||||||
sep = ' '
|
|
||||||
|
|
||||||
return table.strip()
|
|
||||||
|
|
||||||
|
|
||||||
def _is_docstring(docstring: str | PythonDocstring | None) -> bool:
|
def _is_docstring(docstring: str | PythonDocstring | None) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks whether the docstring is a docstring or an empty docstring.
|
Checks whether the docstring is a docstring or an empty docstring.
|
||||||
@@ -641,7 +519,7 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if params_types:
|
if params_types:
|
||||||
md += _markdown_table(
|
md += markdown_table(
|
||||||
['Parameter', 'Type', 'Kind', 'Default value', 'Description'],
|
['Parameter', 'Type', 'Kind', 'Default value', 'Description'],
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
@@ -720,7 +598,7 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
md += self.level * '#' + '# Exceptions\n\n'
|
md += self.level * '#' + '# Exceptions\n\n'
|
||||||
|
|
||||||
if self._docstring.raises:
|
if self._docstring.raises:
|
||||||
md += _markdown_table(
|
md += markdown_table(
|
||||||
('Exception', 'Description'),
|
('Exception', 'Description'),
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ __all__ = [
|
|||||||
'assert_that_is_instance',
|
'assert_that_is_instance',
|
||||||
'non_empty_str',
|
'non_empty_str',
|
||||||
'get_relative_path_segments',
|
'get_relative_path_segments',
|
||||||
|
'fit_row_length',
|
||||||
|
'markdown_table',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -237,3 +239,127 @@ def get_relative_path_segments(
|
|||||||
)
|
)
|
||||||
.parts,
|
.parts,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def fit_row_length(expected: int, row: tuple) -> tuple:
|
||||||
|
"""
|
||||||
|
Fits the row length to the expected length.
|
||||||
|
|
||||||
|
If the row is too long, the tail, that makes it too long, is omitted.
|
||||||
|
If it is too short, it is filled with ``None`` (at the end).
|
||||||
|
|
||||||
|
:param expected: The expected length.
|
||||||
|
:type expected: int
|
||||||
|
:param row: The row.
|
||||||
|
:type row: tuple
|
||||||
|
"""
|
||||||
|
|
||||||
|
if expected < 0:
|
||||||
|
raise ValueError('expected must be larger than or equal 0.')
|
||||||
|
|
||||||
|
if len(row) > expected:
|
||||||
|
return row[:expected]
|
||||||
|
else:
|
||||||
|
return row + (None,) * (expected - len(row))
|
||||||
|
|
||||||
|
|
||||||
|
def markdown_table(
|
||||||
|
header: tuple,
|
||||||
|
body: list[tuple],
|
||||||
|
*,
|
||||||
|
allow_markdown_table: bool = False,
|
||||||
|
force_row_lengths: bool = False,
|
||||||
|
one_line_values: bool = True,
|
||||||
|
missing_value: str = '--',
|
||||||
|
) -> str:
|
||||||
|
"""
|
||||||
|
Generates a table.
|
||||||
|
|
||||||
|
If ``allow_markdown_table`` is ``False``, an alternative
|
||||||
|
representation is used.
|
||||||
|
|
||||||
|
:param headers: The table headers.
|
||||||
|
:type headers: tuple
|
||||||
|
:param body: The table body.
|
||||||
|
:type body: list[tuple]
|
||||||
|
:param allow_markdown_table: Controls whether a markdown table may be
|
||||||
|
used.
|
||||||
|
:type allow_markdown_table: bool
|
||||||
|
:param force_row_lengths: Controls whether an exception is raised if
|
||||||
|
a row does not have the correct length.
|
||||||
|
:type force_row_lengths: bool
|
||||||
|
:param one_line_values: Controls whether all newlines in all values
|
||||||
|
are replaced with spaces.
|
||||||
|
:type one_line_values: bool
|
||||||
|
:param missing_value: The string that is used if a value is missing
|
||||||
|
(only if ``force_row_lengths`` is ``False``).
|
||||||
|
:type missing_value: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not header or not body:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
header_len = len(header)
|
||||||
|
|
||||||
|
if allow_markdown_table:
|
||||||
|
table = (
|
||||||
|
'| ' + ' | '.join(header) + ' |\n|' + ' --- |' * len(header) + '\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in body:
|
||||||
|
if len(row) != header_len:
|
||||||
|
if force_row_lengths:
|
||||||
|
raise ValueError(
|
||||||
|
f'expected {header_len} value'
|
||||||
|
f'{"s" if header_len > 1 else ""}, got {len(row)}'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
row = fit_row_length(header_len, row)
|
||||||
|
|
||||||
|
table += (
|
||||||
|
'| '
|
||||||
|
+ ' | '.join(
|
||||||
|
[
|
||||||
|
str(col if col is not None else missing_value)
|
||||||
|
.replace('\n', ' ')
|
||||||
|
.replace('|', '\\|')
|
||||||
|
if one_line_values
|
||||||
|
else str(
|
||||||
|
col if col is not None else missing_value
|
||||||
|
).replace('|', '\\|')
|
||||||
|
for col in row
|
||||||
|
]
|
||||||
|
)
|
||||||
|
+ ' |\n'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
table = ''
|
||||||
|
|
||||||
|
for row in body:
|
||||||
|
if len(row) != header_len:
|
||||||
|
if force_row_lengths:
|
||||||
|
raise ValueError(
|
||||||
|
f'expected {header_len} value'
|
||||||
|
f'{"s" if header_len > 1 else ""}, got {len(row)}'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
row = fit_row_length(header_len, row)
|
||||||
|
|
||||||
|
sep = '- '
|
||||||
|
for i, col in enumerate(row):
|
||||||
|
table += (
|
||||||
|
sep
|
||||||
|
+ header[i]
|
||||||
|
+ ': '
|
||||||
|
+ (
|
||||||
|
str(col if col is not None else missing_value).replace(
|
||||||
|
'\n', ' '
|
||||||
|
)
|
||||||
|
if one_line_values
|
||||||
|
else str(col if col is not None else missing_value)
|
||||||
|
)
|
||||||
|
+ '\n\n'
|
||||||
|
)
|
||||||
|
sep = ' '
|
||||||
|
|
||||||
|
return table.strip()
|
||||||
+1
-1
@@ -47,7 +47,7 @@ Return type: `User`
|
|||||||
| `user_id` | `str` | normal | -- | -- |
|
| `user_id` | `str` | normal | -- | -- |
|
||||||
| `name` | `str` | normal | -- | -- |
|
| `name` | `str` | normal | -- | -- |
|
||||||
| `email` | `str` | normal | -- | -- |
|
| `email` | `str` | normal | -- | -- |
|
||||||
| `age` | `int | None` | normal | `None` | -- |
|
| `age` | `int \| None` | normal | `None` | -- |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -250,8 +250,8 @@ Return type: `int | float`
|
|||||||
|
|
||||||
| Parameter | Type | Kind | Default value | Description |
|
| Parameter | Type | Kind | Default value | Description |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| `a` | `int | float` | normal | -- | The first number. |
|
| `a` | `int \\| float` | normal | -- | The first number. |
|
||||||
| `b` | `int | float` | normal | -- | The second number. |
|
| `b` | `int \\| float` | normal | -- | The second number. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -461,8 +461,8 @@ Return type: `int | float`
|
|||||||
|
|
||||||
| Parameter | Type | Kind | Default value | Description |
|
| Parameter | Type | Kind | Default value | Description |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| `a` | `int | float` | normal | -- | The first number. |
|
| `a` | `int \\| float` | normal | -- | The first number. |
|
||||||
| `b` | `int | float` | normal | -- | The second number. |
|
| `b` | `int \\| float` | normal | -- | The second number. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -672,8 +672,8 @@ Return type: `int | float`
|
|||||||
|
|
||||||
| Parameter | Type | Kind | Default value | Description |
|
| Parameter | Type | Kind | Default value | Description |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| `a` | `int | float` | normal | -- | The first number. |
|
| `a` | `int \\| float` | normal | -- | The first number. |
|
||||||
| `b` | `int | float` | normal | -- | The second number. |
|
| `b` | `int \\| float` | normal | -- | The second number. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _fit_row_length
|
from src.jcloud_docsgen.utils import fit_row_length
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -37,8 +37,8 @@ from src.jcloud_docsgen.core.python._core import _fit_row_length
|
|||||||
(3, (1, 2, 3), (1, 2, 3)),
|
(3, (1, 2, 3), (1, 2, 3)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__fit_row_length(expected_length, row, expected):
|
def test_fit_row_length(expected_length, row, expected):
|
||||||
assert _fit_row_length(expected_length, row) == expected
|
assert fit_row_length(expected_length, row) == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -60,7 +60,7 @@ def test__fit_row_length(expected_length, row, expected):
|
|||||||
(-42, ValueError),
|
(-42, ValueError),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__fit_row_length_exceptions(expected_length, row, expected_exception):
|
def test_fit_row_length_exceptions(expected_length, row, expected_exception):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
_fit_row_length(expected_length, row)
|
fit_row_length(expected_length, row)
|
||||||
assert str(exc_info.value) == 'expected must be larger than or equal 0.'
|
assert str(exc_info.value) == 'expected must be larger than or equal 0.'
|
||||||
+71
-5
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _markdown_table
|
from src.jcloud_docsgen.utils import markdown_table
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -138,6 +138,72 @@ from src.jcloud_docsgen.core.python._core import _markdown_table
|
|||||||
"""| a |
|
"""| a |
|
||||||
| --- |
|
| --- |
|
||||||
| line1\nline2 |""",
|
| line1\nline2 |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('line1\nline2 | 2',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
False,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| line1\nline2 \\| 2 |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('line1\nline2 | 2',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| line1 line2 \\| 2 |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('1 | 2',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| 1 \\| 2 |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('1 |',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| 1 \\| |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('|',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| \\| |""",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
['a'],
|
||||||
|
[('| 2',)],
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
'--',
|
||||||
|
"""| a |
|
||||||
|
| --- |
|
||||||
|
| \\| 2 |""",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[],
|
[],
|
||||||
@@ -252,7 +318,7 @@ from src.jcloud_docsgen.core.python._core import _markdown_table
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__markdown_table(
|
def test_markdown_table(
|
||||||
header,
|
header,
|
||||||
body,
|
body,
|
||||||
allow_markdown_table,
|
allow_markdown_table,
|
||||||
@@ -262,7 +328,7 @@ def test__markdown_table(
|
|||||||
expected,
|
expected,
|
||||||
):
|
):
|
||||||
assert (
|
assert (
|
||||||
_markdown_table(
|
markdown_table(
|
||||||
header,
|
header,
|
||||||
body,
|
body,
|
||||||
allow_markdown_table=allow_markdown_table,
|
allow_markdown_table=allow_markdown_table,
|
||||||
@@ -402,7 +468,7 @@ def test__markdown_table(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__markdown_table_exceptions(
|
def test_markdown_table_exceptions(
|
||||||
header,
|
header,
|
||||||
body,
|
body,
|
||||||
allow_markdown_table,
|
allow_markdown_table,
|
||||||
@@ -413,7 +479,7 @@ def test__markdown_table_exceptions(
|
|||||||
expected_exception_msg,
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
_markdown_table(
|
markdown_table(
|
||||||
header,
|
header,
|
||||||
body,
|
body,
|
||||||
allow_markdown_table=allow_markdown_table,
|
allow_markdown_table=allow_markdown_table,
|
||||||
Reference in new issue
Block a user