py2docfx 0.1.1.dev1622985__py3-none-any.whl → 0.1.1.dev1626976__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.
@@ -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
 
@@ -32,24 +32,18 @@ def build_finished(app, exception):
32
32
  """
33
33
  Output YAML on the file system.
34
34
  """
35
- def insert_node_to_toc_tree(toc_yaml, uid, project_name, toc_node_map):
36
- name = uid.split('.')[-1] if '.' in uid and uid.startswith(project_name) and project_name != uid else uid
37
- cur_node = {'name': name, 'uid': uid}
38
-
39
- # Build nested TOC
40
- if uid.count('.') >= 1:
41
- parent_level = '.'.join(uid.split('.')[:-1])
42
- found_node = toc_node_map[parent_level] if parent_level in toc_node_map else None
43
- if found_node:
44
- if 'uid' in found_node:
45
- found_node.pop('uid', 'No uid found')
46
- found_node.setdefault('items', [{'name': 'Overview', 'uid': parent_level}]).append(cur_node)
47
- else:
48
- toc_yaml.append(cur_node)
49
- else:
50
- # if uid doesn't contain '.', the name needn't to simplify
51
- toc_yaml.append(cur_node)
52
- toc_node_map[uid] = cur_node
35
+ def find_node_in_toc_tree(toc_yaml, to_add_node):
36
+ for module in toc_yaml:
37
+ if module['name'] == to_add_node:
38
+ return module
39
+
40
+ if 'items' in module:
41
+ items = module['items']
42
+ found_module = find_node_in_toc_tree(items, to_add_node)
43
+ if found_module != None:
44
+ return found_module
45
+
46
+ return None
53
47
 
54
48
  def convert_class_to_enum_if_needed(obj):
55
49
  if (obj.get('inheritance'), None):
@@ -100,8 +94,7 @@ def build_finished(app, exception):
100
94
  API_ROOT
101
95
  ))
102
96
  ensuredir(normalized_outdir)
103
- project_name = app.config.project.replace('-','.')
104
- toc_node_map = {}
97
+
105
98
  toc_yaml = []
106
99
  # Used to record filenames dumped to avoid confliction
107
100
  # caused by Windows case insensitive file system
@@ -110,8 +103,8 @@ def build_finished(app, exception):
110
103
  # Order matters here, we need modules before lower level classes,
111
104
  # so that we can make sure to inject the TOC properly
112
105
  # put app.env.docfx_yaml_packages after app.env.docfx_yaml_modules to keep same TOC items order
113
- for data_set in (app.env.docfx_yaml_packages,
114
- app.env.docfx_yaml_modules,
106
+ for data_set in (app.env.docfx_yaml_modules,
107
+ app.env.docfx_yaml_packages,
115
108
  app.env.docfx_yaml_classes,
116
109
  app.env.docfx_yaml_functions): # noqa
117
110
 
@@ -219,7 +212,20 @@ def build_finished(app, exception):
219
212
  if (obj['type'] == 'class' and obj['inheritance']):
220
213
  convert_class_to_enum_if_needed(obj)
221
214
 
222
- insert_node_to_toc_tree(toc_yaml, uid, project_name, toc_node_map)
215
+ # Build nested TOC
216
+ if uid.count('.') >= 1:
217
+ parent_level = '.'.join(uid.split('.')[:-1])
218
+ found_node = find_node_in_toc_tree(toc_yaml, parent_level)
219
+
220
+ if found_node:
221
+ found_node.pop('uid', 'No uid found')
222
+ found_node.setdefault('items', [{'name': 'Overview', 'uid': parent_level}]).append(
223
+ {'name': uid, 'uid': uid})
224
+ else:
225
+ toc_yaml.append({'name': uid, 'uid': uid})
226
+
227
+ else:
228
+ toc_yaml.append({'name': uid, 'uid': uid})
223
229
 
224
230
  for data_set in (app.env.docfx_yaml_packages,
225
231
  app.env.docfx_yaml_modules,
@@ -266,8 +272,41 @@ def build_finished(app, exception):
266
272
  with open(toc_file, 'w') as writable:
267
273
  writable.write(
268
274
  dump(
269
- toc_yaml,
275
+ [{
276
+ 'name': app.config.project,
277
+ 'items': [{'name': 'Overview', 'uid': 'project-' + app.config.project}] + toc_yaml
278
+ }],
270
279
  default_flow_style=False,
271
280
  )
272
281
  )
273
-
282
+
283
+ index_file = os.path.join(normalized_outdir, 'index.yml')
284
+ index_children = []
285
+ index_references = []
286
+ for item in toc_yaml:
287
+ index_children.append(item.get('name', ''))
288
+ index_references.append({
289
+ 'uid': item.get('name', ''),
290
+ 'name': item.get('name', ''),
291
+ 'fullname': item.get('name', ''),
292
+ 'isExternal': False
293
+ })
294
+
295
+ index_obj = [{
296
+ 'uid': 'project-' + app.config.project,
297
+ 'name': app.config.project,
298
+ 'fullName': app.config.project,
299
+ 'langs': ['python'],
300
+ 'type': 'package',
301
+ 'kind': 'distribution',
302
+ 'summary': '',
303
+ 'children': index_children
304
+ }]
305
+ transformed_obj = convert_package(index_obj, app.env.docfx_info_uid_types)
306
+ mime = "PythonPackage"
307
+ if transformed_obj == None:
308
+ print("Unknown yml: " + yamlfile_path)
309
+ else:
310
+ # save file
311
+ common.write_yaml(transformed_obj, index_file, mime)
312
+ file_name_set.add(filename)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2docfx
3
- Version: 0.1.1.dev1622985
3
+ Version: 0.1.1.dev1626976
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=hOAtib9pTFaZCS8QbYS6Dhz0hNGESDHPXumRIuIWp4Y,2415
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=4gAjTchmTBNb0-g0i06rRVUjNbFXIL55knH3v5u6gWo,12823
55
+ py2docfx/docfx_yaml/build_finished.py,sha256=jf8--IvekegnTs6Qx9H31TlDNZA6E5yPWaInmHH9QbA,13996
56
56
  py2docfx/docfx_yaml/build_init.py,sha256=lAw-fnBVQbySfZ7Sut_NpFQUjnqLOmnGQrTBBH2RXcg,1860
57
57
  py2docfx/docfx_yaml/common.py,sha256=Tl6OPSIcvPjFw1AvWt5Mun8pQr9NtUGQnk4zh474Py0,6316
58
58
  py2docfx/docfx_yaml/convert_class.py,sha256=boKDaxnXbnLxja62UFXi3eChGDB_WBW6ouUUJgOhdpE,2098
@@ -112,7 +112,7 @@ py2docfx/docfx_yaml/tests/roots/test-writer-table/conf.py,sha256=avcbnIOV2mlGQwh
112
112
  py2docfx/docfx_yaml/tests/roots/test-writer-uri/code_with_uri.py,sha256=bzWTZpY2yf_By2bOSl1GFaY3BsZpkAvwQuGztlcHKkQ,537
113
113
  py2docfx/docfx_yaml/tests/roots/test-writer-uri/conf.py,sha256=avcbnIOV2mlGQwhMQJZC4W6UGRBRhnq1QBxjPWlySxQ,260
114
114
  py2docfx/docfx_yaml/tests/utils/test_utils.py,sha256=d0OYSUQ6NyoZx5mlLdNGGNhiNmmQhjVT4hQ6jY3VE_M,3383
115
- py2docfx-0.1.1.dev1622985.dist-info/METADATA,sha256=IBip8SicKCdI9fIb5WnLxZ05mrbWoRZQE538ci4j82E,601
116
- py2docfx-0.1.1.dev1622985.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
117
- py2docfx-0.1.1.dev1622985.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
118
- py2docfx-0.1.1.dev1622985.dist-info/RECORD,,
115
+ py2docfx-0.1.1.dev1626976.dist-info/METADATA,sha256=e91GJa9tJNOi4pWlJYftdnPOm-YLGHUHukSdjnmwmsE,601
116
+ py2docfx-0.1.1.dev1626976.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
117
+ py2docfx-0.1.1.dev1626976.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
118
+ py2docfx-0.1.1.dev1626976.dist-info/RECORD,,