diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 82872695029da72e33d139c968035b242c04faaf..34b597969b7b0ac464bc046798e0438184c6e44f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -62,8 +62,6 @@ test-centos7:
   - coverage html
   - pip3.6 install sphinx sphinx-argparse sphinxcontrib.bibtex sphinx_rtd_theme
   - cd docs
-  - sphinx-apidoc -o source/ippidb/ ../ippidb
-  - sphinx-apidoc -o source/ippisite/ ../ippisite
   - make html
   artifacts:
     paths:
diff --git a/ippisite/docs/Makefile b/ippisite/docs/Makefile
index 69fe55ecfa9aade66e1412aef0ee7d04a9bcde86..5fa94b06cfe70549942f3160cd249d19590d194b 100644
--- a/ippisite/docs/Makefile
+++ b/ippisite/docs/Makefile
@@ -3,6 +3,8 @@
 
 # You can set these variables from the command line.
 SPHINXOPTS    =
+SPHINXAPI     = sphinx-apidoc
+SPHINXAPISRC  = ..
 SPHINXBUILD   = sphinx-build
 SOURCEDIR     = source
 BUILDDIR      = build
@@ -16,4 +18,6 @@ help:
 # Catch-all target: route all unknown targets to Sphinx using the new
 # "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
 %: Makefile
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
+	@$(SPHINXAPI) -o $(SOURCEDIR) $(SPHINXAPISRC)
+	python ../manage.py graph_models ippidb --dot > source/db.dot
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)