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

make deploy directory required argument #157

Merged
merged 10 commits into from
Mar 9, 2017
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -31,10 +31,10 @@ script:
cd docs;
make html;
cd ..;
python -m doctr deploy --gh-pages-docs . --key-path deploy_key.enc;
python -m doctr deploy --gh-pages-docs docs --key-path deploy_key.enc;
python -m doctr deploy --no-require-master --gh-pages-docs "docs-$TRAVIS_BRANCH" --built-docs docs/_build/html --key-path deploy_key.enc;
python -m doctr deploy --no-require-master --key-path deploy_key.enc --no-sync --command "echo test";
python -m doctr deploy --key-path deploy_key.enc .;
python -m doctr deploy --key-path deploy_key.enc --gh-pages-docs docs;
python -m doctr deploy --no-require-master --built-docs docs/_build/html --key-path deploy_key.enc "docs-$TRAVIS_BRANCH";
python -m doctr deploy --no-require-master --key-path deploy_key.enc --no-sync --command "echo test" docs;
fi
- if [[ "${TESTS}" == "true" ]]; then
pyflakes doctr;
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@
Doctr Changelog
=================

Current
=======
- The ``--gh-pages-docs`` flag of ``doctr deploy`` has been deprecated.
Specify the deploy directory like ``doctr deploy .`` or ``doctr deploy docs``.
There is also no longer a default deploy directory. (:issue:`128`)


1.4.1 (2017-01-11)
==================
- Fix Travis API endpoint when checking if a repo exists. (:issue:`143`)
27 changes: 21 additions & 6 deletions doctr/__main__.py
Original file line number Diff line number Diff line change
@@ -50,6 +50,8 @@ def get_parser():
subcommand = parser.add_subparsers(title='subcommand', dest='subcommand')
deploy_parser = subcommand.add_parser('deploy', help="""Deploy the docs to GitHub from Travis.""")
deploy_parser.set_defaults(func=deploy)
deploy_parser.add_argument('deploy_directory', type=str, nargs='?',
help="""Directory to deploy the html documentation to on gh-pages.""")
deploy_parser.add_argument('--force', action='store_true', help="""Run the deploy command even
if we do not appear to be on Travis.""")
deploy_parser.add_argument('--token', action='store_true', default=False,
@@ -60,9 +62,6 @@ def get_parser():
deploy_parser.add_argument('--built-docs', default=None,
help="""Location of the built html documentation to be deployed to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could keep and deprecate this option for backwards compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of that, but I'm not sure how to go about having a default argument not be required if a certain non-default option is passed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does argparse let you set a default for positional arguments? You'd have to do the flag logic manually (use parser.error to print the error).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nargs= '?'

gh-pages. If not specified, Doctr will try to automatically detect build location""")
deploy_parser.add_argument('--gh-pages-docs', default='docs',
help="""Directory to deploy the html documentation to on gh-pages. The
default is %(default)r.""")
deploy_parser.add_argument('--tmp-dir', default=None,
help=argparse.SUPPRESS)
deploy_parser.add_argument('--deploy-repo', default=None, help="""Repo to
@@ -81,6 +80,11 @@ def get_parser():
deploy_parser.add_argument('--no-push', dest='push', action='store_false',
default=True, help="Run all the steps except the last push step."
"Useful for debugging")
deploy_parser.add_argument('--gh-pages-docs', default=None,
help="""!!DEPRECATED!! Directory to deploy the html documentation to on gh-pages.
The default is %(default)r. The deploy directory should be passed as
the first argument to 'doctr deploy'. This flag is kept for backwards
compatibility.""")


configure_parser = subcommand.add_parser('configure', help="Configure doctr. This command should be run locally (not on Travis).")
@@ -125,6 +129,17 @@ def deploy(args, parser):
if args.tmp_dir:
parser.error("The --tmp-dir flag has been removed (doctr no longer uses a temporary directory when deploying).")

if args.gh_pages_docs:
print("The --gh-pages-docs flag is deprecated and will be removed in the next release. Instead pass the deploy directory as an argument, e.g. `doctr deploy .`")

if args.gh_pages_docs and args.deploy_directory:
parser.error("The --gh-pages-docs flag is deprecated. Specify the directory to deploy to using `doctr deploy <dir>`")

if not args.gh_pages_docs and not args.deploy_directory:
parser.error("No deploy directory specified. Specify the directory to deploy to using `doctr deploy <dir>`")

deploy_dir = args.gh_pages_docs or args.deploy_directory

build_repo = get_current_repo()
deploy_repo = args.deploy_repo or build_repo

@@ -137,11 +152,11 @@ def deploy(args, parser):
if args.sync:
built_docs = args.built_docs or find_sphinx_build_dir()

log_file = os.path.join(args.gh_pages_docs, '.doctr-files')
log_file = os.path.join(deploy_dir, '.doctr-files')

print("Moving built docs into place")
added, removed = sync_from_log(src=built_docs,
dst=args.gh_pages_docs, log_file=log_file)
dst=deploy_dir, log_file=log_file)

else:
added, removed = [], []
@@ -251,7 +266,7 @@ def configure(args, parser):
- set -e
- # Command to build your docs
- pip install doctr
- doctr deploy{options}
- doctr deploy{options} {deploy_directory}

to the docs build of your .travis.yml. The 'set -e' prevents doctr from
running when the docs build fails. Use the 'script' section so that if