tox
docs: .tox
- $(PIP) list | grep Sphinx || $(PIP) install -U sphinx
+ $(PIP) install -r docs/requirements.txt
rm -rf docs/api/* docs/_build/
$(BIN)/sphinx-apidoc -o docs/api/ juju/
$(BIN)/sphinx-build -b html docs/ docs/_build/
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
+ 'sphinxcontrib.asyncio',
]
# Add any paths that contain templates here, relative to this directory.
async def on_change(self, delta, old, new, model):
# The catch-all handler - will be called whenever a more
# specific handler method is not defined.
+
+
+Any :class:`juju.model.ModelEntity` object can be observed directly by
+registering callbacks on the object itself.
+
+.. code:: python
+
+ import logging
+
+ async def on_app_change(delta, old, new, model):
+ logging.debug('App changed: %r', new)
+
+ async def on_app_remove(delta, old, new, model):
+ logging.debug('App removed: %r', old)
+
+ ubuntu_app = await model.deploy(
+ 'ubuntu',
+ application_name='ubuntu',
+ series='trusty',
+ channel='stable',
+ )
+ ubuntu_app.on_change(on_app_change)
+ ubuntu_app.on_remove(on_app_remove)