Skip to content

Commit 9bbd946

Browse files
committed
implement rst role
1 parent 534026d commit 9bbd946

File tree

4 files changed

+31
-50
lines changed

4 files changed

+31
-50
lines changed

docs/.rstcheck.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[rstcheck]
22
ignore_directives=automodule,http:get,tabs,tab
3-
ignore_roles=djangosetting,setting
3+
ignore_roles=djangosetting,setting,featureflags
44
ignore_messages=(Duplicate implicit target name: ".*")|(Hyperlink target ".*" is not referenced)

docs/doc_extensions.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from django.conf import settings
1414

15+
from readthedocs.projects.models import Feature
16+
1517

1618
def django_setting_role(typ, rawtext, text, lineno, inliner, options=None,
1719
content=None):
@@ -21,9 +23,31 @@ def django_setting_role(typ, rawtext, text, lineno, inliner, options=None,
2123
return [node], []
2224

2325

26+
def feature_flags_role(typ, rawtext, text, lineno, inliner, options=None,
27+
content=None):
28+
"""Up to date feature flags from the application."""
29+
features_dict = {}
30+
for feature in Feature.FEATURES:
31+
features_dict[feature[0].upper()] = feature[1].capitalize()
32+
dl = nodes.definition_list()
33+
for feature, desc in features_dict.items():
34+
term = nodes.term(text=feature)
35+
definition = nodes.definition(text=desc)
36+
dli = nodes.definition_list_item(term=term, definition=definition)
37+
dl.append(dli)
38+
return [dl], []
39+
40+
2441
def setup(_):
2542
from docutils.parsers.rst import roles
26-
roles.register_local_role('djangosetting', django_setting_role)
43+
roles.register_local_role(
44+
'djangosetting',
45+
django_setting_role
46+
)
47+
roles.register_local_role(
48+
'featureflags',
49+
feature_flags_role
50+
)
2751

2852
return {
2953
'version': 'builtin',

docs/faq.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ environment, and will be set to ``True`` when building on RTD::
6565
{% endif %}
6666

6767
My project requires different settings than those available under Admin
68-
--------------------------------------------------------------------------
68+
-----------------------------------------------------------------------
6969

70-
Read the Docs offers additional flag settings. To enable these settings,
70+
Read the Docs offers some settings which can be used for a variety of purposes,
71+
such as to use the latest version of sphinx or pip. To enable these settings,
7172
please open a request issue on our `github`_ and we will change the settings for the project.
72-
Read more about these flag settings :doc:`here <guides/feature-flags>`.
73+
Read more about these settings :doc:`here <guides/feature-flags>`.
7374

7475
.. _github: https://github.com/rtfd/readthedocs.org
7576

docs/guides/feature-flags.rst

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,4 @@ or disable one or more of these featured flags for a particular project.
1212
Available Flags
1313
---------------
1414

15-
USE_SPHINX_LATEST:
16-
~~~~~~~~~~~~~~~~~~
17-
18-
Use latest version of Sphinx in building the project.
19-
20-
USE_SETUPTOOLS_LATEST:
21-
~~~~~~~~~~~~~~~~~~~~~~
22-
23-
Use latest version of setuptools in building the project.
24-
25-
ALLOW_DEPRECATED_WEBHOOKS:
26-
~~~~~~~~~~~~~~~~~~~~~~~~~~
27-
28-
Allow deprecated webhook views.
29-
30-
PIP_ALWAYS_UPGRADE:
31-
~~~~~~~~~~~~~~~~~~~
32-
33-
Always run:
34-
35-
.. code-block:: bash
36-
37-
pip install --upgrade
38-
39-
before building the project.
40-
41-
SKIP_SUBMODULES:
42-
~~~~~~~~~~~~~~~~
43-
44-
Skip git submodule checkout.
45-
46-
DONT_OVERWRITE_SPHINX_CONTEXT:
47-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48-
49-
Do not overwrite context vars in conf.py with Read the Docs context.
50-
51-
ALLOW_V2_CONFIG_FILE:
52-
~~~~~~~~~~~~~~~~~~~~~
53-
54-
Allow to use the v2 of the configuration file.
55-
56-
MKDOCS_THEME_RTD:
57-
~~~~~~~~~~~~~~~~~
58-
59-
Use Read the Docs theme for MkDocs as default theme.
15+
:featureflags:

0 commit comments

Comments
 (0)