You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/README.rst
+130-27
Original file line number
Diff line number
Diff line change
@@ -18,51 +18,125 @@
18
18
Documentation
19
19
#############
20
20
21
-
This directory contains documentation for the Apache Airflow project and other packages that are closely related to it ie. providers packages. Documentation is built using `Sphinx <https://www.sphinx-doc.org/>`__.
21
+
This directory contains documentation for the `Apache Airflow project <https://airflow.apache.org/docs/>`__ and the providers packages that are closely related to it. You can contribute to the Airflow Docs in the same way and for the same reasons as contributing code; Docs contributions that improve existing content, fix bugs, and create new content are welcomed and encouraged.
22
+
23
+
This README gives an overview about how Airflow uses `Sphinx <https://www.sphinx-doc.org/>`__ to write and build docs. It also includes instructions for how to make Docs changes locally or with the GitHub UI.
22
24
23
25
Development documentation preview
24
26
==================================
25
27
26
-
Documentation from the development version is built and automatically published: `s.apache.org/airflow-docs <https://s.apache.org/airflow-docs>`_
28
+
You can find documentation for the current development version at `s.apache.org/airflow-docs <https://s.apache.org/airflow-docs>`_, where it is automatically built and published.
29
+
30
+
Working with Sphinx
31
+
===================
32
+
33
+
Airflow Documentation uses `Sphinx <https://www.sphinx-doc.org/>`__, a reStructure Text (.rst) markup language that was developed to document Python and Python projects, to build the docs site.
34
+
35
+
For most Docs writing purposes, the `reStructured Text Primer <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`__ provides a quick reference of common formatting and syntax.
36
+
37
+
A general docs workflow
38
+
-----------------------
39
+
When you make changes to the docs, it follows roughly the same process as creating and testing code changes. However, for docs, instead of unit tests and integration tests, you run pre-commit checks, spell checks, and visual inspection of your changes in a documentation build.
40
+
41
+
1. **Decide to edit in GitHub UI or locally** - Depending on the size and type of docs update you want to make, it might be easier to work in the UI or to make your edits in a local fork.
42
+
2. **Find the source files to edit** - While you can access most of the docs source files using the **Suggest a change on this page** button or by searching for a string in the ``/docs/`` file directory, in some cases, the source strings might be located in different provider docs or in the source code itself.
43
+
3. **If editing locally, run spellcheck and the build to identify any blocking errors** - Docs require build, spellcheck, and precommit CI/CD tests to pass before they can merge. This means that if you have a pull request with docs changes, a docs build error can prevent your code merge. Checking the build and spelling locally first can help speed up reviews. If you made formatting changes, checking a local build of your docs allows you to make sure you correctly formatted elements like tables, text styling, and line breaks.
44
+
4. **Make your pull request** - When you make a PR, Github automatically assigns reviewers and runs CI/CD tests.
45
+
5. **Fix any build errors or spelling mistakes** - Your PR can't be merged if there are any spelling or build errors. Check to see which builds are failing and click **Show details**. The output of the tests share the errors, location of the problems, and suggest resolutions. Common Docs failures occur due to incorrect formatting and whitespace.
46
+
47
+
Editing in GitHub or locally
48
+
----------------------------
49
+
50
+
You have two options for editing Airflow docs:
51
+
52
+
1. Through the online GitHub Editor by clicking **Suggest a change on this page** in the `docs <https://airflow.apache.org/docs/>`_, or by selecting a file in `GitHub <https://github.com/apache/airflow/tree/main/docs>`__.
53
+
54
+
2. Locally with a forked copy of the Airflow repo, where you can run local builds and tests prior to making a pull request.
Sphinx has _roles_ and _directives_, where Markdown docs frameworks often do not have similar functionality. This means that Airflow uses directives
80
+
to pull code examples, autogenerate indexes and tables of contents, and reference from resources across the codebase and across documentation provider packages.
81
+
This can make it confusing to find the content source on certain types of reference pages.
82
+
83
+
For example, in `Command Line Interface and Environment Variables Reference <https://airflow.apache.org/docs/apache-airflow/stable/cli-and-env-variables-ref.html#environment-variables>`__, the CLI reference is `autogenerated <https://github.com/apache/airflow/blob/main/docs/apache-airflow/cli-and-env-variables-ref.rst?plain=1#L44>`__,
84
+
and requires more complex scripting. While the `Environment Variables <https://github.com/apache/airflow/blob/main/docs/apache-airflow/cli-and-env-variables-ref.rst?plain=1#L51>`__ are explicitly written.
85
+
86
+
To make an edit to an autogenerated doc, you need to make changes to a string in the Python source file. In the previous example, to make edits to the CLI command reference text, you must edit the `cli_config.py <https://github.com/apache/airflow/blob/main/airflow/cli/cli_config.py#L1861>`__ source file.
27
87
28
88
Building documentation
29
89
======================
30
90
31
-
To generate a local version you can use `<../BREEZE.rst>`_.
91
+
To generate a local version of the docs you can use `<../BREEZE.rst>`_.
32
92
33
93
The documentation build consists of verifying consistency of documentation and two steps:
34
94
35
95
* spell checking
36
96
* building documentation
37
97
38
-
You can only run one of the steps via ``--spellcheck-only`` or ``--docs-only``.
98
+
You can choose to run the complete build, to build all the docs and run spellcheck. Or, you can use package names and the optional flags, ``--spellcheck-only`` or ``--docs-only`` to choose the scope of the build.
99
+
100
+
Build all docs and spell check them:
39
101
40
102
.. code-block:: bash
41
103
42
104
breeze build-docs
43
105
44
-
or just to run spell-check
106
+
Just run spellcheck:
45
107
46
108
.. code-block:: bash
47
109
48
110
breeze build-docs --spellcheck-only
49
111
50
-
or just to run documentation building
112
+
Build docs without checking spelling:
51
113
52
114
.. code-block:: bash
53
115
54
116
breeze build-docs --docs-only
55
117
56
-
Also, you can only build one documentation via ``--package-filter``.
118
+
Build documentation of just one provider package by calling the ``PACKAGE_ID``.
119
+
120
+
.. code-block:: bash
121
+
122
+
breeze build-docs PACKAGE_ID
123
+
124
+
So, for example, to build just the ``apache-airflow-providers-apache-beam`` package docs, you would use the following:
57
125
58
126
.. code-block:: bash
59
127
60
-
breeze build-docs --package-filter <PACKAGE-NAME>
128
+
breeze build-docs apache.beam
129
+
130
+
Or, build docs for more than one provider package in the same command by listing multiple package IDs:
131
+
132
+
.. code-block:: bash
133
+
134
+
breeze build-docs PACKAGE1_ID PACKAGE2_ID
61
135
62
136
You can also use shorthand names as arguments instead of using the full names
63
137
for airflow providers. To find the short hand names, follow the instructions in :ref:`generating_short_form_names`.
64
138
65
-
You can also see all the available arguments via ``--help``.
139
+
You can see all the available arguments via ``--help``.
66
140
67
141
.. code-block:: bash
68
142
@@ -71,26 +145,19 @@ You can also see all the available arguments via ``--help``.
71
145
Running the Docs Locally
72
146
------------------------
73
147
74
-
Once you have built the documentation you can start the webserver in breeze environment and view the built documentation
75
-
at ``http://localhost:28080/docs/``
148
+
After you build the documentation, you can check the formatting, style, and documentation build at ``http://localhost:28080/docs/``
149
+
by starting a Breeze environment or by running the following command from the root directory.
76
150
77
-
Alternatively, run the following command from the root directory.
78
151
You need to have Python installed to run the command:
79
152
80
153
.. code-block:: bash
81
154
82
155
docs/start_doc_server.sh
83
156
84
157
85
-
Then, view your docs at ``localhost:8000``, if you are using a virtual machine e.g WSL2,
86
-
you need to find the WSL2 machine IP address and in your browser replace "0.0.0.0" with it
87
-
``http://n.n.n.n:8000``, where n.n.n.n will be the IP of the WSL2.
88
-
89
-
Troubleshooting
90
-
---------------
91
-
92
-
If you are creating ``example_dags`` directory, you need to create ``example_dags/__init__.py`` with Apache
93
-
license or copy another ``__init__.py`` file that contains the necessary license.
158
+
Then, view your docs at ``localhost:8000``. If you use a virtual machine, like WSL2,
159
+
you need to find the WSL2 machine IP address and replace "0.0.0.0" in your browser with it. The address looks like
160
+
``http://n.n.n.n:8000``, where n.n.n.n is the IP of the WSL2.
94
161
95
162
.. _generating_short_form_names:
96
163
@@ -109,18 +176,17 @@ short hand operator.
109
176
Cross-referencing syntax
110
177
========================
111
178
112
-
Cross-references are generated by many semantic interpreted text roles.
179
+
Cross-references are generated by many semantically interpreted text roles.
113
180
Basically, you only need to write:
114
181
115
182
.. code-block:: rst
116
183
117
184
:role:`target`
118
185
119
-
And a link will be
120
-
created to the item named *target* of the type indicated by *role*. The link's
121
-
text will be the same as *target*.
186
+
And Sphinx creates a link to the item named *target* of the type indicated by *role*. The link's
187
+
text is the same as *target*.
122
188
123
-
You may supply an explicit title and reference target, like in reST direct
189
+
You can supply an explicit title and reference target, like in reST direct
124
190
hyperlinks:
125
191
126
192
.. code-block:: rst
@@ -142,6 +208,9 @@ Here are practical examples:
142
208
Section title
143
209
----------------------------------
144
210
211
+
Creating links between provider package docs
212
+
--------------------------------------------
213
+
145
214
Role ``:class:`` works well with references between packages. If you want to use other roles, it is a good idea to specify a package:
146
215
147
216
.. code-block:: rst
@@ -157,7 +226,41 @@ If you still feel confused then you can view more possible roles for our documen
157
226
158
227
For more information, see: `Cross-referencing syntax <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ in Sphinx documentation
159
228
229
+
Docs troubleshooting
230
+
====================
231
+
232
+
``example_dags`` Apache license
233
+
-------------------------------
234
+
235
+
If you are creating ``example_dags`` directory, you need to create an ``example_dags/__init__.py`` file. You can leave the file empty and the pre-commit processing
236
+
adds the license automatically. Otherwise, you can add a file with the Apache license or copy another ``__init__.py`` file that contains the necessary license.
237
+
238
+
Common Docs build errors
239
+
------------------------
240
+
241
+
.rst syntax is sensitive to whitespace, linebreaks, and indents, and can affect build output. When you write content and either
242
+
skip indentations, forget linebreaks, or leave trailing whitespace, it often produces docs build errors that block your PR's mergeability.
243
+
244
+
unexpected unindent
245
+
*******************
246
+
247
+
Certain Sphinx elements, like lists and code blocks, require a blank line between the element and the next part of the content.
248
+
If you do not add a blank line, it creates a build error.
249
+
250
+
.. code-block:: text
251
+
252
+
WARNING: Enumerated list ends without a blank line; unexpected unindent.
253
+
254
+
While easy to resolve, there's `a Sphinx bug <https://github.com/sphinx-doc/sphinx/issues/11026>`__ in certain versions that causes the
255
+
warning to report the wrong line in the file for your missing white space. If your PR has the ``unexpected unindent`` warning blocking your build,
256
+
and the line number it reports is wrong, this is a known error. You can find the missing blank space by searching for the syntax you used to make your
257
+
list, code block, or other whitespace-sensitive markup element.
258
+
160
259
Support
161
260
=======
162
261
163
-
If you need help, write to `#documentation <https://apache-airflow.slack.com/archives/CJ1LVREHX>`__ channel on `Airflow's Slack <https://s.apache.org/airflow-slack>`__
262
+
If you need help, write to `#documentation <https://apache-airflow.slack.com/archives/CJ1LVREHX>`__ channel on `Airflow's Slack <https://s.apache.org/airflow-slack>`__.
263
+
264
+
For more resources about working with Sphinx or reST markup syntax, see the `Sphinx documentation <https://www.sphinx-doc.org/en/master/usage/quickstart.html>`__.
265
+
266
+
The `Write the Docs <https://www.writethedocs.org/slack/>`__ community also includes a #Sphinx Slack channel for questions and additional support.
0 commit comments