@@ -23,153 +23,229 @@ Objects
2323
2424 Grammars can't be nested, they also can't appear inside production rules.
2525
26- .. rst : directive :: .. syntax:rule:: name
26+ ** Options: **
2727
28- Directive for documenting production rules:
28+ .. rst:directive:option:: no-index
29+ no-index-entry
30+ no-contents-entry
31+ no-typesetting
2932
30- .. code-block :: rst
33+ The `standard Sphinx options`__ available to all object descriptions.
3134
32- .. syntax:rule:: MyRule
35+ __ https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup
3336
34- Description.
37+ .. rst:directive:option:: name: <text>
3538
36- .. dropdown :: Example output
39+ Sets a human readable name for a rule or a grammar.
3740
38- .. syntax : rule :: MyRule
39- :no-index:
41+ The primary name is used to refer to an object in documentation; it's used
42+ in HTML paths, anchors, and serves as a unique object identifier.
4043
41- Description.
44+ The human readable name is used to display object to a user; it's used
45+ when rendering documentation and cross-references.
4246
43- Rules can't be nested.
47+ **Example:**
4448
49+ .. code-block:: rst
4550
46- Parameters
47- ----------
51+ .. syntax:grammar:: PrimaryName
52+ :name: Human readable name
4853
49- All of the above directives accept the standard parameters:
54+ Notice that anchor for this grammar uses its primary name.
5055
51- .. rst:directive:option:: no-index
52- no-index-entry
53- no-contents-entry
54- no-typesetting
56+ When referring to an object, we use primary name: :syntax:g:`PrimaryName`.
57+ When this cross-reference is rendered, though,
58+ it will use a human readable name.
5559
56- The `standard Sphinx options`__ available to all object descriptions.
60+ .. dropdown:: Example output
5761
58- __ https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup
62+ .. syntax:grammar:: PrimaryName
63+ :name: Human readable name
64+ :no-index-entry:
65+ :no-contents-entry:
5966
60- .. rst:directive:option:: name: <text>
67+ Notice that anchor for this grammar uses its primary name.
6168
62- Sets a human readable name for a rule or a grammar.
69+ When referring to an object, we use primary name: :syntax:g:`PrimaryName`.
70+ When this cross-reference is rendered, though,
71+ it will use a human readable name.
6372
64- The primary name is used to refer to an object in documentation; it's used
65- in HTML paths, anchors, and serves as a unique object identifier.
73+ .. rst:directive:option:: imports: <list of diagram names>
6674
67- The human readable name is used to display object to a user; it's used
68- when rendering documentation and cross-references .
75+ If your parser generators allows importing grammars, you can use ``imports``
76+ option to specify which diagrams are imported from the documented one .
6977
70- **Example:**
78+ This will affect object resolution for cross-references and diagrams.
7179
72- .. code-block:: rst
80+ **Example:**
7381
74- .. syntax:grammar:: PrimaryName
75- :name: Human readable name
82+ .. code-block:: rst
7683
77- Notice that anchor for this grammar uses its primary name.
84+ .. syntax: grammar:: BaseGrammar
7885
79- When referring to an object, we use primary name: :syntax:g:`PrimaryName`.
80- When this cross-reference is rendered, though,
81- it will use a human readable name.
86+ .. syntax:rule:: BaseRule
8287
83- .. dropdown:: Example output
88+ .. syntax:grammar:: DownstreamGrammar
89+ :imports: BaseGrammar
8490
85- .. syntax:grammar:: PrimaryName
86- :name: Human readable name
91+ This grammar imports :syntax:g:`BaseGrammar`, so it can reference
92+ its rules without prefixing them with grammar name:
93+ :syntax:r:`BaseRule`.
8794
88- Notice that anchor for this grammar uses its primary name.
95+ This also works in diagrams:
8996
90- When referring to an object, we use primary name: :syntax:g:`PrimaryName`.
91- When this cross-reference is rendered, though,
92- it will use a human readable name.
97+ .. syntax:diagram:: BaseRule
9398
94- .. rst:directive:option:: imports: <list of diagram names>
99+ .. dropdown:: Example output
95100
96- If your parser generators allows importing grammars, you can use ``imports``
97- option to specify which diagrams are imported from the documented one.
101+ .. syntax:grammar:: BaseGrammar
102+ :no-index-entry:
103+ :no-contents-entry:
98104
99- This will affect object resolution for cross-references and diagrams.
105+ .. syntax:rule:: BaseRule
106+ :no-index-entry:
107+ :no-contents-entry:
100108
101- **Example:**
109+ .. syntax:grammar:: DownstreamGrammar
110+ :imports: BaseGrammar
111+ :no-index-entry:
112+ :no-contents-entry:
102113
103- .. code-block:: rst
114+ This grammar imports :syntax:g:`BaseGrammar`, so it can reference
115+ its rules without prefixing them with grammar name:
116+ :syntax:r:`BaseRule`.
104117
105- .. syntax:grammar:: BaseGrammar
118+ This also works in diagrams:
106119
107- .. syntax:rule :: BaseRule
120+ .. syntax:diagram :: BaseRule
108121
109- .. syntax:grammar:: DownstreamGrammar
110- :imports: BaseGrammar
122+ .. rst:directive:option:: root-rule: <rule> | <grammar>.<rule> | <path> <rule>
111123
112- This grammar imports :syntax:g:`BaseGrammar`, so it can reference
113- its rules without prefixing them with grammar name:
114- :syntax:r:`BaseRule`.
124+ Specifies root rule of the diagram.
115125
116- This also works in diagrams :
126+ Setting a root rule has two effects :
117127
118- .. syntax:diagram:: BaseRule
128+ 1. If :rst:dir:`mark-root-rule <syntax:grammar:mark-root-rule>` is enabled,
129+ syntax diagrams for the root rule will use use complex line endings,
130+ while syntax diagrams for all other rules will use simple ones.
119131
120- .. dropdown:: Example output
132+ 2. :rst:dir:`syntax:autogrammar` will not display rules that aren't reachable
133+ from the root rule.
121134
122- .. syntax:grammar:: BaseGrammar
135+ See :rst:dir:`example in syntax:autogrammar <syntax:autogrammar:root-rule>`.
123136
124- .. syntax:rule:: BaseRule
137+ The value should be either name of a rule from the grammar that’s
138+ being documented, a grammar name and a rule name separated by a dot,
139+ or a grammar file and a rule name separated by a space.
125140
126- .. syntax:grammar:: DownstreamGrammar
127- :imports: BaseGrammar
141+ .. rst:directive:option:: mark-root-rule
142+ no-mark-root-rule
128143
129- This grammar imports :syntax:g:`BaseGrammar`, so it can reference
130- its rules without prefixing them with grammar name:
131- : syntax:r:`BaseRule` .
144+ If enabled, diagrams in the :rst:dir:`root-rule <syntax:autogrammar:root-rule>`
145+ will use complex line endings, while diagrams in other rules will use simple ones
146+ (see :rst:dir:`end-class < syntax:diagram:end-class>`) .
132147
133- This also works in diagrams:
148+ With this option turned off, :rst:dir:`root-rule <syntax:grammar:root-rule>`
149+ only affects how :rst:dir:`syntax:autogrammar` filters displayed rules.
134150
135- .. syntax:diagram:: BaseRule
151+ .. rst:directive:option:: diagrams
152+ no-diagrams
153+ cc-to-dash
154+ no-cc-to-dash
155+ bison-c-char-literals
156+ no-bison-c-char-literals
157+ literal-rendering
136158
137- .. rst:directive:option:: diagram-*
159+ Same as corresponding options from : rst:dir:`syntax:autogrammar`.
138160
139- You can add any option from :rst:dir:`syntax:diagram` to an object description
140- by prefixing it with ``diagram-``. This option will be used in all diagrams
141- that appear within object's description .
161+ When used on :rst:dir:`syntax:grammar`, these options override defaults
162+ for any nested :rst:dir:`syntax:autorule`, :rst:dir:`syntax:lexer-diagram`
163+ or :rst:dir:`syntax:parser-diagram` .
142164
143- **Example:* *
165+ .. rst:directive:option:: diagram- *
144166
145- .. code-block:: rst
167+ These options override defaults for any :rst:dir:`syntax:diagram`
168+ used within this grammar.
146169
147- .. syntax:grammar:: MyGrammar
148- :diagram-end-class: simple
170+ **Example:**
171+
172+ .. code-block:: rst
173+
174+ .. syntax:grammar:: MyGrammar
175+ :diagram-end-class: simple
176+
177+ All diagrams in this grammar will use simple end class:
178+
179+ .. syntax:diagram:: Simple end class
149180
150- All diagrams in this grammar will use simple end class :
181+ Unless they override it manually :
151182
152- .. syntax:diagram:: Simple end class
183+ .. syntax:diagram:: Complex end class
184+ :end-class: complex
185+
186+ .. dropdown:: Example output
187+
188+ .. syntax:grammar:: MyGrammar
189+ :no-index:
190+ :diagram-end-class: simple
191+
192+ All diagrams in this grammar will use simple end class:
193+
194+ .. syntax:diagram:: Simple end class
195+
196+ Unless they override it manually:
197+
198+ .. syntax:diagram:: Complex end class
199+ :end-class: complex
200+
201+
202+ .. rst :directive :: .. syntax:rule:: name
203+
204+ Directive for documenting production rules:
205+
206+ .. code-block :: rst
153207
154- Unless they override it manually:
208+ .. syntax:rule:: MyRule
155209
156- .. syntax:diagram:: Complex end class
157- :end-class: complex
210+ Description.
158211
159212 .. dropdown :: Example output
160213
161- .. syntax:grammar :: MyGrammar
214+ .. syntax :rule :: MyRule
162215 :no-index:
163- :diagram-end-class: simple
164216
165- All diagrams in this grammar will use simple end class:
217+ Description.
218+
219+ Rules can't be nested.
220+
221+ **Options: **
222+
223+ .. rst:directive:option:: no-index
224+ no-index-entry
225+ no-contents-entry
226+ no-typesetting
227+
228+ The `standard Sphinx options`__ available to all object descriptions.
229+
230+ __ https://www.sphinx-doc.org/en/master/usage/domains/index.html#basic-markup
166231
167- .. syntax:diagram:: Simple end class
232+ .. rst:directive:option:: name: <text>
168233
169- Unless they override it manually:
234+ Sets a human readable name for a rule or a grammar.
170235
171- .. syntax:diagram:: Complex end class
172- :end-class: complex
236+ See :rst:dir:`syntax:grammar:name` for more info.
237+
238+ .. rst:directive:option:: diagram-*
239+ diagrams
240+ no-diagrams
241+ cc-to-dash
242+ no-cc-to-dash
243+ bison-c-char-literals
244+ no-bison-c-char-literals
245+ literal-rendering
246+
247+ Same as corresponding options from :rst:dir:`syntax:grammar`
248+ and :rst:dir:`syntax:autogrammar`.
173249
174250
175251 Diagrams
@@ -317,7 +393,7 @@ but allows less customization.
317393
318394 .. syntax :lexer-diagram :: ('+' | '-')? ([1-9][0-9]* | '0')
319395
320- **Options **
396+ **Options: **
321397
322398 All options from the :rst:dir: `syntax:diagram ` directive ara available,
323399 as well as :rst:dir: `syntax:autogrammar:cc-to-dash `
@@ -345,7 +421,7 @@ but allows less customization.
345421 '*' | expression (AS row_name)? (',' expression (AS row_name)?)*
346422 )
347423
348- **Options **
424+ **Options: **
349425
350426 All options from the :rst:dir: `syntax:diagram ` directive ara available,
351427 as well as :rst:dir: `syntax:autogrammar:cc-to-dash `
0 commit comments