Skip to content

Commit 112bfc6

Browse files
authored
Merge pull request #899 from cderici/fix-sphinx-doc
#899 #### Description This is a follow up on #871 , attempting to have stable green RTD builds for generating the pylibjuju docs. - It adds a tox environment to run the `sphinx-build` locally rather then doing it in the main dev environment. - It adds a new `.readthedocs.yaml` configuration file (which will be required it looks like by Sep 2023) #### Notes & Discussion After the RTD side is stabilized, the actual docs will be revised to keep up-to-date docs for pylibjuju.
2 parents c7d0a10 + 4e1ca3c commit 112bfc6

9 files changed

Lines changed: 73 additions & 36 deletions

File tree

.readthedocs.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
python:
4+
install:
5+
- requirements: docs/requirements.txt
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.10"
11+
12+
sphinx:
13+
configuration: docs/conf.py

CONTRIBUTORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@ Benjamin Saller
22
Tim Van Steenburgh
33
Cory Johns
44
Pete VanderGiessen
5+
Pen Gale
6+
Juan Tirado Martin
7+
Caner Derici
8+
Simon Richardson
9+
Jack Shaw
10+
Leon Mintz
11+
Adam Dyess

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@ test: lint
2424
tox -e py3
2525
tox -e integration
2626

27-
2827
.PHONY: lint
2928
lint:
3029
tox -e lint
3130

3231
.PHONY: docs
33-
docs: .tox
34-
$(PIP) install -r docs/requirements.txt
35-
rm -rf docs/_build/
36-
$(BIN)/sphinx-build -b html docs/ docs/_build/
37-
cd docs/_build/ && zip -r docs.zip *
32+
docs:
33+
tox -e docs
3834

3935
.PHONY: release
4036
release:

docs/narrative/application.rst

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ To deploy a new application, connect a model and then call its
1717
await model.connect_current()
1818
1919
mysql_app = await model.deploy(
20-
# If a revision number is not included in the charm url,
21-
# the latest revision from the Charm Store will be used.
22-
'cs:mysql-55',
23-
application_name='mysql',
24-
series='trusty',
25-
channel='stable',
20+
'mysql',
21+
application_name='my-mysql',
22+
series='jammy',
23+
channel='8.0/stable',
2624
config={
2725
'tuning-level': 'safest',
2826
},
@@ -46,9 +44,9 @@ To deploy a local charm, pass the charm directory path to
4644
4745
# Deploy a local charm using a path to the charm directory
4846
await model.deploy(
49-
'/home/tvansteenburgh/src/charms/ubuntu',
47+
'./charms/ubuntu',
5048
application_name='ubuntu',
51-
series='trusty',
49+
series='jammy',
5250
)
5351
5452
@@ -63,7 +61,6 @@ added units (:class:`~juju.unit.Unit` objects) is returned.
6361
ubuntu_app = await model.deploy(
6462
'ubuntu',
6563
application_name='ubuntu',
66-
series='trusty',
6764
channel='stable',
6865
)
6966
@@ -107,18 +104,18 @@ The :meth:`juju.application.Application.relate` method returns a
107104
108105
# Deploy mysql-master application
109106
mysql_master = await model.deploy(
110-
'cs:mysql-55',
107+
'mysql',
111108
application_name='mysql-master',
112-
series='trusty',
113-
channel='stable',
109+
series='jammy',
110+
channel='8.0/stable',
114111
)
115112
116113
# Deploy mysql-slave application
117114
mysql_slave = await model.deploy(
118-
'cs:mysql-55',
115+
'mysql',
119116
application_name='mysql-slave',
120-
series='trusty',
121-
channel='stable',
117+
series='jammy',
118+
channel='8.0/stable',
122119
)
123120
124121
# Add the master-slave relation

docs/narrative/controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ these endpoints.
66

77
Connecting to the controller endpoint is useful if you want to programmatically
88
create a new model. If the model you want to use already exists, you can
9-
connect directly to it (see py:doc:`model`).
9+
connect directly to it (see :doc:`model`).
1010

11-
For API docs, see py:class:`juju.controller.Controller`.
11+
For API docs, see :class:`juju.controller.Controller`.
1212

1313

1414
Connecting to the Current Controller

docs/narrative/model.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A Juju controller provides websocket endpoints for each of its
44
models. In order to do anything useful with a model, the juju lib must
55
connect to one of these endpoints. There are several ways to do this.
66

7-
For api docs, see py:class:`juju.model.Model`.
7+
For api docs, see :class:`juju.model.Model`.
88

99

1010
Connecting to the Current Model
@@ -92,8 +92,8 @@ require the Juju CLI client to be installed.
9292
Creating and Destroying a Model
9393
-------------------------------
9494
Example of creating a new model and then destroying it. See
95-
py:method:`juju.controller.Controller.add_model` and
96-
py:method:`juju.controller.Controller.destroy_model` for more info.
95+
:method:`juju.controller.Controller.add_model` and
96+
:method:`juju.controller.Controller.destroy_model` for more info.
9797

9898
.. code:: python
9999
@@ -119,8 +119,8 @@ py:method:`juju.controller.Controller.destroy_model` for more info.
119119
Adding Machines and Containers
120120
------------------------------
121121
To add a machine or container, connect to a model and then call its
122-
py:method:`~juju.model.Model.add_machine` method. A
123-
py:class:`~juju.machine.Machine` instance is returned. The machine id
122+
:method:`~juju.model.Model.add_machine` method. A
123+
:class:`~juju.machine.Machine` instance is returned. The machine id
124124
can be used to deploy a charm to a specific machine or container.
125125

126126
.. code:: python
@@ -177,7 +177,7 @@ Reacting to Changes in a Model
177177
------------------------------
178178
To watch for and respond to changes in a model, register an observer with the
179179
model. The easiest way to do this is by creating a
180-
py:class:`juju.model.ModelObserver` subclass.
180+
:class:`juju.model.ModelObserver` subclass.
181181

182182
.. code:: python
183183
@@ -268,7 +268,7 @@ to the entity and type of change that you wish to handle.
268268
# specific handler method is not defined.
269269
270270
271-
Any py:class:`juju.model.ModelEntity` object can be observed directly by
271+
Any :class:`juju.model.ModelEntity` object can be observed directly by
272272
registering callbacks on the object itself.
273273

274274
.. code:: python

docs/readme.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Here's a simple example that shows basic usage of the library. The example
4040
connects to the currently active Juju model, deploys a single unit of the
4141
ubuntu charm, then exits:
4242

43+
.. note::
44+
45+
Pylibjuju requires an already bootstrapped Juju controller to connect to.
4346

4447
.. code:: python
4548
@@ -65,7 +68,7 @@ ubuntu charm, then exits:
6568
# from the stable channel of the Charm Store.
6669
ubuntu_app = await model.deploy(
6770
'ubuntu',
68-
application_name='ubuntu',
71+
application_name='my-ubuntu',
6972
)
7073
7174
if '--wait' in sys.argv:
@@ -124,5 +127,7 @@ and then, to connect to the current model and fetch status:
124127
Versioning
125128
----------
126129

127-
Pylibjuju releases now track the Juju release cadence. New generated schemas
130+
The current Pylibjuju release policy tracks the Juju release cadence.
131+
In particular, whenever Juju makes a latest/stable release, pylibjuju pushes out
132+
a release with the same version in the following week. Newly generated schemas
128133
will be updated per Juju releases.

docs/requirements.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
pytz==2021.1
2-
pymacaroons>=0.13.0,<1.0 # force new version with pynacl instead of libnacl
3-
sphinx==4.3.2
1+
pytz
2+
pymacaroons
3+
sphinx==5.3.0
44
sphinxcontrib-asyncio
55
sphinx_rtd_theme
6+
websockets
7+
typing-inspect
8+
pyyaml
9+
pyasn1
10+
pyrfc3339
11+
paramiko
12+
macaroonbakery
13+
toposort
14+
python-dateutil
15+
kubernetes

tox.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = lint,py3,py38,py39,py310
7+
envlist = lint,py3,py38,py39,py310,docs
88
skipsdist=True
99

1010
[pytest]
@@ -41,6 +41,15 @@ deps =
4141
kubernetes
4242
hvac
4343

44+
[testenv:docs]
45+
deps =
46+
-r docs/requirements.txt
47+
48+
allowlist_externals = rm
49+
commands =
50+
rm -rf docs/_build/
51+
sphinx-build -b html docs/ docs/_build/
52+
4453
[testenv:lint]
4554
commands =
4655
flake8 {posargs} juju tests examples

0 commit comments

Comments
 (0)