Skip to content

Commit 88424a2

Browse files
StaticRocketcshilwant
authored andcommitted
docs(contributing): add section for ifconfig behavior
I've seen a lot of confusion around this lately, and there are still a lot of examples of bad ifconfig usage in the documentation. Add a section to try and clarify ifconfig behavior. Signed-off-by: Randolph Sapp <rs@ti.com>
1 parent 94fce17 commit 88424a2

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,50 @@ directive](https://www.sphinx-doc.org/en/master/usage/extensions/ifconfig.html).
110110
Not all parsers will respect this directive, so be sure to try compiling the
111111
documentation for a platform that matches the ifconfig prior to submitting a PR.
112112

113+
#### Behavior
114+
115+
You cannot use the ifconfig directive to avoid parsing other directives,
116+
sections, or other RST components. The ifconfig directive acts as a standard RST
117+
directive where content under it is conditionally masked in the final document
118+
output.
119+
120+
Sphinx functionally has 2 main processing steps. The first path takes care of
121+
substitutions, role and directive definitions, sections, and references. The
122+
second pass actually processes the directives and other RST structures. Because
123+
of this, RST underneath an ifconfig will be evaluated whether or not it visible
124+
in the final document output.
125+
126+
In some cases, this can change the behavior of external components if they are
127+
handled by the first processing step. For example, given the following snippet:
128+
129+
```rst
130+
.. ifconfig:: CONFIG_part_variant in ('J721S2')
131+
132+
Content
133+
134+
.. |REPLACE_A| replace:: replace_b
135+
136+
|REPLACE_A|
137+
```
138+
139+
When `CONFIG_part_variant` is `J721S2` you may correctly expect the following to
140+
be rendered:
141+
142+
```
143+
Content
144+
replace_b
145+
```
146+
147+
The disconnect comes in when `CONFIG_part_variant` is `J784S4`. The replacement
148+
will still be defined and included into the main state machine that handles
149+
refs, replacements, and other key directives regardless of whether the content
150+
is displayed in the final document output. The following is the output generated
151+
in this case:
152+
153+
```
154+
replace_b
155+
```
156+
113157
## Licensing
114158

115159
### Community

0 commit comments

Comments
 (0)