robotcode-robot 2.9.0.dev115__tar.gz → 2.9.0.dev180__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.
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/PKG-INFO +2 -2
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/pyproject.toml +1 -1
- robotcode_robot-2.9.0.dev180/src/robotcode/robot/__version__.py +1 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/library_doc.py +64 -24
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/markdown_docs.py +34 -1
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/markdownformatter.py +60 -28
- robotcode_robot-2.9.0.dev115/src/robotcode/robot/__version__.py +0 -1
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/.gitignore +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/README.md +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/__init__.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/__init__.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/loader.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/model.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/utils.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/__init__.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/analyzer_result.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/data_cache.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/diagnostic_rules.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/diagnostics_modifier.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/document_cache_helper.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/entities.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/errors.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/import_resolver.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/imports_manager.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/keyword_finder.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/model_helper.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/namespace.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/namespace_analyzer.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/project_index.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/scope_tree.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/__init__.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/analyzer.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/enums.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/json_dump.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/model.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/nodes.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/run_keyword.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/serialization.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/semantic_analyzer/variable_tokenizer.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/variable_scope.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/diagnostics/workspace_config.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/py.typed +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/__init__.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/ast.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/match.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/robot_patching.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/robot_path.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/stubs.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/variables.py +0 -0
- {robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/visitor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: robotcode-robot
|
|
3
|
-
Version: 2.9.0-dev.
|
|
3
|
+
Version: 2.9.0-dev.180
|
|
4
4
|
Summary: Support classes for RobotCode for handling Robot Framework projects.
|
|
5
5
|
Project-URL: Homepage, https://robotcode.io
|
|
6
6
|
Project-URL: Donate, https://opencollective.com/robotcode
|
|
@@ -27,7 +27,7 @@ Classifier: Topic :: Utilities
|
|
|
27
27
|
Classifier: Typing :: Typed
|
|
28
28
|
Requires-Python: >=3.10
|
|
29
29
|
Requires-Dist: platformdirs>=4.3
|
|
30
|
-
Requires-Dist: robotcode-core==2.9.0-dev.
|
|
30
|
+
Requires-Dist: robotcode-core==2.9.0-dev.180
|
|
31
31
|
Requires-Dist: robotframework>=5.0.0
|
|
32
32
|
Requires-Dist: tomli>=1.1.0; python_version < '3.11'
|
|
33
33
|
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.9.0-dev.180"
|
|
@@ -90,6 +90,7 @@ from ..utils.markdown_docs import (
|
|
|
90
90
|
code_span,
|
|
91
91
|
code_span_variables,
|
|
92
92
|
escape_link_text,
|
|
93
|
+
escape_text,
|
|
93
94
|
extract_reference_definitions,
|
|
94
95
|
heading_anchors,
|
|
95
96
|
iter_headings,
|
|
@@ -99,6 +100,7 @@ from ..utils.markdown_docs import (
|
|
|
99
100
|
section_anchors,
|
|
100
101
|
shift_headings,
|
|
101
102
|
slugify,
|
|
103
|
+
unescape_text,
|
|
102
104
|
unique_reference_labels,
|
|
103
105
|
)
|
|
104
106
|
from ..utils.markdownformatter import MarkDownFormatter, NameLinker
|
|
@@ -241,18 +243,17 @@ def _page_heading_shift(doc_format: str, levels: int) -> Optional[Callable[[str]
|
|
|
241
243
|
|
|
242
244
|
|
|
243
245
|
# A run of `#` after a space at the end of a keyword name would close its ATX heading: `### Use C #` shows "Use C".
|
|
244
|
-
_RE_CLOSING_HASHES = re.compile(r"(\s)(#+)$")
|
|
245
|
-
_RE_ESCAPED_CLOSING_HASHES = re.compile(r"(\s)\\(#+)$")
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
def _heading_name(name: str) -> str:
|
|
249
|
-
"""A keyword name as the title of its heading:
|
|
250
|
-
|
|
249
|
+
"""A keyword name as the title of its heading: what Markdown would read as markup escaped,
|
|
250
|
+
also a closing run of `#`."""
|
|
251
|
+
return escape_text(name)
|
|
251
252
|
|
|
252
253
|
|
|
253
254
|
def _heading_title_name(title: str) -> str:
|
|
254
255
|
"""The keyword name of a heading title that `_heading_name` wrote."""
|
|
255
|
-
return
|
|
256
|
+
return unescape_text(title)
|
|
256
257
|
|
|
257
258
|
|
|
258
259
|
def _match_heading_anchors(headings: List[Tuple[str, str]], titles: List[Set[str]]) -> List[str]:
|
|
@@ -1161,14 +1162,16 @@ class KeywordDoc(SourceEntity):
|
|
|
1161
1162
|
*,
|
|
1162
1163
|
link_resolver: Optional[LinkResolver] = None,
|
|
1163
1164
|
reference_targets: Optional[Mapping[str, ReferenceTarget]] = None,
|
|
1165
|
+
ascii_only: bool = False,
|
|
1164
1166
|
) -> str:
|
|
1167
|
+
"""`ascii_only` marks the kinds of arguments as Libdoc does, for text written to a console."""
|
|
1165
1168
|
result = ""
|
|
1166
1169
|
|
|
1167
1170
|
# a library that renders all of its keywords builds the targets once
|
|
1168
1171
|
targets = reference_targets if reference_targets is not None else self.get_reference_targets()
|
|
1169
1172
|
|
|
1170
1173
|
if add_signature:
|
|
1171
|
-
result += self._get_signature(header_level, add_type, link_resolver, targets)
|
|
1174
|
+
result += self._get_signature(header_level, add_type, link_resolver, targets, ascii_only=ascii_only)
|
|
1172
1175
|
|
|
1173
1176
|
if self.doc:
|
|
1174
1177
|
if result:
|
|
@@ -1257,11 +1260,14 @@ class KeywordDoc(SourceEntity):
|
|
|
1257
1260
|
return first + "\n".join([lines[0], *(f" {line}" if line else "" for line in lines[1:])])
|
|
1258
1261
|
|
|
1259
1262
|
@staticmethod
|
|
1260
|
-
def _get_argument_prefix(argument: ArgumentInfo) -> str:
|
|
1263
|
+
def _get_argument_prefix(argument: ArgumentInfo, ascii_only: bool = False) -> str:
|
|
1261
1264
|
if argument.kind == KeywordArgumentKind.VAR_POSITIONAL:
|
|
1262
1265
|
return "*"
|
|
1263
1266
|
if argument.kind == KeywordArgumentKind.VAR_NAMED:
|
|
1264
1267
|
return "**"
|
|
1268
|
+
if ascii_only:
|
|
1269
|
+
# the `/` and `*` marker entries of the argument list show these kinds
|
|
1270
|
+
return ""
|
|
1265
1271
|
if argument.kind == KeywordArgumentKind.NAMED_ONLY:
|
|
1266
1272
|
return "🏷"
|
|
1267
1273
|
if argument.kind == KeywordArgumentKind.POSITIONAL_ONLY:
|
|
@@ -1303,6 +1309,7 @@ class KeywordDoc(SourceEntity):
|
|
|
1303
1309
|
link_resolver: Optional[LinkResolver] = None,
|
|
1304
1310
|
targets: Optional[Mapping[str, ReferenceTarget]] = None,
|
|
1305
1311
|
with_descriptions: bool = False,
|
|
1312
|
+
ascii_only: bool = False,
|
|
1306
1313
|
) -> str:
|
|
1307
1314
|
"""The arguments as a table; with descriptions, they get a fifth column."""
|
|
1308
1315
|
result = "\n| | | | | |" if with_descriptions else "\n| | | | |"
|
|
@@ -1328,9 +1335,16 @@ class KeywordDoc(SourceEntity):
|
|
|
1328
1335
|
return f"{cells} {description} |" if with_descriptions else cells
|
|
1329
1336
|
|
|
1330
1337
|
for a in arguments:
|
|
1338
|
+
if a.kind in [KeywordArgumentKind.NAMED_ONLY_MARKER, KeywordArgumentKind.POSITIONAL_ONLY_MARKER]:
|
|
1339
|
+
result += row(a.str_repr, (), None, None, "")
|
|
1340
|
+
continue
|
|
1331
1341
|
description = self._description_cell(a.doc, link_resolver, targets) if with_descriptions and a.doc else ""
|
|
1332
1342
|
result += row(
|
|
1333
|
-
f"{self._get_argument_prefix(a)}{a.name!s}",
|
|
1343
|
+
f"{self._get_argument_prefix(a, ascii_only)}{a.name!s}",
|
|
1344
|
+
a.types or (),
|
|
1345
|
+
a.type_docs,
|
|
1346
|
+
a.default_value,
|
|
1347
|
+
description,
|
|
1334
1348
|
)
|
|
1335
1349
|
if with_descriptions:
|
|
1336
1350
|
# names the documentation describes without being arguments, like ones taken by `**kwargs`
|
|
@@ -1344,11 +1358,14 @@ class KeywordDoc(SourceEntity):
|
|
|
1344
1358
|
add_type: bool = True,
|
|
1345
1359
|
link_resolver: Optional[LinkResolver] = None,
|
|
1346
1360
|
targets: Optional[Mapping[str, ReferenceTarget]] = None,
|
|
1361
|
+
*,
|
|
1362
|
+
ascii_only: bool = False,
|
|
1347
1363
|
) -> str:
|
|
1348
1364
|
if add_type:
|
|
1349
1365
|
result = (
|
|
1350
1366
|
f"#{'#' * header_level} "
|
|
1351
|
-
f"{(self.libtype or 'Library').capitalize() if self.is_initializer else 'Keyword'}
|
|
1367
|
+
f"{(self.libtype or 'Library').capitalize() if self.is_initializer else 'Keyword'} "
|
|
1368
|
+
f"*{_heading_name(self.name)}*\n"
|
|
1352
1369
|
)
|
|
1353
1370
|
else:
|
|
1354
1371
|
if not self.is_initializer:
|
|
@@ -1356,17 +1373,21 @@ class KeywordDoc(SourceEntity):
|
|
|
1356
1373
|
else:
|
|
1357
1374
|
result = ""
|
|
1358
1375
|
|
|
1376
|
+
# on the console, the `/` and `*` markers stand in the table as in Libdoc's signature
|
|
1359
1377
|
arguments = [
|
|
1360
1378
|
a
|
|
1361
1379
|
for a in self.arguments
|
|
1362
|
-
if
|
|
1380
|
+
if ascii_only
|
|
1381
|
+
or a.kind not in [KeywordArgumentKind.NAMED_ONLY_MARKER, KeywordArgumentKind.POSITIONAL_ONLY_MARKER]
|
|
1363
1382
|
]
|
|
1364
1383
|
has_descriptions = any(a.doc for a in arguments) or bool(self.extra_argument_docs)
|
|
1365
1384
|
|
|
1366
1385
|
if self.arguments or has_descriptions:
|
|
1367
1386
|
result += f"\n##{'#' * header_level} Arguments: \n"
|
|
1368
1387
|
|
|
1369
|
-
result += self._get_argument_table(
|
|
1388
|
+
result += self._get_argument_table(
|
|
1389
|
+
arguments, link_resolver, targets, with_descriptions=has_descriptions, ascii_only=ascii_only
|
|
1390
|
+
)
|
|
1370
1391
|
|
|
1371
1392
|
if self.return_type:
|
|
1372
1393
|
if result:
|
|
@@ -1376,7 +1397,8 @@ class KeywordDoc(SourceEntity):
|
|
|
1376
1397
|
f"**Return Type**: {_type_markdown(self.return_type, self.return_type_docs, link_resolver, False)}"
|
|
1377
1398
|
)
|
|
1378
1399
|
if self.return_doc:
|
|
1379
|
-
|
|
1400
|
+
dash = " - " if ascii_only else " — "
|
|
1401
|
+
result += f"{dash}{self._format_description(self.return_doc, link_resolver, targets)}"
|
|
1380
1402
|
result += "\n"
|
|
1381
1403
|
elif self.return_doc:
|
|
1382
1404
|
if result:
|
|
@@ -1418,7 +1440,10 @@ class KeywordDoc(SourceEntity):
|
|
|
1418
1440
|
+ ")"
|
|
1419
1441
|
)
|
|
1420
1442
|
|
|
1421
|
-
def parameter_signature(self, full_signatures: Optional[Sequence[int]] = None) -> str:
|
|
1443
|
+
def parameter_signature(self, full_signatures: Optional[Sequence[int]] = None, *, ascii_only: bool = False) -> str:
|
|
1444
|
+
if ascii_only:
|
|
1445
|
+
# Libdoc's signature: `table, /, column, *names, limit: int = 10, **options`
|
|
1446
|
+
return "(" + ", ".join(a.str_repr for a in self.arguments) + ")"
|
|
1422
1447
|
return (
|
|
1423
1448
|
"("
|
|
1424
1449
|
+ ", ".join(
|
|
@@ -1880,9 +1905,10 @@ class LibraryDoc:
|
|
|
1880
1905
|
header_level: int = 2,
|
|
1881
1906
|
*,
|
|
1882
1907
|
link_resolver: Optional[LinkResolver] = None,
|
|
1908
|
+
ascii_only: bool = False,
|
|
1883
1909
|
) -> str:
|
|
1884
1910
|
if not only_doc:
|
|
1885
|
-
return self._page_to_markdown(header_level, link_resolver)
|
|
1911
|
+
return self._page_to_markdown(header_level, link_resolver, ascii_only=ascii_only)
|
|
1886
1912
|
|
|
1887
1913
|
with io.StringIO(newline="\n") as result:
|
|
1888
1914
|
|
|
@@ -1899,7 +1925,10 @@ class LibraryDoc:
|
|
|
1899
1925
|
if add_signature and any(v for v in self.inits.values() if v.arguments):
|
|
1900
1926
|
for i in self.inits.values():
|
|
1901
1927
|
init_markdown = i.to_markdown(
|
|
1902
|
-
header_level=header_level,
|
|
1928
|
+
header_level=header_level,
|
|
1929
|
+
link_resolver=link_resolver,
|
|
1930
|
+
reference_targets=targets,
|
|
1931
|
+
ascii_only=ascii_only,
|
|
1903
1932
|
)
|
|
1904
1933
|
write_lines(init_markdown, "", "---")
|
|
1905
1934
|
|
|
@@ -1976,9 +2005,11 @@ class LibraryDoc:
|
|
|
1976
2005
|
|
|
1977
2006
|
return keyword_anchors, {t.name: anchor for t, anchor in zip(page_types, type_anchors) if anchor}
|
|
1978
2007
|
|
|
1979
|
-
def _page_to_markdown(
|
|
2008
|
+
def _page_to_markdown(
|
|
2009
|
+
self, header_level: int, link_resolver: Optional[LinkResolver], *, ascii_only: bool = False
|
|
2010
|
+
) -> str:
|
|
1980
2011
|
"""The full page of `robotcode doc lib`, the REPL's `.doc` and the documentation view."""
|
|
1981
|
-
head, keywords, tail = self._get_page_parts(header_level, link_resolver)
|
|
2012
|
+
head, keywords, tail = self._get_page_parts(header_level, link_resolver, ascii_only=ascii_only)
|
|
1982
2013
|
|
|
1983
2014
|
# Only the assembled page knows its headings: an anchor can carry a number, and a
|
|
1984
2015
|
# private keyword or a section the page leaves out has no heading at all.
|
|
@@ -1993,9 +2024,9 @@ class LibraryDoc:
|
|
|
1993
2024
|
for level, title, anchor in heading_anchors(page):
|
|
1994
2025
|
if level == header_level + 2:
|
|
1995
2026
|
in_introduction = title == "Introduction"
|
|
1996
|
-
section_anchors_by_title.setdefault(normalize_reference(title), anchor)
|
|
2027
|
+
section_anchors_by_title.setdefault(normalize_reference(_heading_title_name(title)), anchor)
|
|
1997
2028
|
elif level > header_level + 2 and in_introduction:
|
|
1998
|
-
introduction.setdefault(normalize_reference(title), anchor)
|
|
2029
|
+
introduction.setdefault(normalize_reference(_heading_title_name(title)), anchor)
|
|
1999
2030
|
section_anchors_by_title.update(introduction)
|
|
2000
2031
|
_, type_anchors = self.get_page_anchors(page, header_level)
|
|
2001
2032
|
|
|
@@ -2010,7 +2041,7 @@ class LibraryDoc:
|
|
|
2010
2041
|
anchor = anchors.get(normalize_reference(name))
|
|
2011
2042
|
return f"#{anchor}" if anchor is not None else None
|
|
2012
2043
|
|
|
2013
|
-
head, keywords, tail = self._get_page_parts(header_level, resolver)
|
|
2044
|
+
head, keywords, tail = self._get_page_parts(header_level, resolver, ascii_only=ascii_only)
|
|
2014
2045
|
|
|
2015
2046
|
page = head + keywords + tail
|
|
2016
2047
|
if keywords:
|
|
@@ -2027,7 +2058,9 @@ class LibraryDoc:
|
|
|
2027
2058
|
|
|
2028
2059
|
return f"{page.rstrip()}\n"
|
|
2029
2060
|
|
|
2030
|
-
def _get_page_parts(
|
|
2061
|
+
def _get_page_parts(
|
|
2062
|
+
self, header_level: int, link_resolver: Optional[LinkResolver], *, ascii_only: bool = False
|
|
2063
|
+
) -> Tuple[str, str, str]:
|
|
2031
2064
|
"""The page up to the keyword entries, the keyword entries, and the rest of the page."""
|
|
2032
2065
|
targets = self.get_reference_targets()
|
|
2033
2066
|
separator = "\n\n---\n\n"
|
|
@@ -2044,7 +2077,9 @@ class LibraryDoc:
|
|
|
2044
2077
|
if any(v for v in self.inits.values() if v.arguments):
|
|
2045
2078
|
head = f"{head.rstrip()}{separator}##{'#' * header_level} Importing\n\n"
|
|
2046
2079
|
head += separator.join(
|
|
2047
|
-
unique_reference_labels(
|
|
2080
|
+
unique_reference_labels(
|
|
2081
|
+
self._get_page_entry(kw, header_level, link_resolver, targets, ascii_only), labels
|
|
2082
|
+
)
|
|
2048
2083
|
for kw in self.inits.values()
|
|
2049
2084
|
)
|
|
2050
2085
|
|
|
@@ -2053,7 +2088,9 @@ class LibraryDoc:
|
|
|
2053
2088
|
if page_keywords:
|
|
2054
2089
|
head = f"{head.rstrip()}{separator}##{'#' * header_level} Keywords\n\n"
|
|
2055
2090
|
keywords = separator.join(
|
|
2056
|
-
unique_reference_labels(
|
|
2091
|
+
unique_reference_labels(
|
|
2092
|
+
self._get_page_entry(kw, header_level, link_resolver, targets, ascii_only), labels
|
|
2093
|
+
)
|
|
2057
2094
|
for kw in page_keywords
|
|
2058
2095
|
)
|
|
2059
2096
|
|
|
@@ -2102,6 +2139,7 @@ class LibraryDoc:
|
|
|
2102
2139
|
header_level: int,
|
|
2103
2140
|
link_resolver: Optional[LinkResolver],
|
|
2104
2141
|
targets: Mapping[str, ReferenceTarget],
|
|
2142
|
+
ascii_only: bool = False,
|
|
2105
2143
|
) -> str:
|
|
2106
2144
|
return kw.to_markdown(
|
|
2107
2145
|
header_level=header_level + 2,
|
|
@@ -2110,6 +2148,7 @@ class LibraryDoc:
|
|
|
2110
2148
|
modify_doc_handler=_page_heading_shift(kw.doc_format, header_level + 3),
|
|
2111
2149
|
link_resolver=link_resolver,
|
|
2112
2150
|
reference_targets=targets,
|
|
2151
|
+
ascii_only=ascii_only,
|
|
2113
2152
|
).strip()
|
|
2114
2153
|
|
|
2115
2154
|
@property
|
|
@@ -2190,9 +2229,10 @@ class VariablesDoc(LibraryDoc):
|
|
|
2190
2229
|
header_level: int = 2,
|
|
2191
2230
|
*,
|
|
2192
2231
|
link_resolver: Optional[LinkResolver] = None,
|
|
2232
|
+
ascii_only: bool = False,
|
|
2193
2233
|
) -> str:
|
|
2194
2234
|
result = super(VariablesDoc, self).to_markdown(
|
|
2195
|
-
add_signature, only_doc, header_level, link_resolver=link_resolver
|
|
2235
|
+
add_signature, only_doc, header_level, link_resolver=link_resolver, ascii_only=ascii_only
|
|
2196
2236
|
)
|
|
2197
2237
|
|
|
2198
2238
|
if self.variables:
|
|
@@ -22,6 +22,7 @@ __all__ = [
|
|
|
22
22
|
"code_span",
|
|
23
23
|
"code_span_variables",
|
|
24
24
|
"escape_link_text",
|
|
25
|
+
"escape_text",
|
|
25
26
|
"extract_reference_definitions",
|
|
26
27
|
"heading_anchors",
|
|
27
28
|
"iter_headings",
|
|
@@ -35,6 +36,7 @@ __all__ = [
|
|
|
35
36
|
"section_anchors",
|
|
36
37
|
"shift_headings",
|
|
37
38
|
"slugify",
|
|
39
|
+
"unescape_text",
|
|
38
40
|
"unique_reference_labels",
|
|
39
41
|
]
|
|
40
42
|
|
|
@@ -148,6 +150,36 @@ def escape_link_text(text: str) -> str:
|
|
|
148
150
|
return _RE_LINK_TEXT_SPECIAL.sub(r"\\\1", text)
|
|
149
151
|
|
|
150
152
|
|
|
153
|
+
_RE_TEXT_SPECIAL = re.compile(
|
|
154
|
+
r"""
|
|
155
|
+
\\(?=[!-/:-@\[-`{-~]|\Z) # a backslash before ASCII punctuation or at the end
|
|
156
|
+
| [<\#`] # always
|
|
157
|
+
| (?<!\s)\* | \*(?!\s) # a star, unless it has space on both sides
|
|
158
|
+
| (?<![^\W_])_ | _(?![^\W_]) # an underscore, unless it is inside a word
|
|
159
|
+
| &(?=\#?\w+;) # what reads as an entity
|
|
160
|
+
| \](?=\() # what reads as an inline link
|
|
161
|
+
| ~(?=~) | (?<=~)~ # what reads as strikethrough
|
|
162
|
+
""",
|
|
163
|
+
re.VERBOSE,
|
|
164
|
+
)
|
|
165
|
+
_RE_ESCAPED_VARIABLE = re.compile(r"(?<!\\)((?:\\\\)+)\$")
|
|
166
|
+
_RE_MARKDOWN_ESCAPE = re.compile(r"\\([!-/:-@\[-`{-~])")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def escape_text(text: str) -> str:
|
|
170
|
+
"""Escape what Markdown would read as markup in text that is meant as text, only where
|
|
171
|
+
it would change the text: `snake_case`, `${list}[0]` and `2 * 3` stay as they are.
|
|
172
|
+
|
|
173
|
+
An odd number of backslashes before `$` is an escaped variable and stays one."""
|
|
174
|
+
text = _RE_TEXT_SPECIAL.sub(r"\\\g<0>", text)
|
|
175
|
+
return _RE_ESCAPED_VARIABLE.sub(lambda m: m.group(1) + ("\\$" if len(m.group(1)) % 4 else "$"), text)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def unescape_text(text: str) -> str:
|
|
179
|
+
"""The text that Markdown shows for `text`, without its escapes."""
|
|
180
|
+
return _RE_MARKDOWN_ESCAPE.sub(r"\1", text)
|
|
181
|
+
|
|
182
|
+
|
|
151
183
|
def anchor_link_resolver(kind: str, name: str) -> Optional[str]:
|
|
152
184
|
"""A `LinkResolver` for pages that show a whole library: keywords and
|
|
153
185
|
sections have a heading there. The heading of a type can carry a number,
|
|
@@ -555,7 +587,8 @@ def _code_span_variables_in(text: str) -> str:
|
|
|
555
587
|
# variables that follow each other directly share one code span: `${TEMPDIR}${/}`
|
|
556
588
|
while (following := search_variable(text[end:], "$", ignore_errors=True)).start == 0:
|
|
557
589
|
end += following.end
|
|
558
|
-
|
|
590
|
+
# inside code an escape would show
|
|
591
|
+
result.append(text[: match.start] + code_span(unescape_text(text[match.start : end])))
|
|
559
592
|
text = text[end:]
|
|
560
593
|
result.append(text)
|
|
561
594
|
return "".join(result)
|
|
@@ -5,7 +5,7 @@ import re
|
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
6
|
from typing import Any, Callable, Final, Iterator, List, Optional, Tuple
|
|
7
7
|
|
|
8
|
-
from .markdown_docs import code_span, escape_link_text
|
|
8
|
+
from .markdown_docs import code_span, escape_link_text, escape_text
|
|
9
9
|
|
|
10
10
|
# Gets a name in single backticks of documentation in Robot Framework's format and
|
|
11
11
|
# returns the target of a link to it, or `None` if it stays inline code.
|
|
@@ -19,10 +19,15 @@ _RE_CODE_SPAN: Final["re.Pattern[str]"] = re.compile(
|
|
|
19
19
|
| (?<!`) (`+) (?!`) # a run of backticks (group 1)
|
|
20
20
|
([^\ue000]+?) # anything but code that is already held (group 2)
|
|
21
21
|
(?<!`) \1 (?!`) # up to the next run of the same length
|
|
22
|
-
| `+ # a run of backticks without a partner
|
|
23
22
|
""",
|
|
24
23
|
re.VERBOSE,
|
|
25
24
|
)
|
|
25
|
+
# the documentation's own characters that the conversion uses
|
|
26
|
+
_RE_OWN_MARKERS: Final["re.Pattern[str]"] = re.compile("[\ue000\ue002\ue003]")
|
|
27
|
+
# what is no text: held code (group 1) and the syntax the formatter writes itself (group 2)
|
|
28
|
+
_RE_NOT_TEXT: Final["re.Pattern[str]"] = re.compile("(\ue000\\d+\ue001)|\ue002(.*?)\ue003")
|
|
29
|
+
# what starts a Markdown block: a quote, a list or a reference definition (group 1), a numbered list (groups 2 and 3)
|
|
30
|
+
_RE_BLOCK_START: Final["re.Pattern[str]"] = re.compile(r"^(?:(>|[+-](?=\s|$)|\[(?=[^\]]*\]:))|(\d{1,9})([.)])(?=\s|$))")
|
|
26
31
|
_RE_THREE_BACKTICKS: Final["re.Pattern[str]"] = re.compile("(?<!`)```(?!`)")
|
|
27
32
|
_RE_LONG_BACKTICKS: Final["re.Pattern[str]"] = re.compile("`{3,}")
|
|
28
33
|
|
|
@@ -123,7 +128,7 @@ class HeaderFormatter(SingleLineFormatter):
|
|
|
123
128
|
if m is not None:
|
|
124
129
|
level, text = m.groups()
|
|
125
130
|
|
|
126
|
-
return "%s %s\n" % ("#" * (len(level) + 1), text)
|
|
131
|
+
return "%s %s\n" % ("#" * (len(level) + 1), _format_heading(text))
|
|
127
132
|
return ""
|
|
128
133
|
|
|
129
134
|
|
|
@@ -155,15 +160,14 @@ class LinkFormatter:
|
|
|
155
160
|
return pre + self._get_link(url)
|
|
156
161
|
|
|
157
162
|
def _get_image(self, src: str, title: Optional[str] = None) -> str:
|
|
158
|
-
return f"})"
|
|
163
|
+
return _syntax(f"})")
|
|
159
164
|
|
|
160
165
|
def _get_link(self, href: str, content: Optional[str] = None) -> str:
|
|
161
|
-
return
|
|
166
|
+
return _syntax("[") + (content or href) + _syntax(f"]({self._target(href)})")
|
|
162
167
|
|
|
163
168
|
def _target(self, target: str) -> str:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# Markdown takes a target with spaces only in angle brackets; `<` is already escaped in the whole line
|
|
169
|
+
target = target.replace("<", "\\<")
|
|
170
|
+
# Markdown takes a target with spaces only in angle brackets
|
|
167
171
|
if " " in target:
|
|
168
172
|
return "<" + target.replace(">", "\\>") + ">"
|
|
169
173
|
return target
|
|
@@ -184,7 +188,7 @@ class LinkFormatter:
|
|
|
184
188
|
content = self._get_image(content, link)
|
|
185
189
|
elif self._is_image(link):
|
|
186
190
|
return self._get_image(link, content)
|
|
187
|
-
if link.startswith("
|
|
191
|
+
if link.startswith("#"):
|
|
188
192
|
link = link.lower()
|
|
189
193
|
return self._get_link(link, content)
|
|
190
194
|
|
|
@@ -214,6 +218,46 @@ def _hold(held: List[str], text: str) -> str:
|
|
|
214
218
|
return f"\ue000{len(held) - 1}\ue001"
|
|
215
219
|
|
|
216
220
|
|
|
221
|
+
def _hold_own_markers(line: str, held: List[str]) -> str:
|
|
222
|
+
return _RE_OWN_MARKERS.sub(lambda m: _hold(held, m.group(0)), line)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _restore(line: str, held: List[str]) -> str:
|
|
226
|
+
# backwards, the documentation's own characters can be part of held code
|
|
227
|
+
for index, text in reversed(list(enumerate(held))):
|
|
228
|
+
line = line.replace(f"\ue000{index}\ue001", text)
|
|
229
|
+
return line
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _syntax(text: str) -> str:
|
|
233
|
+
"""Marks what the formatter writes itself, the escape of the text leaves it alone."""
|
|
234
|
+
return f"\ue002{text}\ue003"
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _escape_line(line: str) -> str:
|
|
238
|
+
result: List[str] = []
|
|
239
|
+
position = 0
|
|
240
|
+
for match in _RE_NOT_TEXT.finditer(line):
|
|
241
|
+
result.append(escape_text(line[position : match.start()]))
|
|
242
|
+
result.append(match.group(1) or match.group(2))
|
|
243
|
+
position = match.end()
|
|
244
|
+
result.append(escape_text(line[position:]))
|
|
245
|
+
return "".join(result)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _escape_block_start(match: re.Match[str]) -> str:
|
|
249
|
+
return f"\\{match.group(1)}" if match.group(1) else f"{match.group(2)}\\{match.group(3)}"
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _format_heading(text: str) -> str:
|
|
253
|
+
"""Robot Framework formats nothing in a heading, what Markdown would read as markup is text there."""
|
|
254
|
+
held: List[str] = []
|
|
255
|
+
text = _hold_own_markers(text, held)
|
|
256
|
+
if "`" in text:
|
|
257
|
+
text = _RE_CODE_SPAN.sub(lambda m: m.group(0) if m.group(1) is None else _hold(held, m.group(0)), text)
|
|
258
|
+
return _restore(_escape_line(text), held)
|
|
259
|
+
|
|
260
|
+
|
|
217
261
|
class LineFormatter:
|
|
218
262
|
_bold: Final["re.Pattern[str]"] = re.compile(
|
|
219
263
|
r"""
|
|
@@ -257,8 +301,6 @@ _ # end of italic
|
|
|
257
301
|
|
|
258
302
|
self._name_linker = name_linker
|
|
259
303
|
self._formatters: List[Tuple[str, Callable[[str], str]]] = [
|
|
260
|
-
("<", self._quote_lower_then),
|
|
261
|
-
("#", self._quote_hash),
|
|
262
304
|
("*", self._format_bold),
|
|
263
305
|
("_", self._format_italic),
|
|
264
306
|
("", LinkFormatter().format_link),
|
|
@@ -266,9 +308,7 @@ _ # end of italic
|
|
|
266
308
|
|
|
267
309
|
def format(self, line: str) -> str:
|
|
268
310
|
held: List[str] = []
|
|
269
|
-
|
|
270
|
-
# the documentation's own character must not read as a placeholder
|
|
271
|
-
line = line.replace("\ue000", _hold(held, "\ue000"))
|
|
311
|
+
line = _hold_own_markers(line, held)
|
|
272
312
|
if "`" in line:
|
|
273
313
|
# what Robot Framework reads as code decides first, then what else Markdown reads as code
|
|
274
314
|
line = self._code.sub(lambda m: m.group(1) + _hold(held, code_span(_code_text(m.group(3)))), line)
|
|
@@ -276,16 +316,14 @@ _ # end of italic
|
|
|
276
316
|
for marker, formatter in self._formatters:
|
|
277
317
|
if marker in line:
|
|
278
318
|
line = formatter(line)
|
|
279
|
-
#
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return line
|
|
319
|
+
# last, so that all that is left of the line is text
|
|
320
|
+
line = _RE_BLOCK_START.sub(_escape_block_start, _escape_line(line))
|
|
321
|
+
return _restore(line, held)
|
|
283
322
|
|
|
284
323
|
def _hold_span(self, match: re.Match[str], held: List[str]) -> str:
|
|
285
324
|
text, fence, span = match.group(0, 1, 2)
|
|
286
325
|
if fence is None:
|
|
287
|
-
|
|
288
|
-
return text if text.startswith("\\") else text.replace("`", "\\`")
|
|
326
|
+
return text
|
|
289
327
|
# for Robot Framework this is no code, but Markdown shows it as code
|
|
290
328
|
if len(fence) > 1:
|
|
291
329
|
return _hold(held, text)
|
|
@@ -294,17 +332,11 @@ _ # end of italic
|
|
|
294
332
|
return _hold(held, f"[{escape_link_text(span)}]({target})")
|
|
295
333
|
return _hold(held, code_span(_code_text(span)))
|
|
296
334
|
|
|
297
|
-
def _quote_lower_then(self, line: str) -> str:
|
|
298
|
-
return line.replace("<", "\\<")
|
|
299
|
-
|
|
300
|
-
def _quote_hash(self, line: str) -> str:
|
|
301
|
-
return line.replace("#", "\\#")
|
|
302
|
-
|
|
303
335
|
def _format_bold(self, line: str) -> str:
|
|
304
|
-
return self._bold.sub("\\1
|
|
336
|
+
return self._bold.sub(f"\\1{_syntax('**')}\\3{_syntax('**')}", line)
|
|
305
337
|
|
|
306
338
|
def _format_italic(self, line: str) -> str:
|
|
307
|
-
return self._italic.sub("\\1
|
|
339
|
+
return self._italic.sub(f"\\1{_syntax('*')}\\3{_syntax('*')}", line)
|
|
308
340
|
|
|
309
341
|
|
|
310
342
|
_line_formatter = LineFormatter()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.9.0-dev.115"
|
|
File without changes
|
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/__init__.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/__init__.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/loader.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/model.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/config/utils.py
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/__init__.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/ast.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/match.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/stubs.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/variables.py
RENAMED
|
File without changes
|
{robotcode_robot-2.9.0.dev115 → robotcode_robot-2.9.0.dev180}/src/robotcode/robot/utils/visitor.py
RENAMED
|
File without changes
|