Skip to content

Commit

Permalink
Add check_names, checks if all routines are added in sphinx help
Browse files Browse the repository at this point in the history
  • Loading branch information
KybernetikJo committed Aug 26, 2023
1 parent db1652b commit fb26217
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
45 changes: 45 additions & 0 deletions doc/check_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generate the routines divide by slicot-chapters for sphinx-doc.
# Only prints out the names, copy & past them into slycot_outer.rst and slycot_inner.rst.
import re
import pandas as pd
import warnings

import slycot
slycot.__version__

def get_slycot_routines(sly):
all_attributes = dir(sly)
r = re.compile("[a-z][a-z][0-9][0-9a-z][a-z][a-z]")
matched_attributes = list(filter(r.match, all_attributes))
return matched_attributes

def get_slycot_routines_help(file,pre=""):
textfile = open(file, 'r')
filetext = textfile.read()
textfile.close()
lines = filetext.split("\n")
res = [ele.replace(" ","") for ele in lines]
res = [ele.replace("_wrapper.","") for ele in res]

r = re.compile("[a-z][a-z][0-9][0-9a-z][a-z][a-z]")
matched_attributes = list(filter(r.match, res))
return matched_attributes

slycot_wrapper = get_slycot_routines(slycot)
slycot_wrapper.sort()
slycot_f2py_wrapper = get_slycot_routines(slycot._wrapper)
slycot_f2py_wrapper.sort()

slycot_wrapper_help = get_slycot_routines_help("source/reference/slycot_outer.rst")
slycot_wrapper_help.sort()

slycot_f2py_wrapper_help = get_slycot_routines_help("source/reference/slycot_inner.rst")
slycot_f2py_wrapper_help.sort()

missing = list(set(slycot_wrapper) - set(slycot_wrapper_help))
if bool(missing):
warnings.warn(f"The routines {missing} are missing in 'slycot_outer.rst'.")

missing = list(set(slycot_f2py_wrapper) - set(slycot_f2py_wrapper_help))
if bool(missing):
warnings.warn(f"The routines _wrapper.{missing} are missing in 'slycot_inner.rst'.")
4 changes: 4 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import sys
sys.path.insert(0, os.path.abspath('../slycot'))

import subprocess
subprocess.run(["python", "check_names.py"])

project = 'Slycot'
copyright = '2023, Slycot Developers'
author = 'Slycot Developers'
Expand All @@ -25,6 +28,7 @@

print("version %s, release %s" % (version, release))


# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

Expand Down

0 comments on commit fb26217

Please sign in to comment.