Skip to content
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

Sphinx - specify source directory (sphinx-build arguments) #1543

Closed
sid-kap opened this issue Aug 5, 2015 · 7 comments
Closed

Sphinx - specify source directory (sphinx-build arguments) #1543

sid-kap opened this issue Aug 5, 2015 · 7 comments
Labels
Improvement Minor improvement to code
Milestone

Comments

@sid-kap
Copy link
Contributor

sid-kap commented Aug 5, 2015

Hi,

It looks like the default sphinx builder assumes that the source directory is the same as the configuration directory.
In https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/backends/sphinx.py#L128,
it looks like it CDs to the configuration directory and runs sphinx-build specifying "." as the source directory.

I want a directory structure as follows:

project/
  - docs/
    - conf.py
    - src/
    - _build/

where project/docs is my configuration directory and project/docs/src is my source directory.

It looks like the only way to do this is to write my own builder.
Is there an easier way to do this? If not, would you consider adding an easier way to do this?

@sid-kap sid-kap changed the title Sphinx - specify source directory Sphinx - specify source directory (sphinx-build arguments) Aug 5, 2015
@gregmuellegger gregmuellegger added this to the rtd-build milestone Aug 6, 2015
@gregmuellegger
Copy link
Contributor

Hi, I think we won't add this very soon as there are alreadya lot configuration options in the project's admin panel. However we are working on a configuration that can be put in your directory (i.e. a readthedocs.yml config in your repo). We have enough room there for as many config options as we want and will consider it there. Stay tuned :)

@gregmuellegger gregmuellegger added the Improvement Minor improvement to code label Aug 6, 2015
@rweickelt
Copy link

The yml config file has been around for a while. Is this now doable?

@humitos
Copy link
Member

humitos commented Dec 29, 2017

Hi @rweickelt! The documentation for the yaml file is at http://docs.readthedocs.io/en/latest/yaml-config.html and it seems that this is not supported yet :(

@agjohnson
Copy link
Contributor

You can always create a placeholder project/docs/src/conf.py that does something like import * from ..conf -- or prepend the parent path to sys.path. Either way, solving this is probably unlikely in RTD, and is more of a Sphinx issue anyways. Closing this for now

@pradyunsg
Copy link

I request reconsidering the addition of this in the YAML file. I'm currently working on reorganizing pip's documentation, to simplify the build process. This reorganization is intended to split up pip's man pages and html pages.

I want to be able to specify the source directory (either docs/html or docs/man) while pointing to the same conf.py (docs/conf.py) file.

Either way, solving this is probably unlikely in RTD, and is more of a Sphinx issue anyways

I disagree.

Sphinx allows specifying different directories for conf.py vs the source directory. It does default to conf.py being at <source>/conf.py. RTD doesn't expose the ability to customize this. I think the fix is to enable RTD to fix this.


On a slightly different note... Thanks for all the work on RTD. :)

@agjohnson
Copy link
Contributor

I think the workaround above still stands. You can have a single conf.py with the per-directory conf.py that doesn't need to be edited. We are trying to keep bloat out of our yaml config, this particular case isn't common enough for us to warrant the work to add this feature.

Is there a reason using conf.py as a package doesn't work for your case? For example, some untested pseudo sphinx config:

docs/conf.py:

project = "..."
version = ".."
# Rest of your common sphinx config

docs/html/conf.py:

import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

from conf import *

# Override what you need
project = "..."

@pradyunsg
Copy link

Of course, it works. I'm actually going to not do a duplicated import and moved the file to the HTML directory, letting RTD build the HTML docs since the man pages are anyways going to not be built on RTD.

I'll withdraw my proposal - the workaround is simple enough in nearly all cases and there is no need to ask for low-benefit work from others. :)

eli-schwartz added a commit to eli-schwartz/pip that referenced this issue Jul 18, 2019
This was broken in commit 20f672c,
which reorganized the conf.py file into the html subdirectory. See:
pypa#5724
readthedocs/readthedocs.org#1543

This broke the relative manpage globbing because Sphinx will os.chdir()
into the directory location of conf.py before evaluating it, so the
globbing returned nothing at all. As a result, while the main pip(1)
manpage continued to be built, no pip-*(1) subcommand manpages were
built.
nodiscc added a commit to nodiscc/Shaarli that referenced this issue Oct 4, 2023
nodiscc added a commit to nodiscc/Shaarli that referenced this issue Oct 5, 2023
- fixes shaarli#1451
- tools/.gitattributes: exclude doc/conf.py and doc/requirements.txt from zip exports
- tools/doc/sphinx: suppress myst.xref_missing warnings caused by executablebooks/MyST-Parser#564
- dockerfile: use makefile/sphinx instead of mkdocs to build HTML documentation
- dockerfile: add bash to the docs build container (make: bash: No such file or directory)
- tools/doc/readthedocs: force use of python 3.11 (readthedocs ERROR: No matching distribution found for sphinx==7.1.0)
- tools/doc/readthedocs: add all required configuration variables https://docs.readthedocs.io/en/latest/config-file/v2.html#build-os
- tools/doc/readthedocs: override build commands to allow the source directory to be different from the conf.py directory (https://docs.readthedocs.io/en/stable/config-file/v2.html#build-commands, readthedocs/readthedocs.org#1543)
- tools/doc/readthedocs: manually set output directory (readthedocs ERROR: No _readthedocs/html folder was created during this build.)
- doc: replace all references to mkdocs with sphinx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
None yet
Development

No branches or pull requests

6 participants