|
4 | 4 | "description": "Administrators' guide to writing Plone Documentation. It covers automated deployments, hosting, automated testing, previewing, and importing external package documentation into Plone Documentation."
|
5 | 5 | "property=og:description": "Administrators' guide to writing Plone Documentation. It covers automated deployments, hosting, automated testing, previewing, and importing external package documentation into Plone Documentation."
|
6 | 6 | "property=og:title": "Administrators Guide"
|
7 |
| - "keywords": "Plone, Documentation, automated deployments, hosting, automated testing, importing external packages" |
| 7 | + "keywords": "Plone, Documentation, automated deployments, hosting, automated testing, importing external packages, preview, build, pull request" |
8 | 8 | ---
|
9 | 9 |
|
10 | 10 | (administrators-guide-label)=
|
@@ -84,49 +84,118 @@ To make it easier for other contributors to work with your project, update the f
|
84 | 84 | Commit and push your changes to a remote, and submit a pull request against [ `plone/[email protected]`](https://github.com/plone/documentation/compare).
|
85 | 85 |
|
86 | 86 |
|
87 |
| -## Add a project to Netlify |
88 |
| - |
89 |
| -To add a new site to Netlify to preview built documentation or storybooks, you need to add a new site to Netlify. |
90 |
| - |
91 |
| -1. Visit [Team Overview](https://app.netlify.com/teams/plone/overview). |
92 |
| -1. Click {guilabel}`Add a new site` and select {guilabel}`Import an existing project`. |
93 |
| -1. Click {guilabel}`Deploy with GitHub`. |
94 |
| -1. Select {guilabel}`plone` for the GitHub organization. |
95 |
| -1. Click {guilabel}`Configure Netlify on GitHub`. |
96 |
| -1. Select the organization to where you want to install Netlify. |
97 |
| -1. Click {guilabel}`Select repositories` and select the repository that you want to add. |
98 |
| -1. Click {guilabel}`Update access`. |
99 |
| -1. Netlify sends an email to members of the email group `admins` at `plone.org`, who need to review and approve the request. |
100 |
| - However the email doesn't specify the repository, and admins will not know what to do. |
101 |
| - You must send email to that group, including in your request the organization and repository, such as `plone/volto`. |
102 |
| -1. The admin must login to GitHub as an organization owner, then navigate to the requested repository's {guilabel}`Settings`. [What else Admin person?] |
103 |
| -1. The admin replies to the requestor, letting them know the request was approved. |
104 |
| -
|
105 |
| -From here you need to update your repository to work with Netlify. |
106 |
| -For an example, see the following files. |
107 |
| -
|
108 |
| -- [Volto `Makefile`](https://github.com/plone/volto/blob/main/Makefile), specifically the `netlify` section. |
109 |
| - This will become the command used to build docs on Netlify. |
110 |
| -- [Volto `requirements-docs.txt`](https://github.com/plone/volto/blob/main/requirements-docs.txt) specifies the requirements to build the docs. |
111 |
| -- [Volto `netlify.toml`](https://github.com/plone/volto/blob/main/netlify.toml) specifies when to build the docs, specifically only when there are changes to documentation files. |
112 |
| -
|
113 |
| -Finally you need to configure your site in Netlify. |
114 |
| -You may have done some of these steps earlier, but you might need to refine them. |
115 |
| -The critical pieces are the following. |
116 |
| -
|
117 |
| -1. From the dashboard, select the site to edit it. |
118 |
| -1. Click {guilabel}`Site configuration`. |
119 |
| -1. One time only, under {guilabel}`General > Site details` click {guilabel}`Change site name`. |
120 |
| - A modal dialog appears. |
121 |
| - Enter the site name using the pattern `ORGANIZATION_NAME-REPOSITORY_NAME`. |
122 |
| - For example, `plone-components`. |
123 |
| - Click {guilabel}`Save`. |
124 |
| -1. Under {guilabel}`Build & deploy > Continuous deployment`, scroll to {guilabel}`Build settings`, and click {guilabel}`Configure`, then enter the following values. |
125 |
| - - {guilabel}`Base directory`: `/` |
126 |
| - - {guilabel}`Package directory`: `/` |
127 |
| - - {guilabel}`Build command`: `make netlify`. |
128 |
| - This is the command you would define in your `Makefile`. |
129 |
| - - {guilabel}`Publish directory`: `_build/html`. |
130 |
| - This is where the `make` command will output files. |
131 |
| - - Finally click {guilabel}`Save`. |
132 |
| -1. Under {guilabel}`Build & deploy > Continuous deployment`, scroll to {guilabel}`Branches and deploy contexts`, and click {guilabel}`Configure`, then enter appropriate values. |
| 87 | +## Pull request preview builds |
| 88 | + |
| 89 | +To preview pull request builds of documentation or Storybooks on Read the Docs, you need to configure your project's repository and import it into Read the Docs. |
| 90 | +You also need an account on Read the Docs and have write access to the repository. |
| 91 | +
|
| 92 | +
|
| 93 | +### Configuration files |
| 94 | +
|
| 95 | +The following are example files that you can use to configure your project for pull request previews on Read the Docs. |
| 96 | +
|
| 97 | +- [Plone Sphinx Theme `Makefile`](https://github.com/plone/plone-sphinx-theme/blob/main/Makefile), specifically the `rtd-pr-preview` section. |
| 98 | + This is the command to use to build documentation previews on Read the Docs. |
| 99 | +- [Plone Sphinx Theme `requirements-initial.txt`](https://github.com/plone/plone-sphinx-theme/blob/main/requirements-initial.txt) specifies the initial Python packaging tool requirements to set up a virtual environment. |
| 100 | +- [Plone Sphinx Theme `requirements-docs.txt`](https://github.com/plone/plone-sphinx-theme/blob/main/requirements-docs.txt) specifies the requirements to use Plone Sphinx Theme and build the docs. |
| 101 | +- [Plone Sphinx Theme `conf.py`](https://github.com/plone/plone-sphinx-theme/blob/main/docs/conf.py) the Sphinx configuration file to build the docs. |
| 102 | +- [Plone Sphinx Theme `.readthedocs.yaml`](https://github.com/plone/plone-sphinx-theme/blob/main/.readthedocs.yaml) specifies the configuration and command to build the docs. |
| 103 | +- [Plone Sphinx Theme `.github/workflows/rtd-pr-preview.yml`](https://github.com/plone/plone-sphinx-theme/blob/main/.github/workflows/rtd-pr-preview.yml) specifies when to build the docs, specifically only when a pull request is opened against the `main` branch and there are changes to documentation files. |
| 104 | + You might need to adjust the branch name, paths, and files to check for changes. |
| 105 | +
|
| 106 | +
|
| 107 | +### Import your project |
| 108 | +
|
| 109 | +After logging in to your Read the Docs account, you can import your project. |
| 110 | +
|
| 111 | +1. Click {guilabel}`Add project`. |
| 112 | +1. For {guilabel}`Repository name`, enter the GitHub organization, a forward slash, and the repository to import, for example, `plone/volto`. |
| 113 | +1. Click {guilabel}`Continue`. |
| 114 | +1. In the {guilabel}`Add project` screen, you can configure basic project settings, including its {guilabel}`Name`, {guilabel}`Repository URL`, {guilabel}`Default branch`, and {guilabel}`Language`. |
| 115 | + The defaults are usually accurate. |
| 116 | +1. Click {guilabel}`Next`. |
| 117 | +1. A sample `.readthedocs.yaml` file is suggested, if you have not already added one. |
| 118 | +1. Click {guilabel}`Finish`. |
| 119 | + Read the Docs will redirect you to the project details, and start building the docs. |
| 120 | +
|
| 121 | +
|
| 122 | +### Search engine indexing |
| 123 | +
|
| 124 | +Many Plone projects currently self-host their official documentation at {doc}`/index`. |
| 125 | +These projects get indexed by search engines. |
| 126 | +
|
| 127 | +For pull request previews, unsupported branches or versions, or other situations, you most likely do not want search engines to index your documentation. |
| 128 | +Your options include the following. |
| 129 | +
|
| 130 | +- Deactivate your build |
| 131 | +- Hide your build |
| 132 | +- Create a custom {file}`robots.txt` file to discourage, but not absolutely prevent, search engine indexing |
| 133 | +
|
| 134 | +For the last option, you can configure Sphinx to copy the {file}`robots.txt` file. |
| 135 | +However, if you want to have two versions of a {file}`robots.txt` file—say one that allows indexing of your official documentation and another that discourages indexing—you can configure your automation to copy it into place with a command such as the following. |
| 136 | +
|
| 137 | +```shell |
| 138 | +cp source-path/block-robots.txt docs-root-path/robots.txt |
| 139 | +``` |
| 140 | +
|
| 141 | +```{seealso} |
| 142 | +- [Automation rules](https://docs.readthedocs.io/en/stable/automation-rules.html) |
| 143 | +- [Versions](https://docs.readthedocs.io/en/stable/versions.html) |
| 144 | +- [Managing versions automatically](https://docs.readthedocs.io/en/stable/guides/automation-rules.html) |
| 145 | +- [`robots.txt` support](https://docs.readthedocs.io/en/stable/reference/robots.html) |
| 146 | +``` |
| 147 | +
|
| 148 | +
|
| 149 | +### Cancel builds programmatically |
| 150 | +
|
| 151 | +You might want to cancel a build programmatically when certain conditions are met. |
| 152 | +You can do this through your {file}`.readthedocs.yaml` file. |
| 153 | +Read the Docs covers a few scenarios in its documentation, [Cancel build based on a condition](https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition). |
| 154 | +
|
| 155 | +
|
| 156 | +#### Build only on changes |
| 157 | +
|
| 158 | +When there are no changes to documentation, it is not necessary to build it. |
| 159 | +You can save time and energy by programmatically building documentation only when it changes. |
| 160 | +
|
| 161 | +In your {file}`.readthedocs.yaml` file, you could use the following example. |
| 162 | +
|
| 163 | +```yaml |
| 164 | +version: 2 |
| 165 | +build: |
| 166 | + os: "ubuntu-22.04" |
| 167 | + tools: |
| 168 | + python: "3.12" |
| 169 | + jobs: |
| 170 | + post_checkout: |
| 171 | + # Cancel building pull requests when there aren't changes in the docs directory or YAML file. |
| 172 | + # You can add any other files or directories that you'd like here as well, |
| 173 | + # like your docs requirements file, or other files that will change your docs build. |
| 174 | + # |
| 175 | + # If there are no changes (git diff exits with 0) we force the command to return with 183. |
| 176 | + # This is a special exit code on Read the Docs that will cancel the build immediately. |
| 177 | + - | |
| 178 | + if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ .readthedocs.yaml requirements-initial.txt requirements.txt; |
| 179 | + then |
| 180 | + exit 183; |
| 181 | + fi |
| 182 | +``` |
| 183 | + |
| 184 | + |
| 185 | +#### Cancel builds on a branch |
| 186 | + |
| 187 | +If you have pull request preview builds enabled, any pull request to any branch will trigger a build. |
| 188 | +If you do not want to build documentation on a specific branch, you can cancel a build programmatically through your {file}`.readthedocs.yaml` file. |
| 189 | + |
| 190 | +```yaml |
| 191 | +version: 2 |
| 192 | +build: |
| 193 | + os: "ubuntu-22.04" |
| 194 | + tools: |
| 195 | + python: "3.12" |
| 196 | + jobs: |
| 197 | + post_checkout: |
| 198 | + # Cancel the Read the Docs build |
| 199 | + # https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition |
| 200 | + - exit 183; |
| 201 | +``` |
0 commit comments