- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Don't ignore first argument passed to sphinx.apidoc.main #3668
Don't ignore first argument passed to sphinx.apidoc.main #3668
Conversation
@shimizukawa could you review this? I don't know what is the standards in python. BTW, sphinx-build, sphinx-quickstart and sphinx-autogen are also uses
|
Let me know if this seems like the right thing to do. If so, I can modify the others as well. |
either is fine to me. I don't have strong opinion. |
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.
Ether OK to me.
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.
Thank you for comment.
As I said, I'm okay to merge this after all other scripts are updated.
Sounds good, I'll try to take a stab at this sometime this week. |
I think I got everything now? Hopefully you have good unit tests. |
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 seems test_extensions
in test_quickstart.py failed.
https://travis-ci.org/sphinx-doc/sphinx/jobs/230493513#L1859
Could you check this please?
@@ -256,4 +256,4 @@ def main(argv): | |||
|
|||
|
|||
if __name__ == '__main__': | |||
sys.exit(main(sys.argv)) | |||
sys.exit(main(sys.argv[1:])) |
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 also need to update the main()
in this file.
This causes following error:
https://travis-ci.org/sphinx-doc/sphinx/jobs/230493517#L746
sphinx/cmdline.py
Outdated
@@ -114,7 +114,7 @@ def handle_exception(app, opts, exception, stderr=sys.stderr): | |||
file=stderr) | |||
|
|||
|
|||
def main(argv): | |||
def main(argv=sys.argv[1:]): |
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.
mypy warns here: https://travis-ci.org/sphinx-doc/sphinx/jobs/231257064#L753
Please mark this line as # typing: ignore
.
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.
Thanks, I've never used mypy before. Alternatively, I could remove the default argument and go back to the way things were before. I was just trying to make everything the same.
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.
Oh, sorry. I was wrong. # type: ignore
is correct, not typing.
Merged. Thank you for contribution! |
Sphinx 1.7.0 changed the behaviour of the internal sphinx "main" functions: sphinx-doc/sphinx#3668 In order to support both, we now need to manually strip argv[0] before calling sphinx.main(), and also provide a dummy first argument for pre-1.7 sphinx to skip automatically. We do this by effectively duplicating our first "real" argument (-b html) as -bhtml.
Sphinx 1.7.0 changed the behaviour of the internal sphinx "main" functions: sphinx-doc/sphinx#3668 In order to support both, we now need to manually strip argv[0] before calling sphinx.main(), and also provide a dummy first argument for pre-1.7 sphinx to skip automatically. We do this by effectively duplicating our first "real" argument (-b html) as -bhtml. (cherry picked from commit 13e3ccb)
Feature or Bugfix
Bugfix? Depends on whether you consider it a bug or a feature 😉
Purpose
We use Sphinx to generate our documentation. Our API changes fairly often, so in order to make sure our API docs stay up-to-date, we always re-run
sphinx-apidoc
with each build. Unfortunately, Read the Docs skips our Makefile and directly calls:To get around this, we run
sphinx-apidoc
from ourconf.py
. Our call looks something like:At first I was really confused why this gave different results than:
but after reading the source code, I quickly discovered that
main
ignores the first argument it is passed. This makes perfect sense when runningsphinx-apidoc
from the command line, as the first argument will be the name of the script. But it is much less intuitive when being called directly frommain
. This PR fixes that.Detail
By default,
main
will still processsys.argv[1:]
, but if passed a list of arguments, it will now process all of them. I'm not sure if this bug (feature?) is documented already. My only concern is that this change isn't really backwards compatible. If you wanted it to be, I could theoretically check if the first argument issphinx-apidoc
and skip it if so.Relates
First reported here:
https://github.com/LLNL/spack/pull/3982/files#r113266150