@typespec/http-client-python 0.7.0 → 0.7.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.
@@ -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": "@typespec/http-client-python",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://typespec.io",
@@ -66,6 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "js-yaml": "~4.1.0",
69
+ "marked": "^15.0.6",
69
70
  "pyodide": "0.26.2",
70
71
  "semver": "~7.6.2",
71
72
  "tsx": "~4.19.1"
@@ -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()
@@ -1,10 +0,0 @@
1
- # ------------------------------------
2
- # Copyright (c) Microsoft Corporation.
3
- # Licensed under the MIT License.
4
- # ------------------------------------
5
- from pygen.m2r import M2R
6
-
7
-
8
- def test_inline_html():
9
- des = "Format: <MajorVersion>.<MinorVersion>.<Patch>"
10
- M2R.convert_to_rst(des) == r"Format: \ :code:`<MajorVersion>`.\ :code:`<MinorVersion>`.\ :code:`<Patch>`"