find . -name __pycache__ -type d -exec rm -r {} +
find . -name *.pyc -delete
rm -rf .tox
+ rm -rf docs/_build/
.tox:
tox -r --notest
docs: .tox
$(PIP) install -r docs/requirements.txt
- rm -rf docs/api/* docs/_build/
- $(BIN)/sphinx-apidoc -o docs/api/ juju/
+ rm -rf docs/_build/
$(BIN)/sphinx-build -b html docs/ docs/_build/
cd docs/_build/ && zip -r docs.zip *
--- /dev/null
+# Copyright 2014-2015 Canonical Limited.
+#
+# This file is part of charm-helpers.
+#
+# charm-helpers is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# charm-helpers is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
+
+
+import importlib
+import inspect
+import textwrap
+
+from docutils import nodes
+from docutils.statemachine import ViewList
+from sphinx.errors import SphinxError
+from sphinx.util.compat import Directive
+from sphinx.util.nodes import nested_parse_with_titles
+
+
+class AutoMemberSummary(Directive):
+ required_arguments = 1
+
+ def run(self):
+ module_name = self.arguments[0]
+
+ try:
+ module = importlib.import_module(module_name)
+ except ImportError:
+ raise SphinxError("Unable to generate reference docs for %s, "
+ "could not import" % (module_name))
+
+ divider = '+{:-<80}+'.format('')
+ row = '| {:<78} |'.format
+ lines = []
+ for member_name, member in inspect.getmembers(module):
+ if not self._filter(module_name, member_name, member):
+ continue
+ summary = textwrap.wrap(self._get_summary(member), 78) or ['']
+ link = '`{} <#{}>`_'.format(member_name,
+ '.'.join([module_name,
+ member_name]))
+ methods = ['* `{} <#{}>`_'.format(n,
+ '.'.join([module_name,
+ member_name,
+ n]))
+ for n, m in inspect.getmembers(member)
+ if not n.startswith('_') and inspect.isfunction(m)]
+
+ lines.append(divider)
+ lines.append(row(link))
+ lines.append(divider)
+ for line in summary:
+ lines.append(row(line))
+ if methods:
+ lines.append(row(''))
+ lines.append(row('Methods:'))
+ lines.append(row(''))
+ for i, method in enumerate(methods):
+ lines.append(row(method))
+ lines.append(divider)
+ content = '\n'.join(lines)
+
+ result = self._parse(content, '<automembersummary>')
+ return result
+
+ def _get_summary(self, member):
+ doc = (member.__doc__ or '').splitlines()
+
+ # strip any leading blank lines
+ while doc and not doc[0].strip():
+ doc.pop(0)
+
+ # strip anything after the first blank line
+ for i, piece in enumerate(doc):
+ if not piece.strip():
+ doc = doc[:i]
+ break
+
+ return " ".join(doc).strip()
+
+ def _filter(self, module_name, member_name, member):
+ if member_name.startswith('_'):
+ return False
+ if hasattr(member, '__module__'):
+ # skip imported classes & functions
+ return member.__module__.startswith(module_name)
+ elif hasattr(member, '__name__'):
+ # skip imported modules
+ return member.__name__.startswith(module_name)
+ else:
+ return False # skip instances
+ return True
+
+ def _parse(self, rst_text, annotation):
+ result = ViewList()
+ for line in rst_text.split("\n"):
+ result.append(line, annotation)
+ node = nodes.paragraph()
+ node.document = self.state.document
+ nested_parse_with_titles(self.state, result, node)
+ return node.children
+
+
+def setup(app):
+ app.add_directive('automembersummary', AutoMemberSummary)
--- /dev/null
+.wy-table-responsive table td,
+.wy-table-responsive table th
+{
+ white-space: normal !important;
+}
--- /dev/null
+juju.action
+===========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.action
+
+.. rubric:: Reference
+
+.. automodule:: juju.action
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.annotation
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.annotation
+
+.. rubric:: Reference
+
+.. automodule:: juju.annotation
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.application
+================
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.application
+
+.. rubric:: Reference
+
+.. automodule:: juju.application
+ :members:
+ :undoc-members:
+ :show-inheritance:
juju\.client package
====================
-Submodules
-----------
+These packages are for internal use in communicating with the low-level
+API. You should use the object oriented API instead. They are documented
+here for developer reference.
+
juju\.client\.client module
---------------------------
:undoc-members:
:show-inheritance:
+juju\.client\._definitions module
+---------------------------------
+
+.. automodule:: juju.client._definitions
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client module
+----------------------------
+
+.. automodule:: juju.client._client
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client1 module
+-----------------------------
+
+.. automodule:: juju.client._client1
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client2 module
+-----------------------------
+
+.. automodule:: juju.client._client2
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client3 module
+-----------------------------
+
+.. automodule:: juju.client._client3
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client4 module
+-----------------------------
+
+.. automodule:: juju.client._client4
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+juju\.client\._client5 module
+-----------------------------
+
+.. automodule:: juju.client._client5
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
juju\.client\.codegen module
----------------------------
--- /dev/null
+juju.cloud
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.cloud
+
+.. rubric:: Reference
+
+.. automodule:: juju.cloud
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.constraints
+================
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.constraints
+
+.. rubric:: Reference
+
+.. automodule:: juju.constraints
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.controller
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.controller
+
+.. rubric:: Reference
+
+.. automodule:: juju.controller
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.delta
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.delta
+
+.. rubric:: Reference
+
+.. automodule:: juju.delta
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.errors
+===========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.errors
+
+.. rubric:: Reference
+
+.. automodule:: juju.errors
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.exceptions
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.exceptions
+
+.. rubric:: Reference
+
+.. automodule:: juju.exceptions
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.juju
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.juju
+
+.. rubric:: Reference
+
+.. automodule:: juju.juju
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.loop
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.loop
+
+.. rubric:: Reference
+
+.. automodule:: juju.loop
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.machine
+============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.machine
+
+.. rubric:: Reference
+
+.. automodule:: juju.machine
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.model
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.model
+
+.. rubric:: Reference
+
+.. automodule:: juju.model
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.placement
+==============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.placement
+
+.. rubric:: Reference
+
+.. automodule:: juju.placement
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.relation
+=============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.relation
+
+.. rubric:: Reference
+
+.. automodule:: juju.relation
+ :members:
+ :undoc-members:
+ :show-inheritance:
+++ /dev/null
-juju package
-============
-
-Subpackages
------------
-
-.. toctree::
-
- juju.client
-
-Submodules
-----------
-
-juju\.action module
--------------------
-
-.. automodule:: juju.action
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.annotation module
------------------------
-
-.. automodule:: juju.annotation
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.application module
-------------------------
-
-.. automodule:: juju.application
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.cloud module
-------------------
-
-.. automodule:: juju.cloud
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.constraints module
-------------------------
-
-.. automodule:: juju.constraints
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.controller module
------------------------
-
-.. automodule:: juju.controller
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.delta module
-------------------
-
-.. automodule:: juju.delta
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.errors module
--------------------
-
-.. automodule:: juju.errors
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.exceptions module
------------------------
-
-.. automodule:: juju.exceptions
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.juju module
------------------
-
-.. automodule:: juju.juju
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.loop module
------------------
-
-.. automodule:: juju.loop
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.machine module
---------------------
-
-.. automodule:: juju.machine
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.model module
-------------------
-
-.. automodule:: juju.model
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.placement module
-----------------------
-
-.. automodule:: juju.placement
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.relation module
----------------------
-
-.. automodule:: juju.relation
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.tag module
-----------------
-
-.. automodule:: juju.tag
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.unit module
------------------
-
-.. automodule:: juju.unit
- :members:
- :undoc-members:
- :show-inheritance:
-
-juju\.utils module
-------------------
-
-.. automodule:: juju.utils
- :members:
- :undoc-members:
- :show-inheritance:
-
-
-Module contents
----------------
-
-.. automodule:: juju
- :members:
- :undoc-members:
- :show-inheritance:
--- /dev/null
+juju.tag
+========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.tag
+
+.. rubric:: Reference
+
+.. automodule:: juju.tag
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.unit
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.unit
+
+.. rubric:: Reference
+
+.. automodule:: juju.unit
+ :members:
+ :undoc-members:
+ :show-inheritance:
--- /dev/null
+juju.utils
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.utils
+
+.. rubric:: Reference
+
+.. automodule:: juju.utils
+ :members:
+ :undoc-members:
+ :show-inheritance:
juju
====
+It is recommended that you start with :doc:`juju.model` or :doc:`juju.controller`.
+If you need helpers to manage the asyncio loop, try :doc:`juju.loop`.
+
.. toctree::
- :maxdepth: 4
- juju
+ juju.action
+ juju.annotation
+ juju.application
+ juju.cloud
+ juju.constraints
+ juju.controller
+ juju.delta
+ juju.errors
+ juju.exceptions
+ juju.juju
+ juju.loop
+ juju.machine
+ juju.model
+ juju.placement
+ juju.relation
+ juju.tag
+ juju.unit
+ juju.utils
+
+.. automodule:: juju
+ :members:
+ :undoc-members:
+ :show-inheritance:
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
+sys.path.append(os.path.abspath('_extensions/'))
extensions = [
'sphinx.ext.autodoc',
+ 'sphinx.ext.autosummary',
+ 'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinxcontrib.asyncio',
+ 'automembersummary',
]
# Add any paths that contain templates here, relative to this directory.
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
-html_theme = 'alabaster'
+html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
+
+def setup(app):
+ app.add_stylesheet('custom.css')
narrative/index
API Docs <api/modules>
+ Internal API Docs <api/juju.client>
upstream-updates/index
sphinx
sphinxcontrib-asyncio
+sphinx_rtd_theme
class ModelObserver(object):
+ """
+ Base class for creating observers that react to changes in a model.
+ """
async def __call__(self, delta, old, new, model):
handler_name = 'on_{}_{}'.format(delta.entity, delta.type)
method = getattr(self, handler_name, self.on_change)
async def on_change(self, delta, old, new, model):
"""Generic model-change handler.
+ This should be overridden in a subclass.
+
:param delta: :class:`juju.client.overrides.Delta`
:param old: :class:`juju.model.ModelEntity`
:param new: :class:`juju.model.ModelEntity`
class Model(object):
+ """
+ The main API for interacting with a Juju model.
+ """
def __init__(self, loop=None):
"""Instantiate a new connected Model.
class CharmArchiveGenerator(object):
+ """
+ Create a Zip archive of a local charm directory for upload to a controller.
+
+ This is used automatically by
+ `Model.add_local_charm_dir <#juju.model.Model.add_local_charm_dir>`_.
+ """
def __init__(self, path):
self.path = os.path.abspath(os.path.expanduser(path))
+++ /dev/null
---index-url https://pypi.python.org/simple/
-dateutil
--e .
--- /dev/null
+#!/bin/bash
+packages=(
+ juju.action
+ juju.annotation
+ juju.application
+ juju.cloud
+ juju.constraints
+ juju.controller
+ juju.delta
+ juju.errors
+ juju.exceptions
+ juju.juju
+ juju.loop
+ juju.machine
+ juju.model
+ juju.placement
+ juju.relation
+ juju.tag
+ juju.unit
+ juju.utils
+)
+
+for pkg in ${packages[@]}; do
+ cat <<EOD > docs/api/$pkg.rst
+$pkg
+$(echo $pkg | sed -e 's/./=/g')
+
+.. rubric:: Summary
+
+.. automembersummary:: $pkg
+
+.. rubric:: Reference
+
+.. automodule:: $pkg
+ :members:
+ :undoc-members:
+ :show-inheritance:
+EOD
+done