Skip to content

Commit 47b8c5d

Browse files
committed
A tool to checking doc
1 parent c8b9c20 commit 47b8c5d

2 files changed

Lines changed: 57 additions & 2 deletions

File tree

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ build: clean ## build package
4949
test: ## running test
5050
@$(CURDIR)/tools/runtest.py -s ./tests -p .
5151

52+
.PHONY: check-doc
53+
check-doc: ## check documentation
54+
python $(CURDIR)/tools/checkdoc.py
55+
5256
.PHONY: doc
53-
doc: build ## generate api doc
54-
cd docs && make clean && make html
57+
doc: ## generate api doc
58+
cd $(CURDIR)/docs && make clean && make html
5559

5660
.PHONY: check
5761
check:

tools/checkdoc.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
"""
3+
Check doc use numpydoc.
4+
Need numpydoc 1.0, install latest develop:
5+
pip install git+https://github.com/numpy/numpydoc.git
6+
"""
7+
8+
import sys
9+
import subprocess
10+
11+
12+
def ismethod(m):
13+
return m.__class__.__name__ == "method_descriptor"
14+
15+
16+
def isclass(c):
17+
return c.__class__.__name__ == "type"
18+
19+
20+
def main():
21+
import ctools
22+
23+
names = [i for i in dir(ctools) if not i.startswith("_")]
24+
paths = []
25+
for name in names:
26+
variable = getattr(ctools, name)
27+
if not isclass(variable):
28+
paths.append("ctools." + name)
29+
30+
for m in dir(variable):
31+
if m.startswith("_"):
32+
continue
33+
method = getattr(variable, m)
34+
if ismethod(method):
35+
paths.append("ctools." + method.__qualname__)
36+
37+
exit_code = 0
38+
cmd = [sys.executable, "-m", "numpydoc", "--validate", "placeholder"]
39+
for path in paths:
40+
cmd[-1] = path
41+
v = "# -- " + path + " "
42+
print(v, "-" * (80 - len(v)))
43+
e = subprocess.call(cmd)
44+
if e != 0:
45+
exit_code = e
46+
return exit_code
47+
48+
49+
if __name__ == "__main__":
50+
sys.path.insert(0, ".")
51+
sys.exit(main())

0 commit comments

Comments
 (0)