Skip to content

Commit bd8bdd3

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 062bb96 + 05be11c commit bd8bdd3

File tree

133 files changed

+2214
-1464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2214
-1464
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.8
2+
current_version = 0.0.9.dev0
33
commit = False
44
tag = False
55
allow_dirty = False

.github/workflows/tox.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Merge develop, run tests and build docu
1+
name: Merge develop, run tests and build documentation
22

33
on:
44
pull_request:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.orig
88
.tox
99
docs/_build
10+
docs/sensai
1011
/sync.py
1112
dist
1213
*.egg-info*

build-docs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python build_scripts/update_docs.py
2+
sphinx-build -W -b html docs docs/build
3+

build_scripts/update_docs.py

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
#!/usr/bin/env python3
22
import logging
33
import os
4-
5-
# This script is copy-pasted from a cookiecutter template (to be open sourced soon)
6-
# and therefore does not adhere to the code conventions for the remainder of sensAI
4+
import shutil
75

86

97
log = logging.getLogger(os.path.basename(__file__))
108

119

12-
def module_template(module_path: str):
13-
title = os.path.basename(module_path).replace("_", r"\_")
14-
title = title[:-3] # removing trailing .py
15-
module_path = module_path[:-3]
10+
def module_template(module_qualname: str):
11+
module_name = module_qualname.split(".")[-1]
12+
title = module_name.replace("_", r"\_")
1613
template = f"""{title}
1714
{"="*len(title)}
1815
19-
.. automodule:: {module_path.replace(os.path.sep, ".")}
16+
.. automodule:: {module_qualname}
2017
:members:
2118
:undoc-members:
2219
"""
2320
return template
2421

2522

26-
def package_template(package_path: str):
27-
package_name = os.path.basename(package_path)
23+
def package_template(package_qualname: str):
24+
package_name = package_qualname.split(".")[-1]
2825
title = package_name.replace("_", r"\_")
2926
template = f"""{title}
3027
{"="*len(title)}
3128
32-
.. automodule:: {package_path.replace(os.path.sep, ".")}
29+
.. automodule:: {package_qualname}
3330
:members:
3431
:undoc-members:
3532
@@ -41,50 +38,80 @@ def package_template(package_path: str):
4138
return template
4239

4340

41+
def indexTemplate(package_name):
42+
title = "Modules"
43+
template = \
44+
f"""{title}
45+
{"="*len(title)}
46+
47+
.. automodule:: {package_name}
48+
:members:
49+
:undoc-members:
50+
51+
.. toctree::
52+
:glob:
53+
54+
*
55+
"""
56+
return template
57+
58+
4459
def write_to_file(content: str, path: str):
60+
os.makedirs(os.path.dirname(path), exist_ok=True)
4561
with open(path, "w") as f:
4662
f.write(content)
4763
os.chmod(path, 0o666)
4864

4965

50-
def make_docu(basedir=os.path.join("src", "sensai"), overwrite=False):
66+
67+
def make_rst(src_root=os.path.join("src", "sensai"), rst_root=os.path.join("docs", "sensai"), clean=False, overwrite=False):
5168
"""
5269
Creates/updates documentation in form of rst files for modules and packages.
5370
Does not delete any existing rst files. Thus, rst files for packages or modules that have been removed or renamed
5471
should be deleted by hand.
5572
5673
This method should be executed from the project's top-level directory
5774
58-
:param basedir: path to library basedir, typically "src/<library_name>"
75+
:param src_root: path to library base directory, typically "src/<library_name>"
76+
:param clean: whether to completely clean the target directory beforehand, removing any existing .rst files
5977
:param overwrite: whether to overwrite existing rst files. This should be used with caution as it will delete
6078
all manual changes to documentation files
6179
:return:
6280
"""
63-
library_basedir = basedir.split(os.path.sep, 1)[1] # splitting off the "src" part
64-
for file in os.listdir(basedir):
65-
if file.startswith("_"):
66-
continue
81+
rst_root = os.path.abspath(rst_root)
6782

68-
library_file_path = os.path.join(library_basedir, file)
69-
full_path = os.path.join(basedir, file)
70-
file_name, ext = os.path.splitext(file)
71-
docs_file_path = os.path.join("docs", library_basedir, f"{file_name}.rst")
72-
if os.path.exists(docs_file_path) and not overwrite:
73-
log.debug(f"{docs_file_path} already exists, skipping it")
74-
if os.path.isdir(full_path):
75-
make_docu(basedir=full_path, overwrite=overwrite)
83+
if clean and os.path.isdir(rst_root):
84+
shutil.rmtree(rst_root)
85+
86+
base_package_name = os.path.basename(src_root)
87+
write_to_file(indexTemplate(base_package_name), os.path.join(rst_root, "index.rst"))
88+
89+
for root, dirnames, filenames in os.walk(src_root):
90+
if os.path.basename(root).startswith("_"):
7691
continue
77-
os.makedirs(os.path.dirname(docs_file_path), exist_ok=True)
92+
base_package_relpath = os.path.relpath(root, start=src_root)
93+
base_package_qualname = os.path.relpath(root, start=os.path.dirname(src_root)).replace(os.path.sep, ".")
94+
95+
for dirname in dirnames:
96+
if not dirname.startswith("_"):
97+
package_qualname = f"{base_package_qualname}.{dirname}"
98+
package_rst_path = os.path.join(rst_root, base_package_relpath, f"{dirname}.rst")
99+
log.info(f"Writing package documentation to {package_rst_path}")
100+
write_to_file(package_template(package_qualname), package_rst_path)
101+
102+
for filename in filenames:
103+
base_name, ext = os.path.splitext(filename)
104+
if ext == ".py" and not filename.startswith("_"):
105+
module_qualname = f"{base_package_qualname}.{filename[:-3]}"
106+
107+
module_rst_path = os.path.join(rst_root, base_package_relpath, f"{base_name}.rst")
108+
if os.path.exists(module_rst_path) and not overwrite:
109+
log.debug(f"{module_rst_path} already exists, skipping it")
78110

79-
if ext == ".py":
80-
log.info(f"writing module docu to {docs_file_path}")
81-
write_to_file(module_template(library_file_path), docs_file_path)
82-
elif os.path.isdir(full_path):
83-
log.info(f"writing package docu to {docs_file_path}")
84-
write_to_file(package_template(library_file_path), docs_file_path)
85-
make_docu(basedir=full_path, overwrite=overwrite)
111+
log.info(f"Writing module documentation to {module_rst_path}")
112+
write_to_file(module_template(module_qualname), module_rst_path)
86113

87114

88115
if __name__ == "__main__":
89116
logging.basicConfig(level=logging.INFO)
90-
make_docu()
117+
make_rst(clean=True)

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ def findLineFromObjectName(sourceFile, objectName):
117117
"MySQLdb",
118118
"catboost",
119119
"clearml",
120-
"azure"
120+
"azure",
121+
"geopandas",
122+
"shapely",
123+
"networkx"
121124
]
122125

123126
# Render docu of __init__ methods

docs/sensai/catboost.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/sensai/clustering.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/sensai/clustering/base.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/sensai/clustering/base/clustering.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)