Skip to content

Commit c327620

Browse files
committed
Add check_names, checks if all routines are added in sphinx help
1 parent 1ab9613 commit c327620

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

doc/check_names.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generate the routines divide by slicot-chapters for sphinx-doc.
2+
# Only prints out the names, copy & past them into slycot_outer.rst and slycot_inner.rst.
3+
import re
4+
import pandas as pd
5+
import warnings
6+
7+
import slycot
8+
slycot.__version__
9+
10+
def get_slycot_routines(sly):
11+
all_attributes = dir(sly)
12+
r = re.compile("[a-z][a-z][0-9][0-9a-z][a-z][a-z]")
13+
matched_attributes = list(filter(r.match, all_attributes))
14+
return matched_attributes
15+
16+
def get_slycot_routines_help(file,pre=""):
17+
textfile = open(file, 'r')
18+
filetext = textfile.read()
19+
textfile.close()
20+
lines = filetext.split("\n")
21+
res = [ele.replace(" ","") for ele in lines]
22+
res = [ele.replace("_wrapper.","") for ele in res]
23+
24+
r = re.compile("[a-z][a-z][0-9][0-9a-z][a-z][a-z]")
25+
matched_attributes = list(filter(r.match, res))
26+
return matched_attributes
27+
28+
slycot_wrapper = get_slycot_routines(slycot)
29+
slycot_wrapper.sort()
30+
slycot_f2py_wrapper = get_slycot_routines(slycot._wrapper)
31+
slycot_f2py_wrapper.sort()
32+
33+
slycot_wrapper_help = get_slycot_routines_help("source/reference/slycot_outer.rst")
34+
slycot_wrapper_help.sort()
35+
36+
slycot_f2py_wrapper_help = get_slycot_routines_help("source/reference/slycot_inner.rst")
37+
slycot_f2py_wrapper_help.sort()
38+
39+
missing = list(set(slycot_wrapper) - set(slycot_wrapper_help))
40+
if bool(missing):
41+
warnings.warn(f"The routines {missing} are missing in 'slycot_outer.rst'.")
42+
43+
missing = list(set(slycot_f2py_wrapper) - set(slycot_f2py_wrapper_help))
44+
if bool(missing):
45+
warnings.warn(f"The routines _wrapper.{missing} are missing in 'slycot_inner.rst'.")

doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import sys
1111
sys.path.insert(0, os.path.abspath('../slycot'))
1212

13+
import subprocess
14+
subprocess.run(["python", "check_names.py"])
15+
1316
project = 'Slycot'
1417
copyright = '2023, Slycot Developers'
1518
author = 'Slycot Developers'
@@ -25,6 +28,7 @@
2528

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

31+
2832
# -- General configuration ---------------------------------------------------
2933
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
3034

0 commit comments

Comments
 (0)