summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml47
-rw-r--r--numpy/ma/core.py21
-rwxr-xr-xtools/ci/push_docs_to_repo.py65
3 files changed, 120 insertions, 13 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index e055739e5..70cb8adc0 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -54,8 +54,51 @@ jobs:
# path: doc/neps/_build/html/
# destination: neps
- - deploy:
+ - add_ssh_keys:
+ fingerprints:
+ - "9f:8c:e5:3f:53:40:0b:ee:c9:c3:0f:fd:0f:3c:cc:55"
+
+ - run:
+ name: deploy devdocs
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
- echo "Deploying on master"
+ touch doc/build/html/.nojekyll
+
+ ./tools/ci/push_docs_to_repo.py doc/build/html \
+ git@github.com:numpy/devdocs.git \
+ --committer "numpy-circleci-bot" \
+ --email "numpy-circleci-bot@nomail" \
+ --message "Docs build of $CIRCLE_SHA1" \
+ --force
+ else
+ echo "Not on the master branch; skipping deployment"
+ fi
+
+ - add_ssh_keys:
+ fingerprints:
+ - "11:fb:19:69:80:3a:6d:37:9c:d1:ac:20:17:cd:c8:17"
+
+ - run:
+ name: select SSH key for neps repo
+ command: |
+ cat <<\EOF > ~/.ssh/config
+ Host github.com
+ IdentitiesOnly yes
+ IdentityFile /home/circleci/.ssh/id_rsa_11fb1969803a6d379cd1ac2017cdc817
+ EOF
+
+ - run:
+ name: deploy neps
+ command: |
+ if [ "${CIRCLE_BRANCH}" == "master" ]; then
+ touch doc/neps/_build/html/.nojekyll
+
+ ./tools/push_to_repo.py doc/neps/_build/html \
+ git@github.com:numpy/neps.git \
+ --committer "numpy-circleci-bot" \
+ --email "numpy-circleci-bot@nomail" \
+ --message "Docs build of $CIRCLE_SHA1" \
+ --force
+ else
+ echo "Not on the master branch; skipping deployment"
fi
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 6deff0ef4..5f53dfdae 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -26,6 +26,7 @@ import sys
import operator
import warnings
import textwrap
+import re
from functools import reduce
if sys.version_info[0] >= 3:
@@ -132,19 +133,17 @@ def doc_note(initialdoc, note):
if note is None:
return initialdoc
- # FIXME: disable this function for the moment until we figure out what to
- # do with it. Currently it may result in duplicate Notes sections or Notes
- # sections in the wrong place
- return initialdoc
+ notesplit = re.split(r'\n\s*?Notes\n\s*?-----', initialdoc)
- newdoc = """
- %s
-
- Notes
+ notedoc = """\
+Notes
-----
- %s
- """
- return newdoc % (initialdoc, note)
+ %s""" % note
+
+ if len(notesplit) > 1:
+ notedoc = '\n\n ' + notedoc + '\n'
+
+ return ''.join(notesplit[:1] + [notedoc] + notesplit[1:])
def get_object_signature(obj):
diff --git a/tools/ci/push_docs_to_repo.py b/tools/ci/push_docs_to_repo.py
new file mode 100755
index 000000000..a98966880
--- /dev/null
+++ b/tools/ci/push_docs_to_repo.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+import argparse
+import subprocess
+import tempfile
+import os
+import sys
+import shutil
+
+
+parser = argparse.ArgumentParser(
+ description='Upload files to a remote repo, replacing existing content'
+)
+parser.add_argument('dir', help='directory of which content will be uploaded')
+parser.add_argument('remote', help='remote to which content will be pushed')
+parser.add_argument('--message', default='Commit bot upload',
+ help='commit message to use')
+parser.add_argument('--committer', default='numpy-commit-bot',
+ help='Name of the git committer')
+parser.add_argument('--email', default='numpy-commit-bot@nomail',
+ help='Email of the git committer')
+
+parser.add_argument(
+ '--force', action='store_true',
+ help='hereby acknowledge that remote repo content will be overwritten'
+)
+args = parser.parse_args()
+args.dir = os.path.abspath(args.dir)
+
+if not os.path.exists(args.dir):
+ print('Content directory does not exist')
+ sys.exit(1)
+
+
+def run(cmd, stdout=True):
+ pipe = None if stdout else subprocess.DEVNULL
+ try:
+ subprocess.check_call(cmd, stdout=pipe, stderr=pipe)
+ except subprocess.CalledProcessError:
+ print("\n! Error executing: `%s;` aborting" % ' '.join(cmd))
+ sys.exit(1)
+
+
+workdir = tempfile.mkdtemp()
+os.chdir(workdir)
+
+run(['git', 'init'])
+run(['git', 'remote', 'add', 'origin', args.remote])
+run(['git', 'config', '--local', 'user.name', args.committer])
+run(['git', 'config', '--local', 'user.email', args.email])
+
+print('- committing new content: "%s"' % args.message)
+run(['cp', '-R', os.path.join(args.dir, '.'), '.'])
+run(['git', 'add', '.'], stdout=False)
+run(['git', 'commit', '--allow-empty', '-m', args.message], stdout=False)
+
+print('- uploading as %s <%s>' % (args.committer, args.email))
+if args.force:
+ run(['git', 'push', 'origin', 'master', '--force'])
+else:
+ print('\n!! No `--force` argument specified; aborting')
+ print('!! Before enabling that flag, make sure you know what it does\n')
+ sys.exit(1)
+
+shutil.rmtree(workdir)