@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.
- package/dist/emitter/emitter.d.ts.map +1 -1
- package/dist/emitter/emitter.js +40 -5
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/types.d.ts.map +1 -1
- package/dist/emitter/types.js +3 -1
- package/dist/emitter/types.js.map +1 -1
- package/dist/emitter/utils.d.ts +1 -0
- package/dist/emitter/utils.d.ts.map +1 -1
- package/dist/emitter/utils.js +78 -0
- package/dist/emitter/utils.js.map +1 -1
- package/emitter/src/emitter.ts +44 -5
- package/emitter/src/types.ts +4 -1
- package/emitter/src/utils.ts +82 -0
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/emitter/test/utils.test.ts +6 -1
- package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
- package/eng/scripts/setup/run_tsp.py +2 -3
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen.egg-info/PKG-INFO +0 -1
- package/generator/pygen.egg-info/SOURCES.txt +0 -1
- package/generator/pygen.egg-info/requires.txt +0 -1
- package/generator/setup.py +0 -1
- package/package.json +2 -1
- package/generator/build/lib/pygen/m2r.py +0 -65
- package/generator/pygen/m2r.py +0 -65
- package/generator/test/generic_mock_api_tests/unittests/test_m2r.py +0 -10
package/generator/setup.py
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.7.
|
|
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()
|
package/generator/pygen/m2r.py
DELETED
|
@@ -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>`"
|