Skip to content

Commit 5c45891

Browse files
committed
Tidy up create-a-distribution.md.
- Rewrite passive voice to active. - Enhance code blocks with `emphasize-lines`. - Use definition lists as appropriate for terms and inline literals. - Add links and terms where helpful.
1 parent 5c0f197 commit 5c45891

File tree

1 file changed

+129
-100
lines changed

1 file changed

+129
-100
lines changed

docs/developer-guide/create-a-distribution.md

Lines changed: 129 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -11,76 +11,83 @@ myst:
1111

1212
# Create a Plone distribution
1313

14+
This section explains how a developer can create a custom Plone {term}`distribution`.
1415
A Plone distribution is a pre-packaged version of Plone that includes specific features, themes, modules, and configurations.
15-
This section explains how a developer can create a custom Plone distribution.
1616

1717
```{seealso}
1818
For a conceptual guide, see {doc}`/conceptual-guides/distributions`.
1919
```
2020

21+
2122
## Create a backend add-on
2223

2324
These instructions assume that you already have created a Plone backend add-on package,
2425
and now you want to add a distribution to it.
2526

26-
A Plone distribution exists inside a Python Package that can be installed by `pip`.
27+
A Plone distribution exists inside a Python package that can be installed by `pip`.
28+
2729

2830
## Update `setup.py`
2931

30-
The package will follow some conventions to make it "discoverable" by others.
32+
Your package should follow conventions that make it discoverable by other developers.
3133

32-
In `setup.py`, always add the correct Trove classifiers:
34+
In your {file}`setup.py` file, always add the correct [Python Trove classifiers](https://pypi.org/classifiers/).
3335

3436
```python
35-
"Framework :: Plone",
36-
"Framework :: Plone :: 6.1",
37-
"Framework :: Plone :: Distribution",
37+
"Framework :: Plone",
38+
"Framework :: Plone :: 6.1",
39+
"Framework :: Plone :: Distribution",
3840
```
3941

40-
and also require `plone.distribution` to be available:
42+
Add `plone.distribution` to your `install_requires` stanza in your {file}`setup.py` file.
4143

42-
```python
43-
install_requires=[
44-
"Products.CMFPlone",
45-
"setuptools",
46-
"plone.distribution",
47-
],
44+
```{code-block} python
45+
:emphasize-lines: 4
46+
47+
install_requires=[
48+
"Products.CMFPlone",
49+
"setuptools",
50+
"plone.distribution",
51+
],
4852
```
4953

54+
5055
## Update `configure.zcml`
5156

52-
In your main `configure.zcml`, make sure to have the `plone` XML namespace declared:
57+
In your main {file}`configure.zcml` file, add the `plone` XML namespace with the following declaration.
58+
59+
```{code-block} xml
60+
:emphasize-lines: 3
5361
54-
```xml
5562
<configure
5663
xmlns="http://namespaces.zope.org/zope"
5764
xmlns:plone="http://namespaces.plone.org/plone"
5865
>
5966
```
6067

61-
And also include `plone.distribution`:
68+
Register `plone.distribution` as a package to include with the following `<include>` directive.
6269

6370
```xml
6471
<include package="plone.distribution" />
6572
```
6673

67-
Then declare the distributions included in your package:
74+
Then declare the distributions you want to include in your package.
6875

6976
```xml
70-
<plone:distribution
71-
name="blog"
72-
title="Personal Blog"
73-
description="A Plone site already configured to host a personal Blog."
74-
directory="distributions/blog"
75-
/>
77+
<plone:distribution
78+
name="blog"
79+
title="Personal Blog"
80+
description="A Plone site already configured to host a personal blog."
81+
directory="distributions/blog"
82+
/>
7683
```
7784

78-
This example registers a distribution that will configure a Personal Blog, with some default content.
85+
The above example registers a distribution that will configure a personal blog with some default content.
86+
7987

8088
## Add distribution handlers
8189

82-
When registering a distribution, you can provide a `pre_handler`, a `handler` and a `post_handler` which must be
83-
functions with the following signatures.
90+
When registering a distribution, you can provide a `pre_handler`, a `handler`, and a `post_handler`, each of which must be a function with their respective signature, as shown in the following example.
8491

8592
```python
8693
def pre_handler(answers: dict) -> dict:
@@ -93,46 +100,58 @@ def post_handler(distribution: Distribution, site, answers: dict):
93100
return site
94101
```
95102

96-
Each of those handlers will be called in this way:
103+
Each of those handlers will be called as follows.
97104

98-
- `pre_handler`: it will process the answers to do modifications on them before creating the site
99-
- `handler`: it will be run after the bare Plone site will be created, but instead of the default handler that installs the required GenericSetup profiles and creates the content.
100-
- `post_handler`: it will be run after the site is set up.
105+
`pre_handler`
106+
: Processes the answers to prepare the distribution before creating the site.
101107

102-
If you have added some extra fields in the Plone site creation form and want to do some extra configuration in the
103-
Plone site, you can add your own handler and register as follows:
108+
`handler`
109+
: Runs after creating the bare Plone site instead of the default handler.
110+
It installs the required GenericSetup profiles and creates the content.
104111

105-
```xml
106-
<plone:distribution
107-
name="blog"
108-
title="Personal Blog"
109-
description="A Plone site already configured to host a personal Blog."
110-
directory="distributions/blog"
111-
post_handler=".handlers.blog.post_handler"
112-
/>
112+
`post_handler`
113+
: Runs after the site is set up.
114+
115+
To add extra configuration to your Plone site, and assuming you added extra inputs to the Plone site creation form, then you can add your own handler, registering it as shown in the following example.
116+
117+
```{code-block} xml
118+
:emphasize-lines: 6
119+
120+
<plone:distribution
121+
name="blog"
122+
title="Personal Blog"
123+
description="A Plone site already configured to host a personal Blog."
124+
directory="distributions/blog"
125+
post_handler=".handlers.blog.post_handler"
126+
/>
113127
```
114128

115-
## Add a distribution folder
116129

117-
A convention is to use the `distributions/<distribution_name>`folder in the root of your package to organize your distribution configuration.
130+
## Add a distribution folder
131+
132+
To organize your distribution configuration, you can follow the convention to use the {file}`distributions/<distribution_name>` folder in the root of your package.
133+
In that folder, you need to provide the items described in the following sections.
118134

119-
In that folder, you will need to provide:
120135

121136
### `image.png`
122137

123-
A 1080x768 image of your distribution. It could be the default page of a new site, your logo, or any other way of representing this distribution.
138+
A 1080 pixels wide by 768 pixels tall image in PNG format representing your distribution.
139+
It could be the default page of a new site, your logo, or any other way of representing your distribution.
140+
124141

125142
### `profiles.json`
126143

127-
A `JSON` file with the GenericSetup profiles that are used by your distribution during installation.
144+
A file {file}`profiles.json` containing the GenericSetup profiles that your distribution uses during installation.
128145

129-
This file needs to contain two keys:
146+
This file needs to contain two keys.
130147

131-
- **base**: List of profiles installed in every new site using this distribution.
148+
`base`
149+
: List of profiles to install in every new site using this distribution.
132150

133-
- **content**: List of profiles installed when the user decides to create a site with example content.
151+
`content`
152+
: List of profiles to install when the user decides to create a site with example content.
134153

135-
The configuration for a new Volto site is:
154+
As an example, the configuration for a new Plone site with Volto as its frontend would be the following.
136155

137156
```json
138157
{
@@ -148,25 +167,29 @@ The configuration for a new Volto site is:
148167
}
149168
```
150169

170+
151171
### `schema.json`
152172

153-
In case you require additional input from the user during site creation, you can customize the form using the `schema.json` file.
173+
If you require additional input from the user during site creation, you can customize the form using the {file}`schema.json` file.
154174

155-
The file should contain two keys:
175+
The file should contain two keys.
156176

157-
- **schema**: A JSON Schema definition.
158-
- **uischema**: A [react-jsonschema-form](https://rjsf-team.github.io/react-jsonschema-form/docs/) configuration to modify how the form is displayed.
177+
`schema`
178+
: A {term}`JSON Schema` definition.
159179

160-
The **schema** should have at least the following keys:
180+
`uischema`
181+
: A [`react-jsonschema-form`](https://rjsf-team.github.io/react-jsonschema-form/docs/) configuration to modify the display of the form.
161182

162-
- site_id
163-
- title
164-
- description
165-
- default_language
166-
- portal_timezone
167-
- setup_content
183+
The `schema` should have at least the following keys.
168184

169-
The `schema.json` used for the default site creation is:
185+
- `site_id`
186+
- `title`
187+
- `description`
188+
- `default_language`
189+
- `portal_timezone`
190+
- `setup_content`
191+
192+
The following code example is the content of the {file}`schema.json` file for creating the site.
170193

171194
```json
172195
{
@@ -211,42 +234,41 @@ The `schema.json` used for the default site creation is:
211234
}
212235
```
213236

214-
:::{note}
215-
You probably noticed the entries for `default_language`:
216-
217-
```json
218-
{"$ref": "#/definitions/languages"}
219-
```
220-
221-
and `portal_timezone`:
237+
````{note}
238+
You may have noticed the entries for both `default_language` and `portal_timezone`.
222239
223240
```json
224-
{"$ref": "#/definitions/timezones"}
241+
"default_language": {"$ref": "#/definitions/languages"},
242+
"portal_timezone": {"$ref": "#/definitions/timezones"},
225243
```
226244
227-
Both definitions are added in runtime by `plone.distribution` to provide a list of languages and timezones available on the installation.
228-
:::
245+
`plone.distribution` adds both definitions at runtime, providing a list of languages and timezones available on the installation.
246+
````
229247

230248
## Add a dependency on an add-on
231249

232250
If you want to add a Plone backend add-on to your Plone distribution, then you must perform the following steps.
233251

234-
Add your add-on, such as `collective.person`, to your `setup.py`:
252+
Add your add-on, such as `collective.person`, to your {file}`setup.py` file's `install_requires` stanza.
235253

236-
```python
237-
install_requires=[
238-
"setuptools",
239-
"Plone",
240-
"plone.distribution>=1.0.0b2",
241-
"plone.api",
242-
"collective.person",
243-
],
254+
```{code-block} python
255+
:emphasize-lines: 6
256+
257+
install_requires=[
258+
"setuptools",
259+
"Plone",
260+
"plone.distribution>=1.0.0b2",
261+
"plone.api",
262+
"collective.person",
263+
],
244264
```
245265

246-
Add it to your `dependencies.zcml`:
266+
Then add it to your {file}`dependencies.zcml` file.
247267

248-
```xml
249-
<!-- List all packages you depend here -->
268+
```{code-block} xml
269+
:emphasize-lines: 5
270+
271+
<!-- List all packages your distribution depends on here -->
250272
<include package="plone.volto" />
251273
<include package="plone.restapi" />
252274
<include package="collective.person" />
@@ -255,39 +277,46 @@ Add it to your `dependencies.zcml`:
255277
</configure>
256278
```
257279

258-
Add it to your `profiles.json`:
280+
Finally, add it to your {file}`profiles.json` file.
259281

260-
```json
261-
"base": [
262-
"plone.app.contenttypes:default",
263-
"plone.app.caching:default",
264-
"plone.restapi:default",
265-
"plone.volto:default",
266-
"collective.person:default",
267-
"plonetheme.barceloneta:default"
268-
],
282+
```{code-block} json
283+
:emphasize-lines: 6
284+
285+
"base": [
286+
"plone.app.contenttypes:default",
287+
"plone.app.caching:default",
288+
"plone.restapi:default",
289+
"plone.volto:default",
290+
"collective.person:default",
291+
"plonetheme.barceloneta:default"
292+
],
269293
```
270294

295+
271296
## Add example content
272297

273-
The distribution's content is loaded from JSON data in the `content` folder.
298+
The distribution loads its content from JSON data in the `content` folder.
274299

275300
To export content from a site into this folder, use the `bin/export-distribution` script.
276301

277302
```shell
278303
bin/export-distribution path/to/zope.conf Plone
279304
```
280305

281-
In the example above, "Plone" is the ID of the Plone site to export.
306+
In the example above, `Plone` is the ID of the Plone site to export.
307+
282308

283309
## Limit available distributions
284310

285311
By default, Plone 6.1 ships with two ready-to-use distributions:
286312

287-
- **default**: Plone Site (Volto frontend)
288-
- **classic**: Plone Site (Classic UI)
313+
[`plone.volto`](https://github.com/plone/plone.volto)
314+
: Create a Plone site with the Volto frontend.
315+
316+
[`plone.classicui`](https://github.com/plone/plone.classicui)
317+
: Create a Plone site with the Classic UI frontend.
289318

290-
If you want to limit the choice of distributions when creating a new site, it is possible to set the environment variable `ALLOWED_DISTRIBUTIONS` with fewer options:
319+
If you want to limit the choice of distributions when creating a new site, it is possible to set the environment variable `ALLOWED_DISTRIBUTIONS` with fewer options.
291320

292321
```shell
293322
ALLOWED_DISTRIBUTIONS=default

0 commit comments

Comments
 (0)