Skip to content

Commit 9e30d95

Browse files
authored
Merge pull request #68 from edx/robrap/ARCHBOM-1721-how-to-annotate-settings
ARCHBOM-1721: docs: add how-to docs for settings and new annotations
2 parents 2aae8df + 6d24f91 commit 9e30d95

5 files changed

Lines changed: 109 additions & 3 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def get_version(*file_paths):
470470
'python': ('https://docs.python.org/3.6', None),
471471
'django': ('https://docs.djangoproject.com/en/1.11/', 'https://docs.djangoproject.com/en/1.11/_objects/'),
472472
'model_utils': ('https://django-model-utils.readthedocs.io/en/latest/', None),
473+
'edx_toggles': ('https://edx.readthedocs.io/projects/edx-toggles/en/latest/', None),
473474
}
474475

475476

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
**********************************************
2+
How to: Add new annotations and extracted docs
3+
**********************************************
4+
5+
.. contents::
6+
:depth: 1
7+
:local:
8+
9+
Example annotations and automated docs
10+
======================================
11+
12+
Annotations are a great way to keep documentation close to the code, but also be able to extract into documentation to be published on Readthedocs.
13+
14+
As an example, we have added `feature toggle annotations to the edx-platform codebase`_. A `Readthedocs document with the edx-platform feature toggles`_ has been generated from them.
15+
16+
.. _feature toggle annotations to the edx-platform codebase: https://github.com/edx/edx-platform/search?q=toggle_name
17+
.. _Readthedocs document with the edx-platform feature toggles: https://edx.readthedocs.io/projects/edx-platform-technical/en/latest/featuretoggles.html
18+
19+
Add your own annotations and docs
20+
=================================
21+
22+
The following steps need to be performed to document new types of annotations in edx-platform. Adapt the final steps as appropriate for other services.
23+
24+
* Define a `new annotation format in code_annotations/contrib/config`_. See the feature toggle annotations as an example.
25+
* Create a `Sphinx extension to collect these annotations`_. You can base it on the featuretoggles and settings extensions.
26+
* Read and update :doc:`../sphinx_extensions`.
27+
* Add a new documentation page in the `edx-platform technical docs that will use this Sphinx extension`_. Adapt this step as needed for other services.
28+
* As required, add `custom linting for the new annotations to edx-lint`_. Again, follow the toggle and setting checkers as examples.
29+
30+
.. _new annotation format in code_annotations/contrib/config: https://github.com/edx/code-annotations/tree/master/code_annotations/contrib/config
31+
.. _Sphinx extension to collect these annotations: https://github.com/edx/code-annotations/tree/master/code_annotations/contrib/sphinx/extensions
32+
.. _edx-platform technical docs that will use this Sphinx extension: https://github.com/edx/edx-platform/tree/master/docs/technical
33+
.. _custom linting for the new annotations to edx-lint: https://github.com/edx/edx-lint/blob/master/edx_lint/pylint/annotations_check.py
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
***********************************
2+
How to: Documenting Django settings
3+
***********************************
4+
5+
.. contents::
6+
:depth: 1
7+
:local:
8+
9+
Types of Django Settings
10+
========================
11+
12+
For documentation purposes, in the Open edX codebase there are two types of Django settings:
13+
14+
* Non-boolean Django settings.
15+
* Boolean Django settings, also known as feature toggles.
16+
17+
This how-to is concerned with the non-boolean Django settings. For boolean Django settings, or feature toggles, read :doc:`how-to document feature toggles <edx_toggles:how_to/documenting_new_feature_toggles>` instead.
18+
19+
The documentation of Django settings is a crucial source of information for a very wide audience, including Open edX operators, product owners and developers. The documentation will be available to developers directly in code, and extracted into a human-readable document to be used by all audiences, and especially for Open edX operators.
20+
21+
Please keep all of these audiences in mind when crafting your documentation.
22+
23+
Example Documentation
24+
=====================
25+
26+
Boilerplate template
27+
--------------------
28+
29+
Copy-paste this boilerplate template to document a Django setting::
30+
31+
# .. setting_name: SOME_SETTING_NAME
32+
# .. setting_default: Replace this with the default (non-boolean) value of the setting.
33+
# .. setting_description: Add here a detailed description of the purpose and usage of this setting.
34+
# Note that all annotations can be spread over multiple lines by prefixing every line after the first by
35+
# at least three spaces (two spaces plus the leading space).
36+
# .. setting_warning: (Optional) Add here additional instructions that users should be aware of. For instance, dependency
37+
# on additional settings or feature toggles should be referenced here. If this field is not needed, simply remove it.
38+
SOME_SETTING_NAME = ...
39+
40+
If you have a dict of settings, you can use the following example::
41+
42+
# .. setting_name: SOME_SETTING_DICT_NAME
43+
# .. setting_default: dict of settings
44+
# .. setting_description: First provide a general description about all the settings in the dict. Then include a sentence like:
45+
# See SOME_SETTING_DICT_NAME[XXX] documentation for details of each setting.
46+
SOME_SETTING_DICT_NAME = dict(
47+
48+
# .. setting_name: SOME_SETTING_DICT_NAME['SOME_SETTING_NAME']
49+
# ... # See docs above for the other setting annotations.
50+
SOME_SETTING_NAME = ...,
51+
52+
)
53+
54+
Additional details
55+
==================
56+
57+
There are a variety of tips in `certain sections of the how-to for documenting feature toggles`_, that are applicable to documenting non-boolean Django settings as well, but are not duplicated in this document. We recommend you get familiar with the applicable subsections of "Additional details" and "Documenting legacy feature toggles" from the feature toggle how-to.
58+
59+
.. _certain sections of the how-to for documenting feature toggles: https://edx.readthedocs.io/projects/edx-toggles/en/latest/how_to/documenting_new_feature_toggles.html#additional-details
60+
61+
Additional resources
62+
====================
63+
64+
The documentation format used to annotate non-boolean Django settings is also available from code-annotations repository: `setting_annotations.yaml <https://github.com/edx/code-annotations/blob/master/code_annotations/contrib/config/setting_annotations.yaml>`__.
File renamed without changes.

docs/index.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@ Contents:
1111

1212
.. toctree::
1313
:maxdepth: 2
14+
:caption: General
1415

15-
readme
16+
README <readme>
1617
getting_started
1718
writing_annotations
1819
static_search
1920
django_search
2021
configuration
21-
sphinx_extensions
2222
extensions
2323
testing
24-
modules
24+
Package Reference <modules>
2525
changelog
2626

27+
.. toctree::
28+
:maxdepth: 2
29+
:caption: Contrib Code
30+
31+
decisions/0001-config-and-tools
32+
contrib/how_to/add_new_annotations_and_extracted_docs
33+
contrib/sphinx_extensions
34+
contrib/how_to/documenting_django_settings
2735

2836
Indices and tables
2937
==================

0 commit comments

Comments
 (0)