Cross-referencing objects¶
- :syntax:grammar:¶
- :syntax:g:¶
Grammars are simply referenced by their name:
Reference to :syntax:g:`Json` grammar.
Example output
Reference to
Json
grammar.
- :syntax:rule:¶
- :syntax:r:¶
Rules can be referenced by their name when references appear within their grammar description. Otherwise, rules are referenced by full path which includes diagram name and rule name separated by a dot:
Reference to :syntax:r:`TargetGrammar.TargetRule`. .. syntax:grammar:: TargetGrammar Reference to :syntax:r:`TargetRule`. .. syntax:rule:: TargetRule
Example output
Reference to
TargetGrammar.TargetRule
.- grammar TargetGrammar¶
Reference to
TargetRule
.- TargetRule¶
If you specify a fully qualified object name, and would like to hide its prefix, you can add a tilde (
~
) to the object’s path:Reference to :syntax:r:`~TargetGrammar.TargetRule`.
Example output
Reference to
TargetRule
.When searching for a rule, Sphinx Syntax will first check the current grammar, then any imported grammar, and finally global namespace.
- :syntax:obj:¶
This is a universal role that searches for a rule first, then for a grammar.
Cross-referencing from diagrams¶
Diagram nodes will be linked to their rules automatically, as if using
syntax:rule
:
.. syntax:diagram::
"TargetGrammar.TargetRule"
Equivalent to :syntax:rule:`TargetGrammar.TargetRule`.
Example output
Equivalent to TargetGrammar.TargetRule
.
If href
option is given, then it is used as a target,
while node’s text is used as an explicit title:
.. syntax:diagram::
terminal: "TargetRule"
href: "TargetGrammar.TargetRule"
Equivalent to :syntax:rule:`TargetRule <TargetGrammar.TargetRule>`.
Example output
Equivalent to TargetRule
.
If resolve
option is set to false
, node is not linked:
.. syntax:diagram::
terminal: "TargetRule"
resolve: false
Node is not linked.
Example output
Node is not linked.