2 # SPDX_License-Identifier: MIT
4 # Copyright (C) 2018 Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
9 // To document the instructions used in the intermediate representation
10 // a new domain is defined: 'ir' with a directive::
13 // <description of OP_NAME>
16 // This is equivalent to using a definition list but with the name
17 // also placed in the index (with 'IR instruction' as descriptions).
24 class IROpDirective(docutils
.parsers
.rst
.Directive
):
26 # use the first line of content as the argument, this allow
27 # to not have to write a blanck line after the directive
28 final_argument_whitespace
= True
30 #optional_arguments = 0
36 self
.env
= self
.state
.document
.settings
.env
38 source
= self
.state
.document
43 node
= docutils
.nodes
.section()
44 node
['ids'].append(name
)
45 node
.document
= source
47 index
= '.. index:: pair: %s; IR instruction' % name
48 content
= docutils
.statemachine
.ViewList()
49 content
.append(index
, source
, lineno
)
50 content
.append('' , source
, lineno
)
51 content
.append(name
, source
, lineno
)
52 content
.append('' , source
, lineno
)
53 self
.state
.nested_parse(content
, self
.content_offset
, node
)
55 defnode
= docutils
.nodes
.definition()
56 self
.state
.nested_parse(text
[1:], self
.content_offset
, defnode
)
61 class IRDomain(sphinx
.domains
.Domain
):
67 app
.add_domain(IRDomain
)
68 app
.add_directive_to_domain('ir', 'op', IROpDirective
)
72 'parallel_read_safe': True,