Skip to content
Snippets Groups Projects
Commit dccf7ab3 authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

added Core fake

parent d207d490
No related branches found
No related tags found
7 merge requests!685Release 2.4,!684Release 2.4,!567Release 2.2.1,!566Release 2.2,!501Release 2.1,!372fix doctest snippets,!369Current documentation
......@@ -11,6 +11,7 @@ BUILDDIR = _build
# sphinx build controll:
# Function documentations will be acessible through: FUNCTIONS.saqc
FUNCTIONS = Functions
CORE = Core
# List of folders containing markdown content to include into the build
MDLIST = getting_started_md how_to_doc_md cook_books_md misc_md
# Put it first so that "make" without argument is like "make help".
......@@ -26,6 +27,7 @@ test:
clean:
rm -rf _build _static
rm -rf ../$(FUNCTIONS)
rm -rf ../$(CORE)
mkdir _static
# for k in $(MDLIST); do rm -r "$$k"_m2r; done
rm -f *.automodsumm
......
......@@ -63,8 +63,24 @@ Functions
:glob:
:titlesonly:
All Functions <moduleAPIs/saqcFunctions>
generic <moduleAPIs/functionsgeneric>
all <moduleAPIs/Functionssaqc>
resampling <moduleAPIs/Functionsresampling>
generic <moduleAPIs/Functionsgeneric>
outliers <moduleAPIs/Functionsoutliers>
breaks <moduleAPIs/Functionsbreaks>
constants <moduleAPIs/Functionsconstants>
changepoints <moduleAPIs/Functionschangepoints>
drift <moduleAPIs/Functionsdrift>
curvefit <moduleAPIs/Functionscurvefit>
interpolation <moduleAPIs/Functionsinterpolation>
residues <moduleAPIs/Functionsresidues>
tools <moduleAPIs/Functionstools>
flagtools <moduleAPIs/Functionsflagtools>
rolling <moduleAPIs/Functionsrolling>
scores <moduleAPIs/Functionsscores>
transformation <moduleAPIs/Functionstransformation>
noise <moduleAPIs/Functionsnoise>
Python Package
......@@ -74,7 +90,7 @@ Python Package
:glob:
:titlesonly:
SaQC init <moduleAPIs/saqcInit>
:py:class:`Core.Core.SaQC`
Indices and tables
......@@ -84,4 +100,3 @@ Indices and tables
* :ref:`modindex`
* :ref:`search`
:py:meth:`saqc.SaQC.flagMissing`
\ No newline at end of file
......@@ -138,6 +138,57 @@ def make_doc_module(targetpath, func_dict, doc_mod_structure):
return 0
def make_doc_core(sphinxroot, func_dict, doc_mod_structure):
targetfolder = os.path.join(sphinxroot, 'Core')
coresource = os.path.join(sphinxroot, os.path.normpath('saqc/core/core.py'))
# parse real core.py
with open(coresource) as f:
corelines = f.readlines()
# find SaQC class def
coreast = ast.parse(''.join(corelines))
startline = None
endline = None
for node in coreast.body:
if isinstance(node, ast.ClassDef):
if node.name == 'SaQC':
startline = node.lineno
elif startline and (not endline):
endline = node.lineno
start = corelines[:endline - 1]
end = corelines[endline - 1:]
tab = ' '
for doc_mod in [
d for d in doc_mod_structure.keys() if not re.search("_dcstring$", d)
]:
with open(os.path.join(targetfolder, f"Core.py"), "w+") as f:
mod_string = []
mod_funcs = doc_mod_structure[doc_mod]
for func in mod_funcs:
def_string = func_dict[func][0]
i_pos = re.match('def [^ ]*\(', def_string).span()[-1]
def_string = def_string[:i_pos] + 'self, ' + def_string[i_pos:]
def_string = tab + def_string
mod_string.append(def_string)
mod_string.append(2*tab + '"""')
# indent the docstring:
indented_doc_string = "\n".join(
[2*tab + f"{l}" for l in func_dict[func][1].splitlines()]
)
mod_string.append(indented_doc_string)
mod_string.append(2*tab + '"""')
mod_string.append(2*tab + "pass")
mod_string.append("")
mod_string.append("")
newcore = "".join(start) + "\n" + "\n".join(mod_string) + "\n" + "".join(end)
f.write(newcore)
return 0
def makeModuleAPIs(modules, folder_path="moduleAPIs", pck_path="Functions"):
f_path = os.path.abspath(folder_path)
for m in modules:
......@@ -192,6 +243,8 @@ def main(pckpath, targetpath, sphinxroot, mode):
root_path = os.path.abspath(sphinxroot)
pkg_path = os.path.join(root_path, pckpath)
targetpath = os.path.join(root_path, targetpath)
coretrg = os.path.join(sphinxroot, 'Core')
modules = []
# collect modules
for _, modname, _ in pkgutil.walk_packages(path=[pkg_path], onerror=lambda x: None):
......@@ -202,6 +255,10 @@ def main(pckpath, targetpath, sphinxroot, mode):
shutil.rmtree(targetpath)
os.makedirs(targetpath, exist_ok=True)
if os.path.isdir(coretrg):
shutil.rmtree(coretrg)
os.makedirs(coretrg, exist_ok=True)
# parse all the functions
module_paths = [os.path.join(pkg_path, f"{m}.py") for m in modules]
mod_dict = parse_module_dcstrings(module_paths)
......@@ -224,6 +281,8 @@ def main(pckpath, targetpath, sphinxroot, mode):
makeModuleAPIs(["saqc"])
make_doc_module(targetpath, func_dict, doc_mod_structure)
make_doc_core(root_path, func_dict, doc_mod_structure)
if __name__ == "__main__":
main()
......@@ -2,4 +2,4 @@
saqc
====
.. automodapi:: saqc.core.core
\ No newline at end of file
.. automodapi:: Core.Core
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment