-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[RFC] Simplified 'sphinx-build' #6939
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
This was previously proposed at #4320, but there were some discussion around it and not everyone agreed. Having continued to use Sphinx extensively, I'd like to repropose this in the hopes that I can convince people that it's a good idea. With this change, the typical Sphinx invocation goes from something like this:
to
Which is a heck of a lot easier to remember, if you ask me. I realize there's a bit of magic here, but I think it's a good thing for users. The only other option I can see is to modify #6938 so that the new |
c0a137d
to
4f7a15a
Compare
This is part one of two of the "make 'sphinx-build' easier to call" effort. In this part, we allow users to define the build directory in the 'conf.py' file. This means a user no longer needs to pass the option via the command line, though they can continue to do so if they wish. We use the behavior of the setuptools extension, whereby the results are output to a subfolder in the outdir named after the code of the builder. For example, if using the 'html' builder with 'output_dir = "test"', files would be written to 'test/html'. Signed-off-by: Stephen Finucane <[email protected]>
This is part two of two of the "make 'sphinx-build' easier to call" effort. In this part, we attempt to guess where the source directory is if the user does not provide one. This is possible because many users use one of three directory names - doc, docs, or Documentation - for their documentation. We check these, along with all immediate subdirectories for these directories. If a 'conf.py' file is found in any of these directories, we assume this is the documentation source. This means a user no longer needs to pass any argument to 'sphinx-build' is they do not wish to. This is, of course, best-effort, and users can continue to provide these options manually if they so wish. Signed-off-by: Stephen Finucane <[email protected]>
4f7a15a
to
e01fe3e
Compare
e01fe3e
to
11eaa50
Compare
+1 for "Make sphinx-build easier to call". In other words, +1 for making command-line arguments optional. But I've not still understand the advantage of moving output directory to conf.py. I think the output directory is not portable for each developers... Next, about guessing srcdir, -1 to this. Only I can accept is using current directory as srcdir. It's not magical to me. |
To be clear, I'm not suggesting we remove the ability to set the output directory using a configuration option. Instead, I'm suggesting we simply provide an additional way to configure this. Personally, I don't think the output directory is any different from other configuration, such as project name or HTML theme. If you are building documentation, it is likely that you would always want to output that to the same place. It would be silly to have to configure project name from from the command line every time you called
This might be true, but isn't this the case already if you build documentation using a tox target (
I don't think that offers enough flexibility, given
I still like this idea, but it seems I'm the only one that does 😄 My ultimate goal is to be able to call So, here's my proposal.
Given the above, does this make sense? |
I agree that the command line interface should not be more complicated than necessary, I am not sure if this is a good simplification.
If there should be simplification of the source/output paths I suggest the following:
The source dir is somewhat in control of the package author so they know not to use |
As above, this is the way I'm leaning now too since I think I'm alone in not being bothered by the auto-guessing behavior.
What guessing do you refer to? The choice of output directory is clearly defined: either the [*] Well, as noted above, most projects I interact with set these by default and hide them inside a
Again, this isn't doesn't seem to be a problem because if it affected the user, it would also affect the package maintainer who set this default. If the user would really nervous, just keep passing an output directory as before. I am not removing the ability to do this.
Why? Any user is free to override this but the project maintainer(s) get to provide a default that works best for them.
Again, why? I'm targeting the 90% use case here. In almost every project I work on, a
Seems fair.
As noted previously, that breaks users that use the "separate source and build directories" option that
All in all, this is entirely optional behavior that is wanted by some people and can be safely ignored by others, so I'm not sure why we wouldn't want to do this, heh. |
@stephenfin Thank you for your clear explanation. I'm perfectly understanding your idea. I'm happy to agree with you about srcdir not guessing. But I'm still worrying about output_dir in conf.py. I must admit that it is almost same to place it on conf.py or build script (ex. Makefile, build.sh, etc.). But I've felt bad smells from its design. Sorry for I can't describe it to you well. Please give time to consider why I feel so bad to your idea. BTW, we have to clear a term in this topic to discuss more deeply. It's "output_dir". At present, we have two types of output_dir. First is a directory used to generate output files just inside it. I guess |
Correct. This is similar to the behavior of make mode, as you note, and seems sane when you consider the default support for multiple builders. Again, if someone wants to output to a specific location, they can choose to pass the config option. |
This merge request is open for 4 years now. What is blocking this? |
That it wasn't accepted as proposed. I intend to add support for configuring source and output directories at some later date, but I agree with the concerns about 'guessing' (this could e.g. be done in quickstart). However, thank you for the prompt, it makes sense to close this PR which is now out-of-date. A |
Feature or Bugfix
Purpose
Make sphinx-build easier to call by moving configuration of the build directory to the configuration file and auto-detecting the source directory. This will allow most users to call sphinx-build without any arguments.
Detail
sphinx-build
: Configureoutdir
fromconf.py
This is part one of two of the "make 'sphinx-build' easier to call" effort. In this part, we allow users to define the build directory in the 'conf.py' file. This means a user no longer needs to pass the option via the command line, though they can continue to do so if they wish.
We use the behavior of the setuptools extension, whereby the results are output to a subfolder in the outdir named after the code of the builder. For example, if using the 'html' builder with 'output_dir = "test"', files would be written to 'test/html'.
sphinx-build
: Guesssourcedir
if none providedThis is part two of two of the "make 'sphinx-build' easier to call" effort. In this part, we attempt to guess where the source directory is if the user does not provide one. This is possible because many users use one of three directory names - doc, docs, or Documentation - for their documentation. We check these, along with a possible 'source' subdirectory, which is based on Sphinx's own defaults, for a 'conf.py' file. Is one is found, we assume this is the documentation source. This means a user no longer needs to pass any argument to 'sphinx-build' is they do not wish to.
This is, of course, best-effort, and users can continue to provide these options manually if they so wish.
You can validate this right now by pulling down the pull request and running
sphinx-build
without any arguments. The required change has been made toconf.py
.