py2docfx 0.1.0.dev1464944__py3-none-any.whl → 0.1.0.dev1465062__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/package_info.py +3 -0
- py2docfx/convert_prepare/sphinx_caller.py +41 -8
- py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/__init__.py +0 -0
- py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/sourcecode/__init__.py +0 -0
- py2docfx/convert_prepare/tests/test_generate_document.py +11 -9
- py2docfx/convert_prepare/tests/test_package_info.py +1 -0
- py2docfx/convert_prepare/tests/test_sphinx_caller.py +2 -3
- {py2docfx-0.1.0.dev1464944.dist-info → py2docfx-0.1.0.dev1465062.dist-info}/METADATA +1 -1
- {py2docfx-0.1.0.dev1464944.dist-info → py2docfx-0.1.0.dev1465062.dist-info}/RECORD +13 -11
- /py2docfx/convert_prepare/tests/data/generate_document/{dummy_source_code → dummy-sourcecode/dummy/sourcecode}/boo/boo.py +0 -0
- /py2docfx/convert_prepare/tests/data/generate_document/{dummy_source_code → dummy-sourcecode/dummy/sourcecode}/foo/foo.py +0 -0
- {py2docfx-0.1.0.dev1464944.dist-info → py2docfx-0.1.0.dev1465062.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.0.dev1464944.dist-info → py2docfx-0.1.0.dev1465062.dist-info}/top_level.txt +0 -0
@@ -154,4 +154,7 @@ class PackageInfo:
|
|
154
154
|
for path in self.exclude_path
|
155
155
|
]
|
156
156
|
)
|
157
|
+
# exclude root package __init__.py, prevent generating azure.yml
|
158
|
+
root_package_name = [seg for seg in self.name.split('-') if seg][0]
|
159
|
+
exclude_path.append(os.path.join(code_location, f'{root_package_name}/__init__.py'))
|
157
160
|
return exclude_path
|
@@ -1,11 +1,17 @@
|
|
1
1
|
import os
|
2
2
|
from sphinx.application import Sphinx
|
3
3
|
import sphinx.ext.apidoc as apidoc
|
4
|
+
import sphinx.cmd.build
|
5
|
+
import subprocess
|
6
|
+
from pathlib import Path
|
7
|
+
from py2docfx import PACKAGE_ROOT
|
4
8
|
from py2docfx.convert_prepare.package_info import PackageInfo
|
5
9
|
from py2docfx.convert_prepare.paths import folder_is_hidden
|
6
10
|
from py2docfx.convert_prepare.subpackage import (get_subpackages,
|
7
11
|
move_rst_files_to_subfolder)
|
8
12
|
|
13
|
+
DEBUG_SPHINX_FLAG = 'PY2DOCFX_DEBUG_SPHINX'
|
14
|
+
|
9
15
|
def run_apidoc(rst_path, source_code_path, exclude_paths, package_info: PackageInfo):
|
10
16
|
"""
|
11
17
|
Run sphinx-apidoc to generate RST inside rst_path folder
|
@@ -52,12 +58,39 @@ def run_converter(rst_path, out_path, conf_path = None):
|
|
52
58
|
"""
|
53
59
|
|
54
60
|
outdir = os.path.join(out_path, "_build")
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
# Sphinx/docutils have memory leak including linecaches, module-import-caches,
|
63
|
+
# Use a subprocess on production to prevent out of memory
|
64
|
+
debug_into_sphinx = os.environ.get(DEBUG_SPHINX_FLAG, 'false')
|
65
|
+
debug_into_sphinx = debug_into_sphinx.lower() in {'true', '1'}
|
66
|
+
if debug_into_sphinx:
|
67
|
+
app = Sphinx(
|
68
|
+
srcdir=rst_path,
|
69
|
+
outdir=outdir,
|
70
|
+
confdir=conf_path or rst_path,
|
71
|
+
doctreedir=os.path.join(outdir, "doctrees"),
|
72
|
+
buildername="yaml",
|
73
|
+
)
|
74
|
+
app.build(force_all=True)
|
75
|
+
else:
|
76
|
+
sphinx_build_path = sphinx.cmd.build.__file__
|
77
|
+
sphinx_param = [
|
78
|
+
'python', sphinx_build_path,
|
79
|
+
rst_path,
|
80
|
+
outdir,
|
81
|
+
'-c', conf_path or rst_path,
|
82
|
+
'-d', os.path.join(outdir, "doctrees"),
|
83
|
+
'-b', 'yaml'
|
84
|
+
]
|
85
|
+
|
86
|
+
# TODO: update generate_conf to replace "yaml_builder" with "py2docfx.docfx_yaml.yaml_builder"
|
87
|
+
# then no need to manually add docfx_yaml to path
|
88
|
+
package_root_parent = os.path.join(PACKAGE_ROOT, 'docfx_yaml')
|
89
|
+
env_tmp = os.environ.copy()
|
90
|
+
python_path_current = env_tmp.get('PYTHONPATH', None)
|
91
|
+
if os.name == 'nt' :
|
92
|
+
env_tmp["PYTHONPATH"] = f"{package_root_parent};{python_path_current}" if python_path_current else package_root_parent
|
93
|
+
else:
|
94
|
+
env_tmp["PYTHONPATH"] = f"{package_root_parent}:{python_path_current}" if python_path_current else package_root_parent
|
95
|
+
subprocess.run(sphinx_param, check=True, cwd=PACKAGE_ROOT, env=env_tmp)
|
63
96
|
return outdir
|
File without changes
|
py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/sourcecode/__init__.py
ADDED
File without changes
|
@@ -13,26 +13,26 @@ def test_generate_document(tmp_path):
|
|
13
13
|
Test the generate_document function.
|
14
14
|
"""
|
15
15
|
# init test case
|
16
|
-
source_code_path = "convert_prepare\\tests\\data\\generate_document
|
16
|
+
source_code_path = "convert_prepare\\tests\\data\\generate_document"
|
17
17
|
output_root = os.path.join(tmp_path, "output")
|
18
18
|
shutil.copytree(source_code_path, os.path.join(tmp_path, "source\\0"))
|
19
19
|
package = PackageInfo()
|
20
|
-
package.name = "
|
20
|
+
package.name = "dummy-sourcecode"
|
21
21
|
package.exclude_path = ["test*", "example*", "sample*", "doc*"]
|
22
22
|
package.install_type = PackageInfo.InstallType.PYPI
|
23
23
|
package.version = None
|
24
24
|
package.build_in_subpackage = False
|
25
25
|
package.extra_index_url = None
|
26
26
|
package.prefer_source_distribution = False
|
27
|
-
source_folder = os.path.join(tmp_path, "source\\0")
|
27
|
+
source_folder = os.path.join(tmp_path, "source\\0\\dummy-sourcecode")
|
28
28
|
yaml_output_folder = os.path.join(tmp_path, "yaml_output")
|
29
29
|
package.path = Source(
|
30
30
|
source_folder=source_folder, yaml_output_folder=yaml_output_folder, package_name=package.name
|
31
31
|
)
|
32
32
|
|
33
33
|
# add dummy code to python sys path to simulate installation
|
34
|
-
|
35
|
-
sys.path.insert(0, os.path.abspath(
|
34
|
+
os.environ["PYTHONPATH"] = os.path.abspath(source_folder)
|
35
|
+
sys.path.insert(0, os.path.abspath(source_folder))
|
36
36
|
|
37
37
|
# add docfx_yaml to python sys path for sphinx build to import
|
38
38
|
sys.path.insert(1, os.path.abspath("docfx_yaml"))
|
@@ -43,10 +43,12 @@ def test_generate_document(tmp_path):
|
|
43
43
|
#assert the result
|
44
44
|
yaml_path = os.path.join(yaml_output_folder, "_build\\docfx_yaml")
|
45
45
|
assert os.path.exists(yaml_path)
|
46
|
-
assert os.path.exists(os.path.join(yaml_path, "
|
47
|
-
assert os.path.exists(os.path.join(yaml_path, "
|
48
|
-
assert os.path.exists(os.path.join(yaml_path, "
|
49
|
-
assert os.path.exists(os.path.join(yaml_path, "
|
46
|
+
assert os.path.exists(os.path.join(yaml_path, "dummy.sourcecode.foo.foo.yml"))
|
47
|
+
assert os.path.exists(os.path.join(yaml_path, "dummy.sourcecode.boo.boo.yml"))
|
48
|
+
assert os.path.exists(os.path.join(yaml_path, "dummy.sourcecode.foo.foo.Foo.yml"))
|
49
|
+
assert os.path.exists(os.path.join(yaml_path, "dummy.sourcecode.boo.boo.Boo.yml"))
|
50
|
+
assert os.path.exists(os.path.join(yaml_path, "dummy.sourcecode.yml"))
|
51
|
+
assert not os.path.exists(os.path.join(yaml_path, "dummy.yml"))
|
50
52
|
assert os.path.exists(os.path.join(yaml_path, "toc.yml"))
|
51
53
|
assert os.path.exists(os.path.join(yaml_path, "index.yml"))
|
52
54
|
|
@@ -18,7 +18,7 @@ def init_paths(tmp_path):
|
|
18
18
|
package_info.exclude_path = ["testcode\\exclude\\*"]
|
19
19
|
package_info.path = Source(source_folder=destination, yaml_output_folder=rst_path, package_name="testcode")
|
20
20
|
package_info.build_in_subpackage = False
|
21
|
-
|
21
|
+
package_info.name = 'testcode'
|
22
22
|
return rst_path, destination
|
23
23
|
|
24
24
|
|
@@ -28,7 +28,6 @@ def test_run_apidoc(tmp_path):
|
|
28
28
|
|
29
29
|
# List all files under rst_path
|
30
30
|
rst_list = os.listdir(rst_path)
|
31
|
-
assert "testcode.rst" in rst_list
|
32
31
|
assert "testcode.fakemodule.rst" in rst_list
|
33
32
|
assert "testcode.exclude.rst" not in rst_list
|
34
33
|
|
@@ -51,7 +50,7 @@ def test_run_converter(tmp_path):
|
|
51
50
|
|
52
51
|
if os.path.exists(out_path):
|
53
52
|
yaml_list = os.listdir(os.path.join(out_path, "docfx_yaml"))
|
54
|
-
assert "testcode.yml" in yaml_list
|
53
|
+
assert "testcode.yml" not in yaml_list
|
55
54
|
assert "testcode.fakemodule.test_code.yml" in yaml_list
|
56
55
|
assert "testcode.fakemodule.test_code.testClass.yml" in yaml_list
|
57
56
|
assert "toc.yml" in yaml_list
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py2docfx
|
3
|
-
Version: 0.1.0.
|
3
|
+
Version: 0.1.0.dev1465062
|
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
|
@@ -8,13 +8,13 @@ py2docfx/convert_prepare/get_source.py,sha256=1XOdFABdzhmSld8-w72gaOQv8_xaUX7_Vn
|
|
8
8
|
py2docfx/convert_prepare/git.py,sha256=fY9urQQp5aMnlGnFrSvTTR0FPnIc-28b50W1NzIPpaw,5640
|
9
9
|
py2docfx/convert_prepare/install_package.py,sha256=hATmgazcSX7k2n4jQXh9sQMyNUc1k1YqHv5K5UMALq4,262
|
10
10
|
py2docfx/convert_prepare/pack.py,sha256=vZS67_GzEhUmZWHU1dxm8gnWyRBs-kB6-KjX1d_FdOU,1260
|
11
|
-
py2docfx/convert_prepare/package_info.py,sha256=
|
11
|
+
py2docfx/convert_prepare/package_info.py,sha256=ZSYDTKVqDYV6DLx6N6sD05qNbreIbjyo5IOLEhsGUrw,6549
|
12
12
|
py2docfx/convert_prepare/params.py,sha256=PXMB8pLtb4XbfI322avA47q0AO-TyBE6kZf7FU8I6v4,1771
|
13
13
|
py2docfx/convert_prepare/paths.py,sha256=964RX81Qf__rzXgEATfqBNFCKTYVjLt9J7WCz2TnNdc,485
|
14
14
|
py2docfx/convert_prepare/pip_utils.py,sha256=W8PJQQSZXUW7W_mdBxaK6KRuxMEskO1-Hw6hjRazqTY,1127
|
15
15
|
py2docfx/convert_prepare/repo_info.py,sha256=6ASJlhBwf6vZTSENgrWCVlJjlJVhuBxzdQyWEdWAC4c,117
|
16
16
|
py2docfx/convert_prepare/source.py,sha256=reRr3zPG_Q8zCGaJf-7JbaO0A58RCQAURiGYamx6LEM,1449
|
17
|
-
py2docfx/convert_prepare/sphinx_caller.py,sha256=
|
17
|
+
py2docfx/convert_prepare/sphinx_caller.py,sha256=ZeCEtJPdondwX50Gso6nPwre5VUqtVoBTtbWJ5ID5tU,4132
|
18
18
|
py2docfx/convert_prepare/subpackage.py,sha256=mXAi_07pXvnPkSLZfykDh_7VeFxfLy74pYlzhMO8N_Q,5183
|
19
19
|
py2docfx/convert_prepare/conf_templates/conf.py_t,sha256=VL5K6xUTIw2cb4GFjDXu5iCZFPA2Kb36KLvier78HFg,3811
|
20
20
|
py2docfx/convert_prepare/conf_templates/master_doc.rst_t,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -23,17 +23,19 @@ py2docfx/convert_prepare/post_process/merge_toc.py,sha256=jF4u9Zb618SCSQG7u8IxCd
|
|
23
23
|
py2docfx/convert_prepare/subpackage_merge/merge_root_package.py,sha256=uK96qL2asuSfo_3SZaoP8XZaUvjf5mNkr17JNbZR4Lg,1026
|
24
24
|
py2docfx/convert_prepare/subpackage_merge/merge_toc.py,sha256=nkVqe8R0m8D6cyTYV7aIpMDXorvn4-LXfU_vIK_hJBg,1706
|
25
25
|
py2docfx/convert_prepare/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
py2docfx/convert_prepare/tests/test_generate_document.py,sha256=
|
26
|
+
py2docfx/convert_prepare/tests/test_generate_document.py,sha256=xyGo19FNQeyh6Xpt64a-fAY0VyMswNZgR7RAHdg1IMQ,2363
|
27
27
|
py2docfx/convert_prepare/tests/test_get_source.py,sha256=c22JfobgbEbWWiNzBNYpZm2yDfo5LwBioUuRwft9WZE,5858
|
28
28
|
py2docfx/convert_prepare/tests/test_pack.py,sha256=46JWMNzknIptDVs7D3CuxcmqBr_OKMmaw1br9H7wqco,4134
|
29
|
-
py2docfx/convert_prepare/tests/test_package_info.py,sha256=
|
29
|
+
py2docfx/convert_prepare/tests/test_package_info.py,sha256=OCXoIbIDD8Bu0wMiQctMzFSkyFjfaxtCFf0wS1EHqs8,2210
|
30
30
|
py2docfx/convert_prepare/tests/test_params.py,sha256=Kc6JnoCbC3VvZwzPac1_46USsoZy-2YG-GrwhqFa8sI,2017
|
31
31
|
py2docfx/convert_prepare/tests/test_post_process_merge_toc.py,sha256=YKOcn4_lf4syGsAvJ9BqpdUUc3SLfK4TiOX1lpXJT_Y,885
|
32
32
|
py2docfx/convert_prepare/tests/test_source.py,sha256=xkbYu-F6xNBlXWW0nu0YDYwc5zNj8h67Qd-3QpJ_B0M,1281
|
33
|
-
py2docfx/convert_prepare/tests/test_sphinx_caller.py,sha256=
|
33
|
+
py2docfx/convert_prepare/tests/test_sphinx_caller.py,sha256=RvTPo3DBecr-Z9JwU7qulnfnm2d-ipv7eqebWIbaE2Y,2532
|
34
34
|
py2docfx/convert_prepare/tests/test_subpackage.py,sha256=n0lCcdrTE1gkmmfGE85tSBMlpOEBszZafaHXffxo3Oc,4982
|
35
|
-
py2docfx/convert_prepare/tests/data/generate_document/
|
36
|
-
py2docfx/convert_prepare/tests/data/generate_document/
|
35
|
+
py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
+
py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/sourcecode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
|
+
py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/sourcecode/boo/boo.py,sha256=zXze_R2qRsJsAB8Z1LY5ZGRHWDo-j3N6Tnw1yBy9gVs,97
|
38
|
+
py2docfx/convert_prepare/tests/data/generate_document/dummy-sourcecode/dummy/sourcecode/foo/foo.py,sha256=i2oC5eoHl-HNW1mhLotsOwgdnVzkR0jRj4rnNjMbbCU,97
|
37
39
|
py2docfx/convert_prepare/tests/data/get_source/mock-1/setup.py,sha256=6Zcy-AkzBIuiyU67AdApqj7nF6rNNTd8733ie0M4R-A,121
|
38
40
|
py2docfx/convert_prepare/tests/data/pack/foo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
41
|
py2docfx/convert_prepare/tests/data/pack/foo/foo.py,sha256=nFSS0Abt9DB2jpxbrpv6UNmDiz8pgeChJoPWsFDrRQU,14
|
@@ -99,7 +101,7 @@ py2docfx/docfx_yaml/tests/roots/test-translator-signatures/refered_objects.py,sh
|
|
99
101
|
py2docfx/docfx_yaml/tests/roots/test-writer-table/code_with_table_desc.py,sha256=J4eFvXsymgFvjnwVUY0APtUGwuxvt-AFJjTaEaQ7zMQ,574
|
100
102
|
py2docfx/docfx_yaml/tests/roots/test-writer-table/conf.py,sha256=avcbnIOV2mlGQwhMQJZC4W6UGRBRhnq1QBxjPWlySxQ,260
|
101
103
|
py2docfx/docfx_yaml/tests/utils/test_utils.py,sha256=N61dPDo5vuRSWlq3FIbdmalOwxGMzbKDILpRBeN58RE,3374
|
102
|
-
py2docfx-0.1.0.
|
103
|
-
py2docfx-0.1.0.
|
104
|
-
py2docfx-0.1.0.
|
105
|
-
py2docfx-0.1.0.
|
104
|
+
py2docfx-0.1.0.dev1465062.dist-info/METADATA,sha256=8KGyc82CBXUzJW6ksUtE2BaotKp0i0m1Vl4RohYGz4s,601
|
105
|
+
py2docfx-0.1.0.dev1465062.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
106
|
+
py2docfx-0.1.0.dev1465062.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
|
107
|
+
py2docfx-0.1.0.dev1465062.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|