From e99650e725bf27ff70254c1e99a08bc14ee2bf33 Mon Sep 17 00:00:00 2001 From: Max Linke Date: Wed, 9 Sep 2015 21:23:55 +0200 Subject: [PATCH 1/2] Use current branch to build docs Please never change this again. It makes sure that 'make html' just works and does what you think it will do. --- package/doc/sphinx/source/conf.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/package/doc/sphinx/source/conf.py b/package/doc/sphinx/source/conf.py index 7e7c72bb058..69619636d6c 100644 --- a/package/doc/sphinx/source/conf.py +++ b/package/doc/sphinx/source/conf.py @@ -46,16 +46,8 @@ def __getattr__(cls, name): # documentation root, use os.path.abspath to make it absolute, like shown # here. -# Little trick to make sure sphinx use the dev build if present -build_path = "../../../build/lib.%s-%s-%s" % (platform.system().lower(), - platform.machine(), - ".".join(platform.python_version_tuple()[:2])) -build_path = os.path.abspath(build_path) -if os.path.exists(build_path): - sys.path.insert(0, build_path) - -#sys.path.insert(0, os.path.abspath('.')) -#sys.path.insert(0, '../../../MDAnalysis/analysis/') +# make sure sphinx always uses the current branch +sys.path.insert(0, os.path.abspath('../../..')) # -- General configuration ----------------------------------------------------- From 526139054f3b0d9d1cae7066a4f6c8ee6a3b89d6 Mon Sep 17 00:00:00 2001 From: Max Linke Date: Wed, 9 Sep 2015 21:24:34 +0200 Subject: [PATCH 2/2] Activate sphinx.ext.napoleon for numpy-style docs This also changes one of the docs strings to demonstrate that normal ReST files and the numpy-style can live side by side. [skip ci] --- package/MDAnalysis/lib/mdamath.py | 21 +++++++++++++++------ package/doc/sphinx/source/conf.py | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/package/MDAnalysis/lib/mdamath.py b/package/MDAnalysis/lib/mdamath.py index a30c10269cc..c66c28b9488 100644 --- a/package/MDAnalysis/lib/mdamath.py +++ b/package/MDAnalysis/lib/mdamath.py @@ -36,18 +36,27 @@ from ..exceptions import NoDataError + # geometric functions def norm(v): - r"""Returns the length of a vector, ``sqrt(v.v)``. + r"""Calculate the norm of a vector v. - .. math:: + .. math:: v = \sqrt{\mathbf{v}\cdot\mathbf{v}} - v = \sqrt{\mathbf{v}\cdot\mathbf{v}} + This version is faster then numpy.linalg.norm because it only works for a + single vector and therefore can skip a lot of the additional fuss + linalg.norm does. - Faster than :func:`numpy.linalg.norm` because no frills. + Parameters + ---------- + v: array_like + 1D array of shape (N) for a vector of length N + + Returns + ------- + float + norm of the vector - .. versionchanged:: 0.11.0 - Moved into lib.mdamath """ return np.sqrt(np.dot(v, v)) diff --git a/package/doc/sphinx/source/conf.py b/package/doc/sphinx/source/conf.py index 69619636d6c..a785345a106 100644 --- a/package/doc/sphinx/source/conf.py +++ b/package/doc/sphinx/source/conf.py @@ -57,7 +57,8 @@ def __getattr__(cls, name): # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', - 'sphinx.ext.mathjax', 'sphinx.ext.viewcode'] + 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', + 'sphinx.ext.napoleon',] mathjax_path = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' # Add any paths that contain templates here, relative to this directory.