@autorest/python 6.29.0 → 6.29.1

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.
package/autorest/m2r.py CHANGED
@@ -5,12 +5,60 @@
5
5
  # --------------------------------------------------------------------------
6
6
  """An autorest MD to RST plugin.
7
7
  """
8
- from typing import Any, Dict
8
+ import logging
9
+ from typing import Any, Dict, Set, Union
10
+
11
+ import m2r2
12
+ from pygen import YamlUpdatePlugin
9
13
 
10
- from pygen.m2r import M2R
11
14
  from . import YamlUpdatePluginAutorest
12
15
 
13
16
 
17
+ _LOGGER = logging.getLogger(__name__)
18
+
19
+
20
+ class GeneratorRenderer(m2r2.RestRenderer):
21
+ """Redefine the concept of inline HTML in the renderer, we don't want to define a new format
22
+ in the description/summary.
23
+ """
24
+
25
+ def inline_html(self, html: str) -> str:
26
+ """Do not render inline HTML with a role definition."""
27
+ return r"\ :code:`{}`".format(html)
28
+
29
+
30
+ class M2R(YamlUpdatePlugin):
31
+ """A plugin to convert any description and summary from MD to RST."""
32
+
33
+ def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
34
+ """Convert in place the YAML str."""
35
+ self._convert_docstring_no_cycles(yaml_data, set())
36
+
37
+ def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
38
+ """Walk the YAML tree to convert MD to RST."""
39
+ if id(yaml_data) in node_list:
40
+ return
41
+ node_list.add(id(yaml_data))
42
+
43
+ if isinstance(yaml_data, list):
44
+ for elt in yaml_data:
45
+ self._convert_docstring_no_cycles(elt, node_list)
46
+ elif isinstance(yaml_data, dict):
47
+ for key, value in yaml_data.items():
48
+ if key in ["description", "summary"]:
49
+ yaml_data[key] = self.convert_to_rst(value)
50
+ continue
51
+ self._convert_docstring_no_cycles(value, node_list)
52
+
53
+ @staticmethod
54
+ def convert_to_rst(string_to_convert: str) -> str:
55
+ """Convert that string from MD to RST."""
56
+ try:
57
+ return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
58
+ except Exception: # pylint: disable=broad-except
59
+ return string_to_convert
60
+
61
+
14
62
  class M2RAutorest(YamlUpdatePluginAutorest, M2R):
15
63
  def get_options(self) -> Dict[str, Any]:
16
64
  return {}
@@ -20,7 +20,6 @@ License-File: LICENSE
20
20
  Requires-Dist: black==24.8.0
21
21
  Requires-Dist: docutils>=0.20.1
22
22
  Requires-Dist: Jinja2==3.1.3
23
- Requires-Dist: m2r2==0.3.3.post2
24
23
  Requires-Dist: PyYAML==6.0.1
25
24
  Requires-Dist: tomli==2.0.1
26
25
  Requires-Dist: setuptools==69.5.1
@@ -5,7 +5,6 @@ setup.py
5
5
  pygen/__init__.py
6
6
  pygen/_version.py
7
7
  pygen/black.py
8
- pygen/m2r.py
9
8
  pygen/utils.py
10
9
  pygen.egg-info/PKG-INFO
11
10
  pygen.egg-info/SOURCES.txt
@@ -1,7 +1,6 @@
1
1
  black==24.8.0
2
2
  docutils>=0.20.1
3
3
  Jinja2==3.1.3
4
- m2r2==0.3.3.post2
5
4
  PyYAML==6.0.1
6
5
  tomli==2.0.1
7
6
  setuptools==69.5.1
@@ -51,7 +51,6 @@ setup(
51
51
  "black==24.8.0",
52
52
  "docutils>=0.20.1",
53
53
  "Jinja2==3.1.3",
54
- "m2r2==0.3.3.post2",
55
54
  "PyYAML==6.0.1",
56
55
  "tomli==2.0.1",
57
56
  "setuptools==69.5.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.29.0",
3
+ "version": "6.29.1",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
21
21
  "dependencies": {
22
- "@typespec/http-client-python": "~0.7.0",
22
+ "@typespec/http-client-python": "~0.7.1",
23
23
  "@autorest/system-requirements": "~1.0.2",
24
24
  "fs-extra": "~11.2.0",
25
25
  "tsx": "~4.19.1"
package/requirements.txt CHANGED
@@ -1 +1,2 @@
1
1
  json-rpc==1.14.0
2
+ m2r2==0.3.3.post2
@@ -1,65 +0,0 @@
1
- # -------------------------------------------------------------------------
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # Licensed under the MIT License. See License.txt in the project root for
4
- # license information.
5
- # --------------------------------------------------------------------------
6
- """An MD to RST plugin.
7
- """
8
- import logging
9
- from typing import Any, Dict, Set, Union
10
-
11
- import m2r2
12
-
13
- from . import YamlUpdatePlugin
14
- from .utils import parse_args
15
-
16
-
17
- _LOGGER = logging.getLogger(__name__)
18
-
19
-
20
- class GeneratorRenderer(m2r2.RestRenderer):
21
- """Redefine the concept of inline HTML in the renderer, we don't want to define a new format
22
- in the description/summary.
23
- """
24
-
25
- def inline_html(self, html: str) -> str:
26
- """Do not render inline HTML with a role definition."""
27
- return r"\ :code:`{}`".format(html)
28
-
29
-
30
- class M2R(YamlUpdatePlugin):
31
- """A plugin to convert any description and summary from MD to RST."""
32
-
33
- def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
34
- """Convert in place the YAML str."""
35
- self._convert_docstring_no_cycles(yaml_data, set())
36
-
37
- def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
38
- """Walk the YAML tree to convert MD to RST."""
39
- if id(yaml_data) in node_list:
40
- return
41
- node_list.add(id(yaml_data))
42
-
43
- if isinstance(yaml_data, list):
44
- for elt in yaml_data:
45
- self._convert_docstring_no_cycles(elt, node_list)
46
- elif isinstance(yaml_data, dict):
47
- for key, value in yaml_data.items():
48
- if key in ["description", "summary"]:
49
- yaml_data[key] = self.convert_to_rst(value)
50
- continue
51
- self._convert_docstring_no_cycles(value, node_list)
52
-
53
- @staticmethod
54
- def convert_to_rst(string_to_convert: str) -> str:
55
- """Convert that string from MD to RST."""
56
- try:
57
- return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
58
- except Exception: # pylint: disable=broad-except
59
- return string_to_convert
60
-
61
-
62
- if __name__ == "__main__":
63
- # CADL pipeline will call this
64
- args, unknown_args = parse_args()
65
- M2R(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
@@ -1,65 +0,0 @@
1
- # -------------------------------------------------------------------------
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # Licensed under the MIT License. See License.txt in the project root for
4
- # license information.
5
- # --------------------------------------------------------------------------
6
- """An MD to RST plugin.
7
- """
8
- import logging
9
- from typing import Any, Dict, Set, Union
10
-
11
- import m2r2
12
-
13
- from . import YamlUpdatePlugin
14
- from .utils import parse_args
15
-
16
-
17
- _LOGGER = logging.getLogger(__name__)
18
-
19
-
20
- class GeneratorRenderer(m2r2.RestRenderer):
21
- """Redefine the concept of inline HTML in the renderer, we don't want to define a new format
22
- in the description/summary.
23
- """
24
-
25
- def inline_html(self, html: str) -> str:
26
- """Do not render inline HTML with a role definition."""
27
- return r"\ :code:`{}`".format(html)
28
-
29
-
30
- class M2R(YamlUpdatePlugin):
31
- """A plugin to convert any description and summary from MD to RST."""
32
-
33
- def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
34
- """Convert in place the YAML str."""
35
- self._convert_docstring_no_cycles(yaml_data, set())
36
-
37
- def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
38
- """Walk the YAML tree to convert MD to RST."""
39
- if id(yaml_data) in node_list:
40
- return
41
- node_list.add(id(yaml_data))
42
-
43
- if isinstance(yaml_data, list):
44
- for elt in yaml_data:
45
- self._convert_docstring_no_cycles(elt, node_list)
46
- elif isinstance(yaml_data, dict):
47
- for key, value in yaml_data.items():
48
- if key in ["description", "summary"]:
49
- yaml_data[key] = self.convert_to_rst(value)
50
- continue
51
- self._convert_docstring_no_cycles(value, node_list)
52
-
53
- @staticmethod
54
- def convert_to_rst(string_to_convert: str) -> str:
55
- """Convert that string from MD to RST."""
56
- try:
57
- return m2r2.convert(string_to_convert, renderer=GeneratorRenderer()).strip()
58
- except Exception: # pylint: disable=broad-except
59
- return string_to_convert
60
-
61
-
62
- if __name__ == "__main__":
63
- # CADL pipeline will call this
64
- args, unknown_args = parse_args()
65
- M2R(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()