Skip to content

Commit 1fa8998

Browse files
committed
Improve documentation
Signed-off-by: Aurélien Bompard <[email protected]>
1 parent 4228dd8 commit 1fa8998

19 files changed

+111
-72
lines changed
File renamed without changes.
File renamed without changes.

docs/build-schemas-list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
SCHEMAS_FILE = "schema-packages.txt"
19-
DOC_FILE = "schemas.rst"
19+
DOC_FILE = "user-guide/schemas.rst"
2020
HEADER = """
2121
=================
2222
Available Schemas

docs/conf.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@
8989
html_theme_options = {
9090
"github_user": "fedora-infra",
9191
"github_repo": "fedora-messaging",
92+
"github_button": True,
93+
"description": "A set of tools for using Fedora's messaging infrastructure",
9294
"page_width": "1040px",
9395
"show_related": True,
9496
"sidebar_collapse": True,
97+
"caption_font_size": "150%",
9598
}
9699

97100
# Add any paths that contain custom static files (such as style sheets) here,
@@ -154,7 +157,13 @@
154157
# One entry per manual page. List of tuples
155158
# (source start file, name, description, authors, manual section).
156159
man_pages = [
157-
("fedora-messaging", "fedora-messaging", "Fedora Messaging CLI", [author], 1)
160+
(
161+
"user-guide/cli/fedora-messaging",
162+
"fedora-messaging",
163+
"Fedora Messaging CLI",
164+
[author],
165+
1,
166+
)
158167
]
159168

160169

docs/contributing.rst

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
============
2-
Contributing
3-
============
1+
=================
2+
Contributor guide
3+
=================
44

55
Thanks for considering contributing to fedora-messaging, we really appreciate it!
66

7-
Quickstart:
7+
Quickstart
8+
==========
89

910
1. Look for an `existing issue
1011
<https://github.com/fedora-infra/fedora-messaging/issues>`_ about the bug or
@@ -28,17 +29,15 @@ below.
2829
.. note:: If you do not wish to use GitHub, please send patches to
2930
3031

31-
Guidelines
32-
==========
3332

3433
Python Support
35-
--------------
34+
==============
3635
fedora-messaging supports Python 3.6 or greater. This is automatically enforced
3736
by the continuous integration (CI) suite.
3837

3938

4039
Code Style
41-
----------
40+
==========
4241
We follow the `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_ style guide
4342
for Python. This is automatically enforced by the CI suite.
4443

@@ -51,7 +50,7 @@ To setup to hook for your repo clone, install pre-commit and run ``pre-commit in
5150

5251

5352
Tests
54-
-----
53+
=====
5554
The test suites can be run using `tox <http://tox.readthedocs.io/>`_ by simply
5655
running ``tox`` from the repository root. All code must have test coverage or
5756
be explicitly marked as not covered using the ``# no-qa`` comment. This should
@@ -62,8 +61,7 @@ you're not certain how to write tests, we will be happy to help you.
6261

6362

6463
Release notes
65-
-------------
66-
64+
=============
6765
To add entries to the release notes, run ``towncrier create <source.type>`` to
6866
create a news fragment file in the ``news`` directory, where ``type`` is one of:
6967

@@ -99,8 +97,7 @@ A preview of the release notes can be generated with ``towncrier --draft``.
9997

10098

10199
Licensing
102-
---------
103-
100+
=========
104101
Your commit messages must include a Signed-off-by tag with your name and e-mail
105102
address, indicating that you agree to the `Developer Certificate of Origin
106103
<https://developercertificate.org/>`_ version 1.1::
@@ -147,8 +144,7 @@ Use ``git commit -s`` to add the Signed-off-by tag.
147144

148145

149146
Releasing
150-
---------
151-
147+
=========
152148
When cutting a new release, follow these steps:
153149

154150
* update the version in ``fedora_messaging/__init__.py``

docs/index.rst

+24-30
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,52 @@ This library is designed to be a replacement for the `PyZMQ`_-backed `fedmsg`_
1212
library.
1313

1414

15-
User Guide
16-
==========
17-
1815
.. toctree::
1916
:maxdepth: 2
17+
:caption: User Guide
2018

21-
installation
22-
quick-start
23-
configuration
24-
publishing
25-
consuming
26-
messages
27-
testing
28-
schemas
29-
changelog
30-
19+
user-guide/installation
20+
user-guide/quick-start
21+
user-guide/configuration
22+
user-guide/publishing
23+
user-guide/messages
24+
user-guide/consuming
25+
user-guide/schemas
26+
user-guide/testing
27+
user-guide/cli
3128

32-
Command Line Interface Manuals
33-
------------------------------
3429

3530
.. toctree::
3631
:maxdepth: 2
32+
:caption: Tutorial
3733

38-
fedora-messaging
34+
tutorial/installation
35+
tutorial/usage
36+
tutorial/schemas
37+
tutorial/exceptions
38+
tutorial/conversion
3939

4040

41-
Tutorial
42-
========
43-
4441
.. toctree::
4542
:maxdepth: 2
43+
:caption: API Documentation
4644

47-
tutorial/index
48-
45+
api/api
46+
api/wire-format
4947

50-
API Documentation
51-
=================
5248

5349
.. toctree::
5450
:maxdepth: 2
51+
:caption: Contributing
5552

56-
api
57-
wire-format
58-
53+
contributing
5954

60-
Contributor Guide
61-
=================
6255

6356
.. toctree::
64-
:maxdepth: 2
57+
:maxdepth: 1
58+
:caption: Release Notes
6559

66-
contributing
60+
changelog
6761

6862

6963
.. _fedmsg: https://github.com/fedora-infra/fedmsg/

docs/tutorial/index.rst

-16
This file was deleted.

docs/user-guide/cli.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Command Line Interface Manuals
2+
------------------------------
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
cli/fedora-messaging
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/messages.rst renamed to docs/user-guide/messages.rst

+54-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _messages:
22

3-
========
4-
Messages
5-
========
3+
===============
4+
Message Schemas
5+
===============
66

77
Before you release your application, you should create a subclass of
88
:class:`fedora_messaging.message.Message`, define a schema, define a default
@@ -23,7 +23,8 @@ develop!
2323

2424
Secondly, it allows you to change your message format in a controlled fashion
2525
by versioning your schema. You can then choose to implement methods one way or
26-
another based on the version of the schema used by a message.
26+
another based on the version of the schema used by a message. For details on how
27+
to deprecate and upgrade message schemas, see :ref:`schema-upgrade`.
2728

2829
Message schema are defined using `JSON Schema`_. The complete API can be found
2930
in the :ref:`message-api` API documentation.
@@ -52,7 +53,7 @@ object.
5253
Example Schema
5354
--------------
5455

55-
.. include:: sample_schema_package/mailman_messages/messages.py
56+
.. include:: ../sample_schema_package/mailman_messages/messages.py
5657
:literal:
5758

5859
Note that message schema can be composed of other message schema, and
@@ -78,6 +79,52 @@ format. Messages should provide Python properties to access the deserialized
7879
JSON object. This Python API should maintain backwards compatibility between
7980
schema. This shields consumers from changes in schema.
8081

82+
Useful Accessors
83+
~~~~~~~~~~~~~~~~
84+
85+
All available accessors are described in the :ref:`message-api` API documentation ;
86+
here is a list of those we recommend implementing to allow users to get
87+
notifications for your messages:
88+
89+
* :py:meth:`~fedora_messaging.message.Message.__str__`:
90+
A human-readable representation of this message. This can be a multi-line string
91+
that forms the body of an email notification.
92+
* :py:attr:`~fedora_messaging.message.Message.summary`:
93+
A short, single-line, human-readable summary of the message, much like the subject
94+
line of an email.
95+
* :py:attr:`~fedora_messaging.message.Message.agent_name`:
96+
The username of the user who caused the action.
97+
* :py:attr:`~fedora_messaging.message.Message.app_name`:
98+
The name of the application that generated the message. This can be implemented as
99+
a class attribute or as a property.
100+
* :py:attr:`~fedora_messaging.message.Message.app_icon`:
101+
A URL to the icon of the application that generated the message. This can be
102+
implemented as a class attribute or as a property.
103+
* :py:attr:`~fedora_messaging.message.Message.packages`:
104+
A list of RPM packages affected by the action that generated this message, if any.
105+
* :py:attr:`~fedora_messaging.message.Message.flatpaks`:
106+
A list of flatpaks affected by the action that generated this message, if any.
107+
* :py:attr:`~fedora_messaging.message.Message.modules`:
108+
A list of modules affected by the action that generated this message, if any.
109+
* :py:attr:`~fedora_messaging.message.Message.containers`:
110+
A list of containers affected by the action that generated this message, if any.
111+
* :py:attr:`~fedora_messaging.message.Message.usernames`:
112+
A list of usernames affected by the action that generated this message.
113+
This may contain the ``agent_name``.
114+
* :py:attr:`~fedora_messaging.message.Message.groups`:
115+
A list of group names affected by the action that generated this message.
116+
* :py:attr:`~fedora_messaging.message.Message.url`:
117+
A URL to the action that caused this message to be emitted, if any.
118+
* :py:attr:`~fedora_messaging.message.Message.severity`:
119+
An integer that indicates the severity of the message. This is used to determine
120+
what messages to notify end users about and should be
121+
:py:data:`~fedora_messaging.message.DEBUG`,
122+
:py:data:`~fedora_messaging.message.INFO`,
123+
:py:data:`~fedora_messaging.message.WARNING`,
124+
or :py:data:`~fedora_messaging.message.ERROR`.
125+
The default is :py:data:`~fedora_messaging.message.INFO`, and can be set
126+
as a class attribute or on an instance-by-instance basis.
127+
81128

82129
Packaging
83130
=========
@@ -121,6 +168,8 @@ structure for you.
121168

122169

123170

171+
.. _schema-upgrade:
172+
124173
Upgrade and deprecation
125174
=======================
126175

File renamed without changes.

docs/quick-start.rst renamed to docs/user-guide/quick-start.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ If fedora-messaging was installed via RPM, they should be in
9393
`key`_, `certificate`_, and the `CA certificate`_ from the upstream git
9494
repository and start with the following configuration file:
9595

96-
.. literalinclude:: ../configs/fedora.toml
96+
.. literalinclude:: ../../configs/fedora.toml
9797

9898
Assuming the ``/etc/fedora-messaging/fedora.toml``,
9999
``/etc/fedora-messaging/cacert.pem``, ``/etc/fedora-messaging/fedora-key.pem``,
File renamed without changes.
File renamed without changes.

fedora_messaging/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
A complete example TOML configuration:
2929
30-
.. literalinclude:: ../config.toml.example
30+
.. literalinclude:: ../../config.toml.example
3131
3232
3333
Generic Options

fedora_messaging/message.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ def agent_name(self):
587587
def agent_avatar(self):
588588
"""An URL to the avatar of the user who caused the action.
589589
590-
.. note:: Sub-classes should override this method if the message was
591-
triggered by a particular user.
590+
.. note:: Sub-classes should override this method if the default
591+
Libravatar and OpenID-based URL generator is not appropriate.
592592
593593
Returns:
594594
str or None: The URL to the user's avatar.

0 commit comments

Comments
 (0)