py2docfx 0.1.22.dev2258230__py3-none-any.whl → 0.1.22.dev2259826__py3-none-any.whl
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.
- py2docfx/docfx_yaml/process_doctree.py +3 -23
- py2docfx/docfx_yaml/translator.py +6 -35
- py2docfx/docfx_yaml/type_mapping.py +102 -0
- {py2docfx-0.1.22.dev2258230.dist-info → py2docfx-0.1.22.dev2259826.dist-info}/METADATA +1 -1
- {py2docfx-0.1.22.dev2258230.dist-info → py2docfx-0.1.22.dev2259826.dist-info}/RECORD +7 -6
- {py2docfx-0.1.22.dev2258230.dist-info → py2docfx-0.1.22.dev2259826.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.22.dev2258230.dist-info → py2docfx-0.1.22.dev2259826.dist-info}/top_level.txt +0 -0
@@ -12,28 +12,13 @@ from utils import transform_string
|
|
12
12
|
from enum import EnumMeta
|
13
13
|
from importlib import import_module
|
14
14
|
from logger import get_package_logger
|
15
|
+
from type_mapping import map_type_transformations, PACKAGE, METHOD, FUNCTION, DATA, MODULE, CLASS, EXCEPTION, ATTRIBUTE, PROPERTY, PYDANTIC_MODEL, PYDANTIC_FIELD, PYDANTIC_SETTINGS, PYDANTIC_VALIDATOR, PYDANTIC_CONFIG
|
15
16
|
|
16
|
-
PACKAGE = 'package'
|
17
|
-
METHOD = 'method'
|
18
|
-
FUNCTION = 'function'
|
19
|
-
DATA = 'data'
|
20
|
-
MODULE = 'module'
|
21
|
-
CLASS = 'class'
|
22
|
-
EXCEPTION = 'exception'
|
23
|
-
ATTRIBUTE = 'attribute'
|
24
|
-
PROPERTY = 'property'
|
25
17
|
REFMETHOD = 'meth'
|
26
18
|
REFFUNCTION = 'func'
|
27
19
|
REF_PATTERN = ':(py:)?(func|class|meth|mod|ref):`~?[a-zA-Z_\.<> ]*?`'
|
28
20
|
INITPY = '__init__.py'
|
29
21
|
|
30
|
-
#Pydantic specific types
|
31
|
-
PYDANTIC_MODEL = 'pydantic_model'
|
32
|
-
PYDANTIC_FIELD = 'pydantic_field'
|
33
|
-
PYDANTIC_SETTINGS = 'pydantic_settings'
|
34
|
-
PYDANTIC_VALIDATOR = 'pydantic_validator'
|
35
|
-
PYDANTIC_CONFIG = 'pydantic_config'
|
36
|
-
|
37
22
|
def _fullname(obj):
|
38
23
|
"""
|
39
24
|
Get the fullname from a Python object
|
@@ -395,13 +380,8 @@ def process_docstring(app, _type, name, obj, options, lines):
|
|
395
380
|
return PACKAGE
|
396
381
|
return _type
|
397
382
|
|
398
|
-
#
|
399
|
-
|
400
|
-
_type = CLASS
|
401
|
-
elif _type == PROPERTY or _type == PYDANTIC_FIELD:
|
402
|
-
_type = ATTRIBUTE
|
403
|
-
elif _type == PYDANTIC_VALIDATOR:
|
404
|
-
_type = METHOD
|
383
|
+
# Apply type transformations using shared mapping function
|
384
|
+
_type = map_type_transformations(_type)
|
405
385
|
|
406
386
|
_type = check_convert_package_type(obj, _type)
|
407
387
|
cls, module = _get_cls_module(_type, name)
|
@@ -15,35 +15,15 @@ from sphinx.util.docfields import _is_single_paragraph
|
|
15
15
|
from collections import OrderedDict
|
16
16
|
from nodes import remarks
|
17
17
|
from logger import get_package_logger
|
18
|
+
from type_mapping import (
|
19
|
+
translator_type_mapping, CLASS_TYPE, EXCEPTION_TYPE, ATTRIBUTE_TYPE,
|
20
|
+
PYDANTIC_MODEL_TYPE, PYDANTIC_SETTINGS_TYPE, PYDANTIC_FIELD_TYPE, PYDANTIC_CONFIG_TYPE,
|
21
|
+
types_contain_constructor, types_contain_attributes, attribute_types
|
22
|
+
)
|
18
23
|
|
19
24
|
TYPE_SEP_PATTERN = '(\[|\]|, |\(|\))'
|
20
25
|
PARAMETER_NAME = "[*][*](.*?)[*][*]"
|
21
26
|
PARAMETER_TYPE = "[(]((?:.|\n)*)[)]"
|
22
|
-
CLASS_TYPE = 'class'
|
23
|
-
EXCEPTION_TYPE = 'exception'
|
24
|
-
ATTRIBUTE_TYPE = 'attribute'
|
25
|
-
|
26
|
-
# Pydantic specific types
|
27
|
-
PYDANTIC_MODEL_TYPE = "pydantic_model"
|
28
|
-
PYDANTIC_SETTINGS_TYPE = "pydantic_settings"
|
29
|
-
PYDANTIC_FIELD_TYPE = "pydantic_field"
|
30
|
-
PYDANTIC_CONFIG_TYPE = "pydantic_config"
|
31
|
-
|
32
|
-
types_contain_constructor = {
|
33
|
-
CLASS_TYPE,
|
34
|
-
PYDANTIC_MODEL_TYPE,
|
35
|
-
PYDANTIC_SETTINGS_TYPE,
|
36
|
-
EXCEPTION_TYPE,
|
37
|
-
PYDANTIC_CONFIG_TYPE,
|
38
|
-
}
|
39
|
-
types_contain_attributes = {
|
40
|
-
CLASS_TYPE,
|
41
|
-
PYDANTIC_MODEL_TYPE,
|
42
|
-
PYDANTIC_SETTINGS_TYPE,
|
43
|
-
EXCEPTION_TYPE,
|
44
|
-
PYDANTIC_CONFIG_TYPE,
|
45
|
-
}
|
46
|
-
attribute_types = {PYDANTIC_FIELD_TYPE, ATTRIBUTE_TYPE}
|
47
27
|
|
48
28
|
def translator(app, docname, doctree):
|
49
29
|
|
@@ -64,15 +44,6 @@ def translator(app, docname, doctree):
|
|
64
44
|
else:
|
65
45
|
return para_field.astext()
|
66
46
|
|
67
|
-
def type_mapping(type_name):
|
68
|
-
mapping = {
|
69
|
-
"staticmethod": "method",
|
70
|
-
"classmethod": "method",
|
71
|
-
"exception": "class",
|
72
|
-
}
|
73
|
-
|
74
|
-
return mapping[type_name] if type_name in mapping else type_name
|
75
|
-
|
76
47
|
def _get_uid_and_type_from_desc(node):
|
77
48
|
assert node.tagname == 'desc'
|
78
49
|
if node.attributes['domain'] != 'py':
|
@@ -493,7 +464,7 @@ def translator(app, docname, doctree):
|
|
493
464
|
data.update(extract_content(content_child, node_type, module_name))
|
494
465
|
data['content'] = extract_signature(signature_child)
|
495
466
|
|
496
|
-
data['type'] =
|
467
|
+
data['type'] = translator_type_mapping(node_type) if node_type else 'unknown'
|
497
468
|
if _is_property_node(signature_child):
|
498
469
|
data['type'] = ATTRIBUTE_TYPE
|
499
470
|
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# ---------------------------------------------------------
|
4
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
5
|
+
# ---------------------------------------------------------
|
6
|
+
|
7
|
+
"""
|
8
|
+
Type mapping utilities for converting various documentation types to standardized forms.
|
9
|
+
"""
|
10
|
+
|
11
|
+
# Standard types
|
12
|
+
PACKAGE = 'package'
|
13
|
+
METHOD = 'method'
|
14
|
+
FUNCTION = 'function'
|
15
|
+
DATA = 'data'
|
16
|
+
MODULE = 'module'
|
17
|
+
CLASS = 'class'
|
18
|
+
EXCEPTION = 'exception'
|
19
|
+
ATTRIBUTE = 'attribute'
|
20
|
+
PROPERTY = 'property'
|
21
|
+
|
22
|
+
# Pydantic specific types
|
23
|
+
PYDANTIC_MODEL = 'pydantic_model'
|
24
|
+
PYDANTIC_FIELD = 'pydantic_field'
|
25
|
+
PYDANTIC_SETTINGS = 'pydantic_settings'
|
26
|
+
PYDANTIC_VALIDATOR = 'pydantic_validator'
|
27
|
+
PYDANTIC_CONFIG = 'pydantic_config'
|
28
|
+
|
29
|
+
# Translator-style constants (for compatibility)
|
30
|
+
CLASS_TYPE = 'class'
|
31
|
+
EXCEPTION_TYPE = 'exception'
|
32
|
+
ATTRIBUTE_TYPE = 'attribute'
|
33
|
+
PYDANTIC_MODEL_TYPE = "pydantic_model"
|
34
|
+
PYDANTIC_SETTINGS_TYPE = "pydantic_settings"
|
35
|
+
PYDANTIC_FIELD_TYPE = "pydantic_field"
|
36
|
+
PYDANTIC_CONFIG_TYPE = "pydantic_config"
|
37
|
+
|
38
|
+
# Type groupings for translator functionality
|
39
|
+
types_contain_constructor = {
|
40
|
+
CLASS_TYPE,
|
41
|
+
PYDANTIC_MODEL_TYPE,
|
42
|
+
PYDANTIC_SETTINGS_TYPE,
|
43
|
+
EXCEPTION_TYPE,
|
44
|
+
PYDANTIC_CONFIG_TYPE,
|
45
|
+
}
|
46
|
+
|
47
|
+
types_contain_attributes = {
|
48
|
+
CLASS_TYPE,
|
49
|
+
PYDANTIC_MODEL_TYPE,
|
50
|
+
PYDANTIC_SETTINGS_TYPE,
|
51
|
+
EXCEPTION_TYPE,
|
52
|
+
PYDANTIC_CONFIG_TYPE,
|
53
|
+
}
|
54
|
+
|
55
|
+
attribute_types = {PYDANTIC_FIELD_TYPE, ATTRIBUTE_TYPE}
|
56
|
+
|
57
|
+
|
58
|
+
def map_type_transformations(type_name):
|
59
|
+
"""
|
60
|
+
Apply type transformations to convert various documentation types to standardized forms.
|
61
|
+
Used by process_doctree.py for initial type processing.
|
62
|
+
|
63
|
+
Args:
|
64
|
+
type_name (str): The original type name
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
str: The transformed type name
|
68
|
+
"""
|
69
|
+
# Type transformations
|
70
|
+
if type_name == EXCEPTION or type_name in {PYDANTIC_MODEL, PYDANTIC_SETTINGS, PYDANTIC_CONFIG}:
|
71
|
+
return CLASS
|
72
|
+
elif type_name == PROPERTY or type_name == PYDANTIC_FIELD:
|
73
|
+
return ATTRIBUTE
|
74
|
+
elif type_name == PYDANTIC_VALIDATOR:
|
75
|
+
return METHOD
|
76
|
+
|
77
|
+
# Return original type if no transformation needed
|
78
|
+
return type_name
|
79
|
+
|
80
|
+
|
81
|
+
def translator_type_mapping(type_name):
|
82
|
+
"""
|
83
|
+
Apply type mapping transformations for translator processing.
|
84
|
+
Used by translator.py for docstring processing.
|
85
|
+
Includes both original translator mappings and process_doctree transformations.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
type_name (str): The original type name
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
str: The mapped type name
|
92
|
+
"""
|
93
|
+
# First apply the process_doctree style transformations
|
94
|
+
transformed_type = map_type_transformations(type_name)
|
95
|
+
|
96
|
+
# Then apply the original translator mappings
|
97
|
+
mapping = {
|
98
|
+
"staticmethod": "method",
|
99
|
+
"classmethod": "method",
|
100
|
+
}
|
101
|
+
|
102
|
+
return mapping[transformed_type] if transformed_type in mapping else transformed_type
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: py2docfx
|
3
|
-
Version: 0.1.22.
|
3
|
+
Version: 0.1.22.dev2259826
|
4
4
|
Summary: A package built based on Sphinx which download source code package and generate yaml files supported by docfx.
|
5
5
|
Author: Microsoft Corporation
|
6
6
|
License: MIT License
|
@@ -69,10 +69,11 @@ py2docfx/docfx_yaml/logger.py,sha256=brzFbSgQq3o3n2sy-2pk849AVpaUn1rhJfIs44IYa0Y
|
|
69
69
|
py2docfx/docfx_yaml/miss_reference.py,sha256=NHoQtas0kvFsJXaR4fsk7kHjwV4aJobrr_Q30HaUc_I,2450
|
70
70
|
py2docfx/docfx_yaml/nodes.py,sha256=tBDi35jLJArlobl07DKOkmH2qz7dudXLp_kTUfR_r2w,412
|
71
71
|
py2docfx/docfx_yaml/parameter_utils.py,sha256=04wQCtbS-G2hWM5UGkL22s10LZLUbqbh3RM9rWGOToI,10897
|
72
|
-
py2docfx/docfx_yaml/process_doctree.py,sha256=
|
72
|
+
py2docfx/docfx_yaml/process_doctree.py,sha256=xz4Whx19pprCo12jrZD2rLTVtM1dJsHSsURQOlF6xl0,17207
|
73
73
|
py2docfx/docfx_yaml/return_type_utils.py,sha256=nmdCUOvwdYk2jF6RqmOvU6gjXmXUTPUeCqyHPdKZNUQ,7483
|
74
74
|
py2docfx/docfx_yaml/settings.py,sha256=JQZNwFebczl-zn8Yk2taAGANRi-Hw8hywtDWxqXXFyQ,373
|
75
|
-
py2docfx/docfx_yaml/translator.py,sha256
|
75
|
+
py2docfx/docfx_yaml/translator.py,sha256=hLSl8WkTMB_Oq5XuzCP4fDRWSOWzpNJN7Gzvy_SkXck,25664
|
76
|
+
py2docfx/docfx_yaml/type_mapping.py,sha256=rgnkxbPRzr3C1NDLjXdAyYg1Zh-y0QcFutlzWvtJaC8,2954
|
76
77
|
py2docfx/docfx_yaml/utils.py,sha256=sJ6aWF9wwIWIoZL6WWsd3FQD-zb3PWrJ5QTWP7PCarY,1567
|
77
78
|
py2docfx/docfx_yaml/write_utils.py,sha256=q5qoYWw6GVDV8a3E8IxcSLWnN9sAer42VFRgadHBkgk,305
|
78
79
|
py2docfx/docfx_yaml/writer.py,sha256=aDxz8Vc8ln0a9PKi08DIILvgMIfXqN5wArDcAQ8Iy8E,35980
|
@@ -3915,7 +3916,7 @@ py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/convert.py,sha256=0wSJMU0m
|
|
3915
3916
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/pack.py,sha256=o3iwjfRHl7N9ul-M2kHbewLJZnqBLAWf0tzUCwoiTMw,3078
|
3916
3917
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/tags.py,sha256=Rv2ySVb8-qX3osKp3uJgxcIMXkjt43XUD0-zvC6KvnY,4775
|
3917
3918
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/unpack.py,sha256=Y_J7ynxPSoFFTT7H0fMgbBlVErwyDGcObgme5MBuz58,1021
|
3918
|
-
py2docfx-0.1.22.
|
3919
|
-
py2docfx-0.1.22.
|
3920
|
-
py2docfx-0.1.22.
|
3921
|
-
py2docfx-0.1.22.
|
3919
|
+
py2docfx-0.1.22.dev2259826.dist-info/METADATA,sha256=xTi8c6UJVwYuNDSY5O8A6dbR8WmuBwTblt8Ynk1NQlg,548
|
3920
|
+
py2docfx-0.1.22.dev2259826.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
3921
|
+
py2docfx-0.1.22.dev2259826.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
|
3922
|
+
py2docfx-0.1.22.dev2259826.dist-info/RECORD,,
|
File without changes
|
File without changes
|