py2docfx 0.1.1.dev1634739__py3-none-any.whl → 0.1.2.dev1669302__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/convert_prepare/tests/test_generate_document.py +1 -0
- py2docfx/docfx_yaml/build_finished.py +81 -41
- {py2docfx-0.1.1.dev1634739.dist-info → py2docfx-0.1.2.dev1669302.dist-info}/METADATA +1 -1
- {py2docfx-0.1.1.dev1634739.dist-info → py2docfx-0.1.2.dev1669302.dist-info}/RECORD +6 -6
- {py2docfx-0.1.1.dev1634739.dist-info → py2docfx-0.1.2.dev1669302.dist-info}/WHEEL +1 -1
- {py2docfx-0.1.1.dev1634739.dist-info → py2docfx-0.1.2.dev1669302.dist-info}/top_level.txt +0 -0
@@ -51,4 +51,5 @@ def test_generate_document(tmp_path):
|
|
51
51
|
assert not os.path.exists(os.path.join(yaml_path, "azure.dummy.yml"))
|
52
52
|
assert not os.path.exists(os.path.join(yaml_path, "azure.yml"))
|
53
53
|
assert os.path.exists(os.path.join(yaml_path, "toc.yml"))
|
54
|
+
assert os.path.exists(os.path.join(yaml_path, "index.yml"))
|
54
55
|
|
@@ -26,36 +26,8 @@ scientific_notation_regex = re.compile(r'^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)$
|
|
26
26
|
def string_representer(dumper, data):
|
27
27
|
return dumper.represent_scalar(u"tag:yaml.org,2002:str", data,
|
28
28
|
style="'" if (scientific_notation_regex.match(data)) else None)
|
29
|
-
yml.add_representer(str, string_representer)
|
30
|
-
|
31
|
-
def insert_node_to_toc_tree(toc_yaml, uid, project_name, toc_node_map):
|
32
|
-
# Build nested TOC
|
33
|
-
parent_level = uid
|
34
|
-
cur_node = None
|
35
29
|
|
36
|
-
|
37
|
-
while parent_level.count('.') >= 1:
|
38
|
-
parent_level = '.'.join(parent_level.split('.')[:-1])
|
39
|
-
found_node = toc_node_map[parent_level] if parent_level in toc_node_map else None
|
40
|
-
if found_node:
|
41
|
-
# If ancestor already in current TOC, insert to its items
|
42
|
-
name = uid.split('.')[-1] if '.' in uid and project_name != uid else uid
|
43
|
-
cur_node = {'name': name, 'uid': uid}
|
44
|
-
if 'uid' in found_node:
|
45
|
-
# Only leaf nodes should have uid
|
46
|
-
found_node.pop('uid', 'No uid found')
|
47
|
-
# Subpackages should have its Overview page
|
48
|
-
found_node.setdefault('items', [{'name': 'Overview', 'uid': parent_level}]).append(cur_node)
|
49
|
-
break
|
50
|
-
|
51
|
-
# uid is representing a package in TOC as root node
|
52
|
-
if cur_node is None:
|
53
|
-
# if uid doesn't contain '.', the name needn't to simplify
|
54
|
-
cur_node = {'name': uid}
|
55
|
-
toc_yaml.append(cur_node)
|
56
|
-
|
57
|
-
# insert to uid-toc map
|
58
|
-
toc_node_map[uid] = cur_node
|
30
|
+
yml.add_representer(str, string_representer)
|
59
31
|
|
60
32
|
def merge_params(arg_params, doc_params):
|
61
33
|
merged_params = deepcopy(doc_params)
|
@@ -83,10 +55,10 @@ def remove_params_without_id(params):
|
|
83
55
|
return new_params
|
84
56
|
|
85
57
|
def add_isrequired_if_needed(obj, key: str):
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
58
|
+
if key in obj['syntax'] and obj['type'] in ['class', 'function', 'method']:
|
59
|
+
for args in obj['syntax'][key]:
|
60
|
+
if 'isRequired' not in args and 'defaultValue' not in args:
|
61
|
+
args['isRequired'] = True
|
90
62
|
|
91
63
|
def get_merged_params(obj, info_field_data, key: str):
|
92
64
|
merged_params = []
|
@@ -96,7 +68,7 @@ def get_merged_params(obj, info_field_data, key: str):
|
|
96
68
|
key, [])
|
97
69
|
if arg_params and doc_params:
|
98
70
|
if len(arg_params) - len(doc_params) > 0:
|
99
|
-
print(
|
71
|
+
print("Documented params don't match size of params:"" {}".format(obj['uid'])) # lgtm [py/clear-text-logging-sensitive-data]
|
100
72
|
doc_params = remove_params_without_id(doc_params)
|
101
73
|
merged_params = merge_params(arg_params, doc_params)
|
102
74
|
else:
|
@@ -109,7 +81,7 @@ def raise_up_fields(obj):
|
|
109
81
|
if 'summary' in obj['syntax'] and obj['syntax']['summary']:
|
110
82
|
obj['summary'] = obj['syntax'].pop(
|
111
83
|
'summary').strip(" \n\r\r")
|
112
|
-
|
84
|
+
|
113
85
|
# Raise up remarks
|
114
86
|
if 'remarks' in obj['syntax'] and obj['syntax']['remarks']:
|
115
87
|
obj['remarks'] = obj['syntax'].pop('remarks')
|
@@ -176,6 +148,35 @@ def merge_data(obj, info_field_data, yaml_data):
|
|
176
148
|
# Revert `type` for other objects to use
|
177
149
|
info_field_data[obj['uid']]['type'] = obj['type']
|
178
150
|
|
151
|
+
def find_node_in_toc_tree(toc_yaml, to_add_node):
|
152
|
+
for module in toc_yaml:
|
153
|
+
if module['name'] == to_add_node:
|
154
|
+
return module
|
155
|
+
|
156
|
+
if 'items' in module:
|
157
|
+
items = module['items']
|
158
|
+
found_module = find_node_in_toc_tree(items, to_add_node)
|
159
|
+
if found_module != None:
|
160
|
+
return found_module
|
161
|
+
|
162
|
+
return None
|
163
|
+
|
164
|
+
def build_nested_toc(toc_yaml, uid):
|
165
|
+
# Build nested TOC
|
166
|
+
if uid.count('.') >= 1:
|
167
|
+
parent_level = '.'.join(uid.split('.')[:-1])
|
168
|
+
found_node = find_node_in_toc_tree(toc_yaml, parent_level)
|
169
|
+
|
170
|
+
if found_node:
|
171
|
+
found_node.pop('uid', 'No uid found')
|
172
|
+
found_node.setdefault('items', [{'name': 'Overview', 'uid': parent_level}]).append(
|
173
|
+
{'name': uid, 'uid': uid})
|
174
|
+
else:
|
175
|
+
toc_yaml.append({'name': uid, 'uid': uid})
|
176
|
+
|
177
|
+
else:
|
178
|
+
toc_yaml.append({'name': uid, 'uid': uid})
|
179
|
+
|
179
180
|
def build_finished(app, exception):
|
180
181
|
"""
|
181
182
|
Output YAML on the file system.
|
@@ -206,8 +207,6 @@ def build_finished(app, exception):
|
|
206
207
|
))
|
207
208
|
|
208
209
|
ensuredir(normalized_outdir)
|
209
|
-
project_name = app.config.project.replace('-','.')
|
210
|
-
toc_node_map = {}
|
211
210
|
|
212
211
|
def filter_out_self_from_args(obj):
|
213
212
|
arg_params = obj.get('syntax', {}).get('parameters', [])
|
@@ -261,13 +260,30 @@ def build_finished(app, exception):
|
|
261
260
|
if (obj['type'] == 'class' and obj['inheritance']):
|
262
261
|
convert_class_to_enum_if_needed(obj)
|
263
262
|
|
264
|
-
|
263
|
+
build_nested_toc(toc_yaml, uid)
|
264
|
+
|
265
|
+
index_children = []
|
266
|
+
index_references = []
|
267
|
+
|
268
|
+
def form_index_references_and_children(yaml_data, index_children, index_references):
|
269
|
+
if yaml_data[0].get('type', None) in ['package', 'module']:
|
270
|
+
index_children.append(yaml_data[0].get('fullName', ''))
|
271
|
+
index_references.append({
|
272
|
+
'uid': yaml_data[0].get('fullName', ''),
|
273
|
+
'name': yaml_data[0].get('fullName', ''),
|
274
|
+
'fullname': yaml_data[0].get('fullName', ''),
|
275
|
+
'isExternal': False
|
276
|
+
})
|
265
277
|
|
266
278
|
for data_set in (app.env.docfx_yaml_packages,
|
267
279
|
app.env.docfx_yaml_modules,
|
268
280
|
app.env.docfx_yaml_classes,
|
269
281
|
app.env.docfx_yaml_functions): # noqa
|
282
|
+
|
270
283
|
for uid, yaml_data in iter(sorted(data_set.items())):
|
284
|
+
|
285
|
+
form_index_references_and_children(yaml_data, index_children, index_references)
|
286
|
+
|
271
287
|
# Output file
|
272
288
|
if uid.lower() in file_name_set:
|
273
289
|
filename = uid + "(%s)" % app.env.docfx_info_uid_types[uid]
|
@@ -275,6 +291,7 @@ def build_finished(app, exception):
|
|
275
291
|
filename = uid
|
276
292
|
out_file = os.path.join(normalized_outdir, '%s.yml' % filename)
|
277
293
|
ensuredir(os.path.dirname(out_file))
|
294
|
+
new_object = {}
|
278
295
|
|
279
296
|
transformed_obj = None
|
280
297
|
if yaml_data[0]['type'] == 'package':
|
@@ -293,13 +310,12 @@ def build_finished(app, exception):
|
|
293
310
|
mime = "PythonModule"
|
294
311
|
|
295
312
|
if transformed_obj == None:
|
296
|
-
print(
|
313
|
+
print("Unknown yml: " + yamlfile_path)
|
297
314
|
else:
|
298
315
|
# save file
|
299
316
|
common.write_yaml(transformed_obj, out_file, mime)
|
300
317
|
file_name_set.add(filename)
|
301
318
|
|
302
|
-
# Write TOC, the toc should include at least 1
|
303
319
|
if len(toc_yaml) == 0:
|
304
320
|
raise RuntimeError("No documentation for this module.")
|
305
321
|
|
@@ -307,7 +323,31 @@ def build_finished(app, exception):
|
|
307
323
|
with open(toc_file, 'w') as writable:
|
308
324
|
writable.write(
|
309
325
|
dump(
|
310
|
-
|
326
|
+
[{
|
327
|
+
'name': app.config.project,
|
328
|
+
'items': [{'name': 'Overview', 'uid': 'project-' + app.config.project}] + toc_yaml
|
329
|
+
}],
|
311
330
|
default_flow_style=False,
|
312
331
|
)
|
313
332
|
)
|
333
|
+
|
334
|
+
index_file = os.path.join(normalized_outdir, 'index.yml')
|
335
|
+
|
336
|
+
index_obj = [{
|
337
|
+
'uid': 'project-' + app.config.project,
|
338
|
+
'name': app.config.project,
|
339
|
+
'fullName': app.config.project,
|
340
|
+
'langs': ['python'],
|
341
|
+
'type': 'package',
|
342
|
+
'kind': 'distribution',
|
343
|
+
'summary': '',
|
344
|
+
'children': index_children
|
345
|
+
}]
|
346
|
+
transformed_obj = convert_package(index_obj, app.env.docfx_info_uid_types)
|
347
|
+
mime = "PythonPackage"
|
348
|
+
if transformed_obj == None:
|
349
|
+
print("Unknown yml: " + yamlfile_path)
|
350
|
+
else:
|
351
|
+
# save file
|
352
|
+
common.write_yaml(transformed_obj, index_file, mime)
|
353
|
+
file_name_set.add(filename)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py2docfx
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2.dev1669302
|
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
|
@@ -22,7 +22,7 @@ py2docfx/convert_prepare/post_process/merge_toc.py,sha256=coyae54OB1nGcCkxz9oAu-
|
|
22
22
|
py2docfx/convert_prepare/subpackage_merge/merge_root_package.py,sha256=uK96qL2asuSfo_3SZaoP8XZaUvjf5mNkr17JNbZR4Lg,1026
|
23
23
|
py2docfx/convert_prepare/subpackage_merge/merge_toc.py,sha256=nkVqe8R0m8D6cyTYV7aIpMDXorvn4-LXfU_vIK_hJBg,1706
|
24
24
|
py2docfx/convert_prepare/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
|
-
py2docfx/convert_prepare/tests/test_generate_document.py,sha256=
|
25
|
+
py2docfx/convert_prepare/tests/test_generate_document.py,sha256=BKw8pMSsygLnv6bETlA2MIVarECzfWoNo4JglxHb-T4,2480
|
26
26
|
py2docfx/convert_prepare/tests/test_get_source.py,sha256=c22JfobgbEbWWiNzBNYpZm2yDfo5LwBioUuRwft9WZE,5858
|
27
27
|
py2docfx/convert_prepare/tests/test_pack.py,sha256=46JWMNzknIptDVs7D3CuxcmqBr_OKMmaw1br9H7wqco,4134
|
28
28
|
py2docfx/convert_prepare/tests/test_package_info.py,sha256=L2ax9dItnz5QNSsSjSjEcaS6UPZxiq3MwysBB1FdJxI,2262
|
@@ -52,7 +52,7 @@ py2docfx/convert_prepare/tests/data/subpackage/azure-mgmt-containerservice/azure
|
|
52
52
|
py2docfx/convert_prepare/tests/data/subpackage/azure-mgmt-containerservice/azure/mgmt/containerservice/v2018_03_31/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
53
|
py2docfx/convert_prepare/tests/data/subpackage/azure-mgmt-containerservice/azure/mgmt/containerservice/v2018_03_31/models.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
54
|
py2docfx/docfx_yaml/__init__.py,sha256=KCEizAXv-SXtrYhvFfLHdBWDhz51AA9uagaeTL-Itpo,100
|
55
|
-
py2docfx/docfx_yaml/build_finished.py,sha256=
|
55
|
+
py2docfx/docfx_yaml/build_finished.py,sha256=kJemkgnh9NIzn4E8jcAIaP7vb7wcHzdLl7yWUjoZbi8,14218
|
56
56
|
py2docfx/docfx_yaml/build_init.py,sha256=lAw-fnBVQbySfZ7Sut_NpFQUjnqLOmnGQrTBBH2RXcg,1860
|
57
57
|
py2docfx/docfx_yaml/common.py,sha256=UN1MUmjUoN1QSFDR1Cm_bfRuHr6FQiOe5VQV6s8xzjc,6841
|
58
58
|
py2docfx/docfx_yaml/convert_class.py,sha256=boKDaxnXbnLxja62UFXi3eChGDB_WBW6ouUUJgOhdpE,2098
|
@@ -118,7 +118,7 @@ py2docfx/docfx_yaml/tests/roots/test-writer-table/conf.py,sha256=avcbnIOV2mlGQwh
|
|
118
118
|
py2docfx/docfx_yaml/tests/roots/test-writer-uri/code_with_uri.py,sha256=bzWTZpY2yf_By2bOSl1GFaY3BsZpkAvwQuGztlcHKkQ,537
|
119
119
|
py2docfx/docfx_yaml/tests/roots/test-writer-uri/conf.py,sha256=avcbnIOV2mlGQwhMQJZC4W6UGRBRhnq1QBxjPWlySxQ,260
|
120
120
|
py2docfx/docfx_yaml/tests/utils/test_utils.py,sha256=d0OYSUQ6NyoZx5mlLdNGGNhiNmmQhjVT4hQ6jY3VE_M,3383
|
121
|
-
py2docfx-0.1.
|
122
|
-
py2docfx-0.1.
|
123
|
-
py2docfx-0.1.
|
124
|
-
py2docfx-0.1.
|
121
|
+
py2docfx-0.1.2.dev1669302.dist-info/METADATA,sha256=iivYGhk17bJTOQ7f45BXY_Ey5MbEkzUvainKAoKAAqI,601
|
122
|
+
py2docfx-0.1.2.dev1669302.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
123
|
+
py2docfx-0.1.2.dev1669302.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
|
124
|
+
py2docfx-0.1.2.dev1669302.dist-info/RECORD,,
|
File without changes
|