Skip to content

Commit 2e16e78

Browse files
authored
Merge pull request #2 from marian-nmt/tg/apidoc
API doc via python instead of bash and make
2 parents 079cc97 + dc7372d commit 2e16e78

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

docs/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ SPHINXBUILD ?= sphinx-build
88
SPHINXAPIDOC ?= sphinx-apidoc
99
SOURCEDIR = .
1010
BUILDDIR = build
11-
MODULE_NAME = sotastream
12-
CODEDIR = ../$(MODULE_NAME)
11+
MODULE_NAME = sotastream
12+
CODEDIR = ../$(MODULE_NAME)
1313

1414
# Put it first so that "make" without argument is like "make help".
1515
help:
@@ -21,8 +21,5 @@ help:
2121
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2222

2323
%: Makefile
24-
@if [ $@ = "html" ]; then \
25-
$(SPHINXAPIDOC) -o "$(SOURCEDIR)/api" --force "$(CODEDIR)" -H "$(MODULE_NAME) API";\
26-
fi
2724
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
28-
@if [ $@ = "clean" ]; then rm -rf "$(SOURCEDIR)/api/"; fi
25+
@if [ $@ = "clean" ]; then rm -rf "$(SOURCEDIR)/api/"; fi

docs/conf.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
import sys
88
from pathlib import Path
99

10-
sys.path.insert(0, str(Path(__file__).parent.parent.parent.absolute()))
11-
# <root>/docs/source/conf.py i.e three levels up ^
10+
DOCS_DIR = Path(__file__).parent.absolute()
11+
PROJECT_DIR = DOCS_DIR.parent
12+
# <root>/docs/conf.py i.e two levels up ^
13+
SRC_DIR = PROJECT_DIR / 'sotastream'
14+
15+
sys.path.insert(0, str(PROJECT_DIR))
1216
import sotastream # this import should work
1317

1418
# -- Project information -----------------------------------------------------
@@ -25,7 +29,6 @@
2529
'sphinx.ext.autodoc',
2630
'sphinx.ext.mathjax',
2731
'sphinx.ext.viewcode',
28-
'sphinx.ext.githubpages',
2932
'sphinx.ext.autodoc',
3033
]
3134

@@ -40,3 +43,11 @@
4043
# html_theme = 'alabaster'
4144
html_theme = 'sphinx_rtd_theme'
4245
html_static_path = ['_static']
46+
47+
def run_apidoc(_):
48+
# from sphinx.apidoc import main # for older Sphinx <= 1.6
49+
from sphinx.ext.apidoc import main # for newer
50+
main(['-e', '-o', str(DOCS_DIR / 'api'), str(SRC_DIR), '--force'])
51+
52+
def setup(app):
53+
app.connect('builder-inited', run_apidoc)

0 commit comments

Comments
 (0)