Skip to content

Conversation

@saimn
Copy link
Contributor

@saimn saimn commented Sep 8, 2015

When using a classic make html inside the doc directory, the doc is build in docs/_build/html.
But when using python setup.py build_docs as stated in the install page the output path is build/sphinx/html which is quite confusing. I had an old version of the doc in the first directory, which was not updated when running build_docs.

The build/sphinx/ path seems to come from sphinx.setup_command.BuildDoc, maybe it could modified in AstropyBuildSphinx to docs/_build/ and have the same output drectory as make html ?

Futhermore make html is broken for me with Python 3.4. This is related to #2532, but in my case, with python 3 and an install in develop mode, import astropy_helpers works because the astropy_helpers directory is inside the astropy one pointed by the .egg-link, but it returns an invalid module:

~/lib/astropy/docs docs
(astropy)❯ python -c 'import astropy_helpers; print(astropy_helpers)'
<module 'astropy_helpers' (namespace)>

With the following patch I can use make html in the docs directory, but it is just more hackish :

diff --git a/docs/conf.py b/docs/conf.py
index 11192b9..9ae24ea 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -26,7 +26,7 @@
 # be accessible, and the documentation will not build correctly.

 try:
-    import astropy_helpers
+    from astropy_helpers.sphinx.conf import *
 except ImportError:
     # Building from inside the docs/ directory?
     import os
@@ -36,6 +36,9 @@ except ImportError:
         if os.path.isdir(a_h_path):
             sys.path.insert(1, a_h_path)

+    if 'astropy_helpers' in sys.modules:
+        del sys.modules['astropy_helpers']
+
     # If that doesn't work trying to import from astropy_helpers below will
     # still blow up

Depending on the build method the output directory is not the same:

- `docs/_build/html` with `make html` in the docs directory
- `build/sphinx/html` with `setup.py build_docs`
@embray
Copy link
Member

embray commented Sep 9, 2015

I've noticed also that that changed, but I'm not entirely sure why it did. I don't think it was intentional, and it may be something that changed actually in Sphinx. I agree it's confusing, and would rather it just go to docs/_build (or alternatively, "build/docs", but not "build/sphinx" since that's hard to find...).

I'm not sure about running make html directly though. I think that there are reasons in the past that I've said it won't work, but I can't articulate them at the moment. If you want to have the submodule of astropy_helpers on your path during development you should:

$ cd astropy_helpers
$ ./setup.py develop

@saimn
Copy link
Contributor Author

saimn commented Sep 10, 2015

I have no preference between the two ways to build the docs, but if setup.py build_docs is the way to go then the Makefile should probably be removed to avoid confusion (especially if this way is broken).

@embray embray added the zzz 💤 astropy-helpers archived: PRs and issues related to astropy-helpers label Sep 10, 2015
@embray
Copy link
Member

embray commented Sep 10, 2015

Looking at the build_sphinx command implementation, it seems to also assume that the docs are going to be output to docs/_build. I swear it used to do that too. So I suspect something changed in Sphinx. That would be an issue for astropy-helpers though.

I'd be okay with removing the makefile--I never use it and see no reason to have more than one way to do it. I need to double check whether or not that's necessary for readthedocs though. It might be.

@embray
Copy link
Member

embray commented Sep 10, 2015

To clarify, all the makefile itself really does is run the sphinx-build command with the correct options. Whereas the advantage to ./setup.py build_docs is that it makes sure all dependencies can be imported, and that the package is built and fully importable.

@hamogu
Copy link
Member

hamogu commented Jun 15, 2016

I've in the past used the makefile when I needed to debug sphinx failures. Sphinx can (with the right options) drop you into the debugger when it encounters an error. Could I do that with python setup.py build_sphinx, too?

@saimn
Copy link
Contributor Author

saimn commented Jun 15, 2016

@hamogu - it seems setup.py build_docs does not have the pdb option, though it should easy to add. And the Makefile uses the sphinx-build command, so you could still use this command directly if needed.

@eteq
Copy link
Member

eteq commented Jul 5, 2016

Just realized the origin of this problem: build_docs is not the intended command. build_sphinx is the correct one. Currently build_docs is aliased to build_sphinx, but setup.cfg does not have a section for build_docs like it does for build_sphinx, and apparently the setup script doesn't pick up the setup.cfg section for build_sphinx if you use build_docs even though it's an alias.

So the install docs are just wrong, first of all. But also we should either add a build_docs section to setup.cfg or just remove/disable build_docs with some kind of redirection.

@astrofrog
Copy link
Member

astrofrog commented Jul 5, 2016

Ah, I think we switched to recommending build_docs in #3924?

@eteq
Copy link
Member

eteq commented Jul 5, 2016

Ohh, didn't know that. Guess I'm the dinosaur, then. But then it's been broken since then because it's definitely wrong in a lot of ways to be going into build/sphinx/..., so we should add a [build_docs] section to setup.cfg with the same content as the [build_sphinx] section.

@astrofrog
Copy link
Member

Ahem:

screen shot 2016-07-05 at 21 57 40

😉

@astrofrog
Copy link
Member

But yes indeed, we need to update setup.cfg - thanks for spotting the issue!

@eteq
Copy link
Member

eteq commented Jul 5, 2016

... maybe that's that other @eteq that keeps merging things when I'm not looking? ;)

@astrofrog
Copy link
Member

Ah, you have a sentient bot too?

@eteq
Copy link
Member

eteq commented Jul 5, 2016

image

@adrn adrn mentioned this pull request Jul 5, 2016
@saimn
Copy link
Contributor Author

saimn commented Jul 6, 2016

Oh, good catch @eteq !

@saimn
Copy link
Contributor Author

saimn commented Jul 6, 2016

Also, from the discussion above, we should remove the Makefile and have only one way to build the docs.

@eteq eteq closed this in #5156 Jul 6, 2016
@eteq
Copy link
Member

eteq commented Jul 6, 2016

@saimn - personally I'm +0 to removing the makefile - I don't really care about it, but I think some others expect it. But I see your point that it is clearly causing some confusion. Maybe make a separate issue/PR to do that and we can decide there?

(this issue was auto-closed by #5156, which fixed the underlying problem of the setup.cfg not including build_docs)

saimn added a commit to saimn/astropy that referenced this pull request Jul 7, 2016
`make html` does not work on Python 3, and there should be only one way to
build the docs (`setup.py build_docs`) and avoid to confuse users:

    Exception occurred:
    File "conf.py", line 43, in <module>
	from astropy_helpers.sphinx.conf import *
    ImportError: No module named 'astropy_helpers.sphinx'

Ref astropy#4133, astropy#2532
@saimn saimn mentioned this pull request Jul 7, 2016
@saimn
Copy link
Contributor Author

saimn commented Jul 7, 2016

@eteq - See #5161. Using make html is usually the way to build a sphinx documentation, so it's better to remove it to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Docs zzz 💤 astropy-helpers archived: PRs and issues related to astropy-helpers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants