-
Notifications
You must be signed in to change notification settings - Fork 766
Auto generate docs with sphinx #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace pdoc with Sphinx to auto-generate API reference.
…ries and 'make docs' to run sphinx-apidoc
Makefile
Outdated
@@ -27,10 +27,11 @@ cover: | |||
find tests -type d | xargs nosetests --with-coverage --cover-inclusive --cover-erase --cover-package=twilio | |||
|
|||
docs-install: | |||
. venv/bin/activate; pip install pdoc | |||
. venv/bin/activate; pip install twilio sphinx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this install twilio in the virtualenv? is that necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've imported __version__
from the twilio module on docs/config.py
. Is there a way to grab the current API version that doesn't require installing twilio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want the current API version -- you want the next API version (the one you're building the docs for). You already have the source for that in the virtualenv.
docs/Makefile
Outdated
@@ -0,0 +1,155 @@ | |||
# Minimal makefile for Sphinx documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're using sphinx-apidoc
to generate the docs, do we need this Makefile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sphinx-apidoc
generates the .rst files, that are used in this Makefile when we call make html
(look at line 34 of the Makefile above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think it will be easier to understand if you call rm docs
and sphinx-build
directly from the existing Makefile
, rather than adding a second one.
(You might as well remove the entire docs directory, rather than just build
, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved all the autogenerated .rst
files to source/_rst
. Now the directory is cleaned up every time new docs are generated (also added to .gitignore). This addresses your concern about deprecated modules (even though the rst files are just directives, so a new html wouldn't be created but the deprecated .rst
file would stay there).
I would prefer to keep the two Makefile
s, if you don't have a strong motivation behind merging them. Sphix's internal variables would make twilio-python/Makefile
too crowded.
docs/Makefile
Outdated
@@ -0,0 +1,155 @@ | |||
# Minimal makefile for Sphinx documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think it will be easier to understand if you call rm docs
and sphinx-build
directly from the existing Makefile
, rather than adding a second one.
(You might as well remove the entire docs directory, rather than just build
, right?)
docs/Makefile
Outdated
-rm -rf $(BUILDDIR)/* | ||
|
||
html: | ||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to put the docs into docs/build/html
, right? So I think you'll either need to open a PR against librarian to look there instead of in docs
, or you'll need to change the output directory to match what librarian expects.
Makefile
Outdated
@@ -27,11 +27,17 @@ cover: | |||
find tests -type d | xargs nosetests --with-coverage --cover-inclusive --cover-erase --cover-package=twilio | |||
|
|||
docs-install: | |||
. venv/bin/activate; pip install twilio sphinx | |||
. venv/bin/activate; pip install -U sphinx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to use pip install -r tests/requirements.txt
? It looks like we already require sphinx 1.4.9 there.
.gitignore
Outdated
@@ -26,6 +26,7 @@ pip-log.txt | |||
# sphinx build folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about the directory structure -- shouldn't these be located underneath docs/
?
Makefile
Outdated
-rm -rf source/_rst/* | ||
-rm -rf build/* | ||
. venv/bin/activate; sphinx-apidoc -f twilio -o docs/source/_rst | ||
. venv/bin/activate; sphinx-build -b html -c ./docs -d docs/build/doctrees . docs/build/html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does sphinx-build know where to find index.rst?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's on conf.py
and the -c flag indicates where the conf file lives
Makefile
Outdated
. venv/bin/activate; sphinx-apidoc -f twilio -o docs/source/_rst | ||
. venv/bin/activate; sphinx-build -b html -c ./docs -d docs/build/doctrees . docs/build/html | ||
|
||
@echo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of the other make targets have an output message like this, so I would drop it here too
Makefile
Outdated
|
||
docs: | ||
. venv/bin/activate; sphinx-apidoc -f twilio -o docs/source | ||
cd docs && make clean && make html | ||
-rm -rf source/_rst/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these paths have a docs/
prefix?
Also, if the directory must exist in order for sphinx to work, I think you'll need to add it yourself. If sphinx is OK with a nonexistent directory, then you can delete the directory itself instead of its contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Sphinx is ok with non-existent directory, and it creates one if it doesn't exist. And I will add the docs/ prefix
.gitignore
Outdated
build/ | ||
_rst | ||
# sphinx build and rst folder | ||
**/docs/_build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the **
, do we? docs
is a top-level directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double asterisks match patterns anywhere in the directory (even if it is top level)