Skip to content

Commit 690d6e2

Browse files
authored
Add more info to Docs README (apache#36287)
1 parent b0db1f9 commit 690d6e2

File tree

2 files changed

+132
-27
lines changed

2 files changed

+132
-27
lines changed

CONTRIBUTING.rst

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ Airflow could always use better documentation, whether as part of the official
102102
Airflow docs, in docstrings, ``docs/*.rst`` or even on the web as blog posts or
103103
articles.
104104

105+
See the `Docs README <https://github.com/apache/airflow/blob/main/docs/README.rst>`__ for more information about contributing to Airflow docs.
106+
105107
Submit Feedback
106108
---------------
107109

docs/README.rst

+130-27
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,125 @@
1818
Documentation
1919
#############
2020

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.
2224

2325
Development documentation preview
2426
==================================
2527

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.
55+
56+
+--------------------------------------+------------------+-------------------------------------------------+
57+
| Type of Docs update | Suggested Editor | Explanation |
58+
+======================================+==================+=================================================+
59+
| I need to edit multiple files. | Local Editor | It's easier to batch-edit files in an editor, |
60+
| | | than make multiple PRs or changes to individual |
61+
| | | files in a GitHub editor. |
62+
+--------------------------------------+------------------+-------------------------------------------------+
63+
| I want to fix a quick typo or a | GitHub Editor | Allows you to quickly edit without any local |
64+
| broken link. | | installation or build required. |
65+
+--------------------------------------+------------------+-------------------------------------------------+
66+
| My edits contain tables or | Local Editor | GitHub can provide Markdown previews, but might |
67+
| other formatting changes. | | change ``.rst`` styling. Use a local build. |
68+
+--------------------------------------+------------------+-------------------------------------------------+
69+
| I want to make a new page/ | Local Editor | Will need a local build to check navigation and |
70+
| delete a page. | | link redirects. |
71+
+--------------------------------------+------------------+-------------------------------------------------+
72+
| I want to edit autogenerated content | Either, probably | Allows you to easily find the correct file and |
73+
| on a page. | Local Editor | generate a preview before creating the PR. |
74+
+--------------------------------------+------------------+-------------------------------------------------+
75+
76+
Finding source content to edit
77+
------------------------------
78+
79+
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.
2787

2888
Building documentation
2989
======================
3090

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>`_.
3292

3393
The documentation build consists of verifying consistency of documentation and two steps:
3494

3595
* spell checking
3696
* building documentation
3797

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:
39101

40102
.. code-block:: bash
41103
42104
breeze build-docs
43105
44-
or just to run spell-check
106+
Just run spellcheck:
45107

46108
.. code-block:: bash
47109
48110
breeze build-docs --spellcheck-only
49111
50-
or just to run documentation building
112+
Build docs without checking spelling:
51113

52114
.. code-block:: bash
53115
54116
breeze build-docs --docs-only
55117
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:
57125

58126
.. code-block:: bash
59127
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
61135
62136
You can also use shorthand names as arguments instead of using the full names
63137
for airflow providers. To find the short hand names, follow the instructions in :ref:`generating_short_form_names`.
64138

65-
You can also see all the available arguments via ``--help``.
139+
You can see all the available arguments via ``--help``.
66140

67141
.. code-block:: bash
68142
@@ -71,26 +145,19 @@ You can also see all the available arguments via ``--help``.
71145
Running the Docs Locally
72146
------------------------
73147

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.
76150

77-
Alternatively, run the following command from the root directory.
78151
You need to have Python installed to run the command:
79152

80153
.. code-block:: bash
81154
82155
docs/start_doc_server.sh
83156
84157
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.
94161

95162
.. _generating_short_form_names:
96163

@@ -109,18 +176,17 @@ short hand operator.
109176
Cross-referencing syntax
110177
========================
111178

112-
Cross-references are generated by many semantic interpreted text roles.
179+
Cross-references are generated by many semantically interpreted text roles.
113180
Basically, you only need to write:
114181

115182
.. code-block:: rst
116183
117184
:role:`target`
118185
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*.
122188

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
124190
hyperlinks:
125191

126192
.. code-block:: rst
@@ -142,6 +208,9 @@ Here are practical examples:
142208
Section title
143209
----------------------------------
144210
211+
Creating links between provider package docs
212+
--------------------------------------------
213+
145214
Role ``:class:`` works well with references between packages. If you want to use other roles, it is a good idea to specify a package:
146215

147216
.. code-block:: rst
@@ -157,7 +226,41 @@ If you still feel confused then you can view more possible roles for our documen
157226
158227
For more information, see: `Cross-referencing syntax <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ in Sphinx documentation
159228

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+
160259
Support
161260
=======
162261

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

Comments
 (0)