sphinx-aimms-theme 0.1.48__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. sphinx_aimms_theme/AIMMSDomain.py +623 -0
  2. sphinx_aimms_theme/AIMMSLexer.py +167 -0
  3. sphinx_aimms_theme/AIMMSspellingFilters.py +12 -0
  4. sphinx_aimms_theme/__init__.py +35 -0
  5. sphinx_aimms_theme/breadcrumbs.html +58 -0
  6. sphinx_aimms_theme/footer.html +41 -0
  7. sphinx_aimms_theme/layout.html +176 -0
  8. sphinx_aimms_theme/searchbox.html +11 -0
  9. sphinx_aimms_theme/spelling_wordlist.txt +539 -0
  10. sphinx_aimms_theme/static/AIMMS_logo_BlackWhite-PRINT-900x508.jpg +0 -0
  11. sphinx_aimms_theme/static/AIMMS_logo_H_RGB.png +0 -0
  12. sphinx_aimms_theme/static/AIMMS_logo_S_RGB.png +0 -0
  13. sphinx_aimms_theme/static/aimms_css/styles.css +1014 -0
  14. sphinx_aimms_theme/static/copycode.js +130 -0
  15. sphinx_aimms_theme/static/favicon.ico +0 -0
  16. sphinx_aimms_theme/static/icons/100.jpg +0 -0
  17. sphinx_aimms_theme/static/icons/105.png +0 -0
  18. sphinx_aimms_theme/static/icons/11.png +0 -0
  19. sphinx_aimms_theme/static/icons/110.png +0 -0
  20. sphinx_aimms_theme/static/icons/111.png +0 -0
  21. sphinx_aimms_theme/static/icons/12.png +0 -0
  22. sphinx_aimms_theme/static/icons/13.png +0 -0
  23. sphinx_aimms_theme/static/icons/14.png +0 -0
  24. sphinx_aimms_theme/static/icons/140.png +0 -0
  25. sphinx_aimms_theme/static/icons/141.png +0 -0
  26. sphinx_aimms_theme/static/icons/145.png +0 -0
  27. sphinx_aimms_theme/static/icons/15 (1).png +0 -0
  28. sphinx_aimms_theme/static/icons/15.png +0 -0
  29. sphinx_aimms_theme/static/icons/150.png +0 -0
  30. sphinx_aimms_theme/static/icons/152.png +0 -0
  31. sphinx_aimms_theme/static/icons/16.png +0 -0
  32. sphinx_aimms_theme/static/icons/160.png +0 -0
  33. sphinx_aimms_theme/static/icons/161.png +0 -0
  34. sphinx_aimms_theme/static/icons/162.png +0 -0
  35. sphinx_aimms_theme/static/icons/163.png +0 -0
  36. sphinx_aimms_theme/static/icons/168.png +0 -0
  37. sphinx_aimms_theme/static/icons/170.png +0 -0
  38. sphinx_aimms_theme/static/icons/172.png +0 -0
  39. sphinx_aimms_theme/static/icons/175.png +0 -0
  40. sphinx_aimms_theme/static/icons/176.png +0 -0
  41. sphinx_aimms_theme/static/icons/180.png +0 -0
  42. sphinx_aimms_theme/static/icons/181.png +0 -0
  43. sphinx_aimms_theme/static/icons/200.png +0 -0
  44. sphinx_aimms_theme/static/icons/201.png +0 -0
  45. sphinx_aimms_theme/static/icons/202.png +0 -0
  46. sphinx_aimms_theme/static/icons/203.png +0 -0
  47. sphinx_aimms_theme/static/icons/204.png +0 -0
  48. sphinx_aimms_theme/static/icons/205.png +0 -0
  49. sphinx_aimms_theme/static/icons/205a.png +0 -0
  50. sphinx_aimms_theme/static/icons/205b.png +0 -0
  51. sphinx_aimms_theme/static/icons/207.png +0 -0
  52. sphinx_aimms_theme/static/icons/208.png +0 -0
  53. sphinx_aimms_theme/static/icons/210.png +0 -0
  54. sphinx_aimms_theme/static/icons/210b.png +0 -0
  55. sphinx_aimms_theme/static/icons/211.png +0 -0
  56. sphinx_aimms_theme/static/icons/212.png +0 -0
  57. sphinx_aimms_theme/static/icons/3000.png +0 -0
  58. sphinx_aimms_theme/static/icons/301.png +0 -0
  59. sphinx_aimms_theme/static/icons/302.png +0 -0
  60. sphinx_aimms_theme/static/icons/303.png +0 -0
  61. sphinx_aimms_theme/static/icons/304.png +0 -0
  62. sphinx_aimms_theme/static/icons/961.png +0 -0
  63. sphinx_aimms_theme/static/icons/962.png +0 -0
  64. sphinx_aimms_theme/static/icons/963.png +0 -0
  65. sphinx_aimms_theme/static/icons/964.png +0 -0
  66. sphinx_aimms_theme/static/icons/965.png +0 -0
  67. sphinx_aimms_theme/static/icons/966.png +0 -0
  68. sphinx_aimms_theme/static/icons/ClosedNodeModelExplorer.PNG +0 -0
  69. sphinx_aimms_theme/static/icons/DeclarationSectionIcon.PNG +0 -0
  70. sphinx_aimms_theme/static/icons/FunctionIcon.PNG +0 -0
  71. sphinx_aimms_theme/static/icons/GuiAxProp.png +0 -0
  72. sphinx_aimms_theme/static/icons/IDECheckLeave.PNG +0 -0
  73. sphinx_aimms_theme/static/icons/IDESaveAll.PNG +0 -0
  74. sphinx_aimms_theme/static/icons/IconDirty.jpg +0 -0
  75. sphinx_aimms_theme/static/icons/MEDeclActivity.PNG +0 -0
  76. sphinx_aimms_theme/static/icons/MEDeclArc.PNG +0 -0
  77. sphinx_aimms_theme/static/icons/MEDeclAssertion.PNG +0 -0
  78. sphinx_aimms_theme/static/icons/MEDeclCal.PNG +0 -0
  79. sphinx_aimms_theme/static/icons/MEDeclComplVar.PNG +0 -0
  80. sphinx_aimms_theme/static/icons/MEDeclCon.PNG +0 -0
  81. sphinx_aimms_theme/static/icons/MEDeclConvention.PNG +0 -0
  82. sphinx_aimms_theme/static/icons/MEDeclDatabaseTable.PNG +0 -0
  83. sphinx_aimms_theme/static/icons/MEDeclElemPar.PNG +0 -0
  84. sphinx_aimms_theme/static/icons/MEDeclElementVariable.PNG +0 -0
  85. sphinx_aimms_theme/static/icons/MEDeclFile.PNG +0 -0
  86. sphinx_aimms_theme/static/icons/MEDeclHandle.PNG +0 -0
  87. sphinx_aimms_theme/static/icons/MEDeclIndex.PNG +0 -0
  88. sphinx_aimms_theme/static/icons/MEDeclMP.PNG +0 -0
  89. sphinx_aimms_theme/static/icons/MEDeclMacro.PNG +0 -0
  90. sphinx_aimms_theme/static/icons/MEDeclNode.PNG +0 -0
  91. sphinx_aimms_theme/static/icons/MEDeclOther.PNG +0 -0
  92. sphinx_aimms_theme/static/icons/MEDeclPar.PNG +0 -0
  93. sphinx_aimms_theme/static/icons/MEDeclQnt.PNG +0 -0
  94. sphinx_aimms_theme/static/icons/MEDeclQuantity.PNG +0 -0
  95. sphinx_aimms_theme/static/icons/MEDeclResource.PNG +0 -0
  96. sphinx_aimms_theme/static/icons/MEDeclSet.PNG +0 -0
  97. sphinx_aimms_theme/static/icons/MEDeclStringPar.PNG +0 -0
  98. sphinx_aimms_theme/static/icons/MEDeclUncerConst.PNG +0 -0
  99. sphinx_aimms_theme/static/icons/MEDeclUnitPar.PNG +0 -0
  100. sphinx_aimms_theme/static/icons/MEDeclVar.PNG +0 -0
  101. sphinx_aimms_theme/static/icons/MEInsertHere.PNG +0 -0
  102. sphinx_aimms_theme/static/icons/OpenNodeModelExplorer.PNG +0 -0
  103. sphinx_aimms_theme/static/icons/ProcedureIcon.PNG +0 -0
  104. sphinx_aimms_theme/static/icons/SectionIcon.PNG +0 -0
  105. sphinx_aimms_theme/static/icons/activeXIcons.png +0 -0
  106. sphinx_aimms_theme/static/icons/aimms-uncompressed.jpg +0 -0
  107. sphinx_aimms_theme/static/icons/apply.jpg +0 -0
  108. sphinx_aimms_theme/static/icons/apply.png +0 -0
  109. sphinx_aimms_theme/static/icons/attrdata.jpg +0 -0
  110. sphinx_aimms_theme/static/icons/attrdown.jpg +0 -0
  111. sphinx_aimms_theme/static/icons/attribdn.png +0 -0
  112. sphinx_aimms_theme/static/icons/attribup.png +0 -0
  113. sphinx_aimms_theme/static/icons/attrmnmx.jpg +0 -0
  114. sphinx_aimms_theme/static/icons/attrprnt.jpg +0 -0
  115. sphinx_aimms_theme/static/icons/attrup.jpg +0 -0
  116. sphinx_aimms_theme/static/icons/bitmap15.png +0 -0
  117. sphinx_aimms_theme/static/icons/bitmap310.png +0 -0
  118. sphinx_aimms_theme/static/icons/blend1.png +0 -0
  119. sphinx_aimms_theme/static/icons/blend2.png +0 -0
  120. sphinx_aimms_theme/static/icons/blend3.png +0 -0
  121. sphinx_aimms_theme/static/icons/blend4.png +0 -0
  122. sphinx_aimms_theme/static/icons/blend5.png +0 -0
  123. sphinx_aimms_theme/static/icons/browse.jpg +0 -0
  124. sphinx_aimms_theme/static/icons/btnadd.jpg +0 -0
  125. sphinx_aimms_theme/static/icons/btndel.jpg +0 -0
  126. sphinx_aimms_theme/static/icons/btndel.png +0 -0
  127. sphinx_aimms_theme/static/icons/btnplus.png +0 -0
  128. sphinx_aimms_theme/static/icons/busy.jpg +0 -0
  129. sphinx_aimms_theme/static/icons/cancel.jpg +0 -0
  130. sphinx_aimms_theme/static/icons/cancel.png +0 -0
  131. sphinx_aimms_theme/static/icons/check.jpg +0 -0
  132. sphinx_aimms_theme/static/icons/check.png +0 -0
  133. sphinx_aimms_theme/static/icons/chkclose.jpg +0 -0
  134. sphinx_aimms_theme/static/icons/chkclose.png +0 -0
  135. sphinx_aimms_theme/static/icons/copy.png +0 -0
  136. sphinx_aimms_theme/static/icons/copyinto.png +0 -0
  137. sphinx_aimms_theme/static/icons/copytext.png +0 -0
  138. sphinx_aimms_theme/static/icons/debugbreak.jpg +0 -0
  139. sphinx_aimms_theme/static/icons/debugstack.jpg +0 -0
  140. sphinx_aimms_theme/static/icons/default.jpg +0 -0
  141. sphinx_aimms_theme/static/icons/delfolder.jpg +0 -0
  142. sphinx_aimms_theme/static/icons/delfoldr.png +0 -0
  143. sphinx_aimms_theme/static/icons/delta.png +0 -0
  144. sphinx_aimms_theme/static/icons/dockIcons.png +0 -0
  145. sphinx_aimms_theme/static/icons/drag_rmo.png +0 -0
  146. sphinx_aimms_theme/static/icons/error.jpg +0 -0
  147. sphinx_aimms_theme/static/icons/externalprocedure.png +0 -0
  148. sphinx_aimms_theme/static/icons/filerepl.jpg +0 -0
  149. sphinx_aimms_theme/static/icons/find.png +0 -0
  150. sphinx_aimms_theme/static/icons/help.png +0 -0
  151. sphinx_aimms_theme/static/icons/helpbutton.jpg +0 -0
  152. sphinx_aimms_theme/static/icons/hlarger.png +0 -0
  153. sphinx_aimms_theme/static/icons/hsmaller.png +0 -0
  154. sphinx_aimms_theme/static/icons/icon_cas.jpg +0 -0
  155. sphinx_aimms_theme/static/icons/icon_dat.jpg +0 -0
  156. sphinx_aimms_theme/static/icons/icon_que.jpg +0 -0
  157. sphinx_aimms_theme/static/icons/kast.png +0 -0
  158. sphinx_aimms_theme/static/icons/lade.png +0 -0
  159. sphinx_aimms_theme/static/icons/ladeopen.png +0 -0
  160. sphinx_aimms_theme/static/icons/leftarrow.png +0 -0
  161. sphinx_aimms_theme/static/icons/librarymodule.png +0 -0
  162. sphinx_aimms_theme/static/icons/lightbul.jpg +0 -0
  163. sphinx_aimms_theme/static/icons/margin.jpg +0 -0
  164. sphinx_aimms_theme/static/icons/minmax.png +0 -0
  165. sphinx_aimms_theme/static/icons/move.png +0 -0
  166. sphinx_aimms_theme/static/icons/movedown.jpg +0 -0
  167. sphinx_aimms_theme/static/icons/movedown.png +0 -0
  168. sphinx_aimms_theme/static/icons/movetext.png +0 -0
  169. sphinx_aimms_theme/static/icons/moveup.jpg +0 -0
  170. sphinx_aimms_theme/static/icons/moveup.png +0 -0
  171. sphinx_aimms_theme/static/icons/newcase.png +0 -0
  172. sphinx_aimms_theme/static/icons/newdtset.png +0 -0
  173. sphinx_aimms_theme/static/icons/newfolder.jpg +0 -0
  174. sphinx_aimms_theme/static/icons/newfoldr.png +0 -0
  175. sphinx_aimms_theme/static/icons/none.png +0 -0
  176. sphinx_aimms_theme/static/icons/ok.jpg +0 -0
  177. sphinx_aimms_theme/static/icons/print.jpg +0 -0
  178. sphinx_aimms_theme/static/icons/prtbmp.png +0 -0
  179. sphinx_aimms_theme/static/icons/readonly.jpg +0 -0
  180. sphinx_aimms_theme/static/icons/statusbarIcons.png +0 -0
  181. sphinx_aimms_theme/static/icons/sync.jpg +0 -0
  182. sphinx_aimms_theme/static/icons/totree.jpg +0 -0
  183. sphinx_aimms_theme/static/icons/totree.png +0 -0
  184. sphinx_aimms_theme/static/icons/up.jpg +0 -0
  185. sphinx_aimms_theme/static/icons/updir.jpg +0 -0
  186. sphinx_aimms_theme/static/icons/updir.png +0 -0
  187. sphinx_aimms_theme/static/icons/vlarger.png +0 -0
  188. sphinx_aimms_theme/static/icons/vsmaller.png +0 -0
  189. sphinx_aimms_theme/static/icons/warning.jpg +0 -0
  190. sphinx_aimms_theme/theme.conf +26 -0
  191. sphinx_aimms_theme-0.1.48.dist-info/METADATA +21 -0
  192. sphinx_aimms_theme-0.1.48.dist-info/RECORD +196 -0
  193. sphinx_aimms_theme-0.1.48.dist-info/WHEEL +5 -0
  194. sphinx_aimms_theme-0.1.48.dist-info/entry_points.txt +2 -0
  195. sphinx_aimms_theme-0.1.48.dist-info/licenses/LICENSE +18 -0
  196. sphinx_aimms_theme-0.1.48.dist-info/top_level.txt +1 -0
@@ -0,0 +1,623 @@
1
+
2
+ """
3
+ sphinx.domains.aimms
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ The AIMMS domain.
7
+
8
+ :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ from docutils import nodes
13
+ from docutils.parsers.rst import directives
14
+
15
+ from sphinx import addnodes
16
+ from sphinx.directives import ObjectDescription
17
+ from sphinx.domains import Domain, ObjType
18
+ from sphinx.domains.python import _pseudo_parse_arglist
19
+ from sphinx.locale import _
20
+ from sphinx.roles import XRefRole
21
+ from sphinx.util.docfields import Field, GroupedField, TypedField
22
+ from sphinx.util.docutils import SphinxDirective
23
+ from sphinx.util.nodes import make_refnode
24
+ from sphinx.util import logging
25
+
26
+ if False:
27
+ # For type annotation
28
+ from typing import Any, Dict, Iterator, List, Tuple # NOQA
29
+ from docutils import nodes # NOQA
30
+ from sphinx.application import Sphinx # NOQA
31
+ from sphinx.builders import Builder # NOQA
32
+ from sphinx.environment import BuildEnvironment # NOQA
33
+
34
+
35
+ class AIMMSObject(ObjectDescription):
36
+ """
37
+ Description of an AIMMS object.
38
+ """
39
+ #: If set to ``True`` this object is callable and a `desc_parameterlist` is
40
+ #: added
41
+ has_arguments = False
42
+
43
+ #: what is displayed right before the documentation entry
44
+ display_prefix = None # type: str
45
+
46
+ #: If ``allow_nesting`` is ``True``, the object prefixes will be accumulated
47
+ #: based on directive nesting
48
+ allow_nesting = False
49
+
50
+ def handle_signature(self, sig, signode):
51
+ # type: (str, addnodes.desc_signature) -> Tuple[str, str]
52
+ """Breaks down construct signatures
53
+
54
+ Parses out prefix and argument list from construct definition. The
55
+ namespace and class will be determined by the nesting of domain
56
+ directives.
57
+ """
58
+ sig = sig.strip()
59
+ if '(' in sig and sig[-1:] == ')':
60
+ member, arglist = sig.split('(', 1)
61
+ member = member.strip()
62
+ arglist = arglist[:-1].strip()
63
+ else:
64
+ member = sig
65
+ arglist = None
66
+ # If construct is nested, prefix the current prefix
67
+ prefix = self.env.ref_context.get('aimms:object', None)
68
+ mod_name = self.env.ref_context.get('aimms:module')
69
+ name = member
70
+ try:
71
+ member_prefix, member_name = member.rsplit('::', 1)
72
+ except ValueError:
73
+ member_name = name
74
+ member_prefix = ''
75
+ finally:
76
+ name = member_name
77
+ if prefix and member_prefix:
78
+ prefix = '::'.join([prefix, member_prefix])
79
+ elif prefix is None and member_prefix:
80
+ prefix = member_prefix
81
+ fullname = name
82
+ if prefix:
83
+ fullname = '::'.join([prefix, name])
84
+
85
+ signode['module'] = mod_name
86
+ signode['object'] = prefix
87
+ signode['fullname'] = fullname
88
+
89
+ if self.display_prefix:
90
+ signode += addnodes.desc_annotation(self.display_prefix,
91
+ self.display_prefix)
92
+ if prefix:
93
+ signode += addnodes.desc_addname(prefix + '::', prefix + '::')
94
+ elif mod_name:
95
+ signode += addnodes.desc_addname(mod_name + '::', mod_name + '::')
96
+ signode += addnodes.desc_name(name, name)
97
+ if self.has_arguments:
98
+ if not arglist:
99
+ pass #signode += addnodes.desc_parameterlist()
100
+ else:
101
+ _pseudo_parse_arglist(signode, arglist)
102
+ return fullname, prefix
103
+
104
+ def add_target_and_index(self, name_obj, sig, signode):
105
+ # type: (Tuple[str, str], str, addnodes.desc_signature) -> None
106
+ mod_name = self.env.ref_context.get('aimms:module')
107
+ fullname = (mod_name and mod_name + '::' or '') + name_obj[0]
108
+ if fullname not in self.state.document.ids:
109
+ signode['names'].append(fullname)
110
+ signode['ids'].append(fullname.replace('$', '_S_'))
111
+ signode['first'] = not self.names
112
+ self.state.document.note_explicit_target(signode)
113
+ objects = self.env.domaindata['aimms']['objects']
114
+ if fullname in objects:
115
+ self.state_machine.reporter.warning(
116
+ 'duplicate object description of %s, ' % fullname +
117
+ 'other instance in ' +
118
+ self.env.doc2path(objects[fullname][0]),
119
+ line=self.lineno)
120
+ objects[fullname] = self.env.docname, self.objtype
121
+
122
+ indextext = self.get_index_text(mod_name, name_obj)
123
+ if indextext:
124
+ self.indexnode['entries'].append(('single', indextext,
125
+ fullname.replace('$', '_S_'),
126
+ '', None))
127
+
128
+ def get_index_text(self, objectname, name_obj):
129
+ # type: (str, Tuple[str, str]) -> str
130
+ name, obj = name_obj
131
+ if self.objtype == 'function':
132
+ if not obj:
133
+ return _('%s() (built-in function)') % name
134
+ return _('%s() (%s method)') % (name, obj)
135
+ elif self.objtype == 'class':
136
+ return _('%s() (class)') % name
137
+ elif self.objtype == 'librarymodule':
138
+ return _('%s() (library module)') % name
139
+ elif self.objtype == 'procedure':
140
+ return _('%s() (procedure)') % name
141
+ elif self.objtype == 'externalprocedure':
142
+ return _('%s() (external procedure)') % name
143
+ elif self.objtype == 'parameter':
144
+ return _('%s() (parameter)') % name
145
+ elif self.objtype == 'elementparameter':
146
+ return _('%s() (element parameter)') % name
147
+ elif self.objtype == 'stringparameter':
148
+ return _('%s() (string parameter)') % name
149
+ elif self.objtype == 'unitparameter':
150
+ return _('%s() (unit parameter)') % name
151
+ elif self.objtype == 'set':
152
+ return _('%s() (set)') % name
153
+ elif self.objtype == 'index':
154
+ return _('%s() (index)') % name
155
+ elif self.objtype == 'variable':
156
+ return _('%s() (variable)') % name
157
+ elif self.objtype == 'constraint':
158
+ return _('%s() (constraint)') % name
159
+ elif self.objtype == 'mathematicalprogram':
160
+ return _('%s() (Mathematical Program)') % name
161
+ elif self.objtype == 'quantity':
162
+ return _('%s() (Quantity)') % name
163
+ elif self.objtype == 'databasetable':
164
+ return _('%s() (Database Table)') % name
165
+ elif self.objtype == 'calendar':
166
+ return _('%s() (Calendar)') % name
167
+ elif self.objtype == 'file':
168
+ return _('%s() (File)') % name
169
+ elif self.objtype == 'handle':
170
+ return _('%s() (Handle)') % name
171
+ elif self.objtype == 'data':
172
+ return _('%s (global variable or constant)') % name
173
+ elif self.objtype == 'attribute':
174
+ return _('%s (%s attribute)') % (name, obj)
175
+ return ''
176
+
177
+ def before_content(self):
178
+ # type: () -> None
179
+ """Handle object nesting before content
180
+
181
+ :py:class:`JSObject` represents JavaScript language constructs. For
182
+ constructs that are nestable, this method will build up a stack of the
183
+ nesting heirarchy so that it can be later de-nested correctly, in
184
+ :py:meth:`after_content`.
185
+
186
+ For constructs that aren't nestable, the stack is bypassed, and instead
187
+ only the most recent object is tracked. This object prefix name will be
188
+ removed with :py:meth:`after_content`.
189
+
190
+ The following keys are used in ``self.env.ref_context``:
191
+
192
+ js:objects
193
+ Stores the object prefix history. With each nested element, we
194
+ add the object prefix to this list. When we exit that object's
195
+ nesting level, :py:meth:`after_content` is triggered and the
196
+ prefix is removed from the end of the list.
197
+
198
+ js:object
199
+ Current object prefix. This should generally reflect the last
200
+ element in the prefix history
201
+ """
202
+ prefix = None
203
+ if self.names:
204
+ (obj_name, obj_name_prefix) = self.names.pop()
205
+ prefix = obj_name_prefix.strip('::') if obj_name_prefix else None
206
+ if self.allow_nesting:
207
+ prefix = obj_name
208
+ if prefix:
209
+ self.env.ref_context['aimms:object'] = prefix
210
+ if self.allow_nesting:
211
+ objects = self.env.ref_context.setdefault('aimms:objects', [])
212
+ objects.append(prefix)
213
+
214
+ def after_content(self):
215
+ # type: () -> None
216
+ """Handle object de-nesting after content
217
+
218
+ If this class is a nestable object, removing the last nested class prefix
219
+ ends further nesting in the object.
220
+
221
+ If this class is not a nestable object, the list of classes should not
222
+ be altered as we didn't affect the nesting levels in
223
+ :py:meth:`before_content`.
224
+ """
225
+ objects = self.env.ref_context.setdefault('aimms:objects', [])
226
+ if self.allow_nesting:
227
+ try:
228
+ objects.pop()
229
+ except IndexError:
230
+ pass
231
+ self.env.ref_context['aimms:object'] = (objects[-1] if len(objects) > 0
232
+ else None)
233
+
234
+
235
+ class AIMMSCallable(AIMMSObject):
236
+ """Description of a AIMMS function, method or constructor."""
237
+ has_arguments = True
238
+
239
+ doc_field_types = [
240
+ TypedField('arguments', label=_('Attributes'),
241
+ names=('argument', 'arg', 'parameter', 'param','attribute','attr'),
242
+ typerolename='function', typenames=('paramtype', 'type')),
243
+ GroupedField('errors', label=_('Throws'), rolename='err',
244
+ names=('throws', ),
245
+ can_collapse=True),
246
+ Field('returnvalue', label=_('Returns'), has_arg=False,
247
+ names=('returns', 'return')),
248
+ Field('returntype', label=_('Return type'), has_arg=False,
249
+ names=('rtype',)),
250
+ ]
251
+
252
+ class AIMMSConstructor(AIMMSCallable):
253
+ """Like a callable but with a different prefix."""
254
+ display_prefix = 'class '
255
+ allow_nesting = True
256
+
257
+ class AIMMSIdentifier(AIMMSCallable):
258
+ """Like a callable but with a different prefix."""
259
+ display_prefix = 'identifier '
260
+ allow_nesting = False
261
+ has_arguments = True
262
+
263
+ class AIMMSModelNode(AIMMSCallable):
264
+ """Like a callable but with a different prefix."""
265
+ display_prefix = 'node '
266
+ allow_nesting = True
267
+
268
+ class AIMMSProcedure(AIMMSCallable):
269
+ """Like a callable but with a different prefix."""
270
+ display_prefix = 'Procedure '
271
+ allow_nesting = True
272
+
273
+ class AIMMSLibraryModule(AIMMSCallable):
274
+ """Like a callable but with a different prefix."""
275
+ display_prefix = 'Library Module '
276
+ allow_nesting = False
277
+
278
+ class AIMMSExternalProcedure(AIMMSCallable):
279
+ """Like a callable but with a different prefix."""
280
+ display_prefix = 'External Procedure '
281
+ allow_nesting = True
282
+
283
+ class AIMMSFunction(AIMMSCallable):
284
+ """Like a callable but with a different prefix."""
285
+ display_prefix = 'Function '
286
+ allow_nesting = True
287
+
288
+ class AIMMSParameter(AIMMSCallable):
289
+ """Like a callable but with a different prefix."""
290
+ display_prefix = 'Parameter '
291
+ allow_nesting = False
292
+ has_arguments = True
293
+
294
+ class AIMMSStringParameter(AIMMSCallable):
295
+ """Like a callable but with a different prefix."""
296
+ display_prefix = 'String Parameter '
297
+ allow_nesting = False
298
+ has_arguments = True
299
+
300
+ class AIMMSUnitParameter(AIMMSCallable):
301
+ """Like a callable but with a different prefix."""
302
+ display_prefix = 'Unit Parameter '
303
+ allow_nesting = False
304
+ has_arguments = True
305
+
306
+ class AIMMSElementParameter(AIMMSCallable):
307
+ """Like a callable but with a different prefix."""
308
+ display_prefix = 'Element Parameter '
309
+ allow_nesting = False
310
+ has_arguments = True
311
+
312
+ class AIMMSSet(AIMMSCallable):
313
+ """Like a callable but with a different prefix."""
314
+ display_prefix = 'Set '
315
+ allow_nesting = False
316
+ has_arguments = False
317
+
318
+ class AIMMSIndex(AIMMSCallable):
319
+ """Like a callable but with a different prefix."""
320
+ display_prefix = 'Index '
321
+ allow_nesting = False
322
+ has_arguments = False
323
+
324
+ class AIMMSVariable(AIMMSCallable):
325
+ """Like a callable but with a different prefix."""
326
+ display_prefix = 'Variable '
327
+ allow_nesting = False
328
+ has_arguments = True
329
+
330
+ class AIMMSConstraint(AIMMSCallable):
331
+ """Like a callable but with a different prefix."""
332
+ display_prefix = 'Constraint '
333
+ allow_nesting = False
334
+ has_arguments = True
335
+
336
+ class AIMMSMathematicalProgram(AIMMSCallable):
337
+ """Like a callable but with a different prefix."""
338
+ display_prefix = 'Mathematical Program '
339
+ allow_nesting = False
340
+ has_arguments = True
341
+
342
+ class AIMMSQuantity(AIMMSCallable):
343
+ """Like a callable but with a different prefix."""
344
+ display_prefix = 'Quantity '
345
+ allow_nesting = False
346
+ has_arguments = True
347
+
348
+ class AIMMSDatabaseTable(AIMMSCallable):
349
+ """Like a callable but with a different prefix."""
350
+ display_prefix = 'Mathematical Program '
351
+ allow_nesting = False
352
+ has_arguments = True
353
+
354
+ class AIMMSCalendar(AIMMSCallable):
355
+ """Like a callable but with a different prefix."""
356
+ display_prefix = 'Calendar '
357
+ allow_nesting = False
358
+ has_arguments = True
359
+
360
+ class AIMMSFile(AIMMSCallable):
361
+ """Like a callable but with a different prefix."""
362
+ display_prefix = 'File '
363
+ allow_nesting = False
364
+ has_arguments = True
365
+
366
+ class AIMMSHandle(AIMMSCallable):
367
+ """Like a callable but with a different prefix."""
368
+ display_prefix = 'Handle '
369
+ allow_nesting = False
370
+ has_arguments = True
371
+
372
+ class AIMMSModule(SphinxDirective):
373
+ """
374
+ Directive to mark description of a new AIMMS module (namespace).
375
+
376
+ This directive specifies the module name that will be used by objects that
377
+ follow this directive.
378
+
379
+ Options
380
+ -------
381
+
382
+ noindex
383
+ If the ``noindex`` option is specified, no linkable elements will be
384
+ created, and the module won't be added to the global module index. This
385
+ is useful for splitting up the module definition across multiple
386
+ sections or files.
387
+
388
+ :param mod_name: Module name
389
+ """
390
+
391
+ has_content = False
392
+ required_arguments = 1
393
+ optional_arguments = 0
394
+ final_argument_whitespace = False
395
+ option_spec = {
396
+ 'noindex': directives.flag
397
+ }
398
+
399
+ def run(self):
400
+ # type: () -> List[nodes.Node]
401
+ mod_name = self.arguments[0].strip()
402
+ self.env.ref_context['aimms:module'] = mod_name
403
+ noindex = 'noindex' in self.options
404
+ ret = [] # type: List[nodes.Node]
405
+ if not noindex:
406
+ self.env.domaindata['aimms']['modules'][mod_name] = self.env.docname
407
+ # Make a duplicate entry in 'objects' to facilitate searching for
408
+ # the module in JavaScriptDomain.find_obj()
409
+ self.env.domaindata['aimms']['objects'][mod_name] = (self.env.docname, 'module')
410
+ targetnode = nodes.target('', '', ids=['module-' + mod_name],
411
+ ismod=True)
412
+ self.state.document.note_explicit_target(targetnode)
413
+ ret.append(targetnode)
414
+ indextext = _('%s (module)') % mod_name
415
+ inode = addnodes.index(entries=[('single', indextext,
416
+ 'module-' + mod_name, '', None)])
417
+ ret.append(inode)
418
+ return ret
419
+
420
+
421
+ class AIMMSXRefRole(XRefRole):
422
+ def process_link(self, env, refnode, has_explicit_title, title, target):
423
+ # type: (BuildEnvironment, nodes.Element, bool, str, str) -> Tuple[str, str]
424
+ # basically what sphinx.domains.python.PyXRefRole does
425
+ refnode['aimms:object'] = env.ref_context.get('aimms:object')
426
+ refnode['aimms:module'] = env.ref_context.get('aimms:module')
427
+ if not has_explicit_title:
428
+ title = title.lstrip('::')
429
+ target = target.lstrip('~')
430
+ if title[0:1] == '~':
431
+ title = title[1:]
432
+ dot = title.rfind('::')
433
+ if dot != -1:
434
+ title = title[dot + 1:]
435
+ if target[0:1] == '::':
436
+ target = target[1:]
437
+ refnode['refspecific'] = True
438
+ return title, target
439
+
440
+
441
+ class AIMMSDomain(Domain):
442
+ """AIMMS language domain."""
443
+ name = 'aimms'
444
+ label = 'AIMMS'
445
+ # if you add a new object type make sure to edit AIMMSObject.get_index_text
446
+ object_types = {
447
+ 'function': ObjType(_('function'), 'func', 'function'),
448
+ 'method': ObjType(_('method'), 'meth'),
449
+ 'identifier': ObjType(_('identifier'), 'id'),
450
+ 'modelnode': ObjType(_('modelnode'), 'mn'),
451
+ 'class': ObjType(_('class'), 'class'),
452
+ 'procedure': ObjType(_('procedure'), 'procedure'),
453
+ 'librarymodule': ObjType(_('librarymodule'), 'librarymodule'),
454
+ 'externalprocedure': ObjType(_('externalprocedure'), 'externalprocedure'),
455
+ 'parameter': ObjType(_('parameter'), 'parameter'),
456
+ 'stringparameter': ObjType(_('stringparameter'), 'stringparameter'),
457
+ 'stringparameter': ObjType(_('unitparameter'), 'unitparameter'),
458
+ 'elementparameter': ObjType(_('elementparameter'), 'elementparameter'),
459
+ 'set': ObjType(_('set'), 'set'),
460
+ 'index': ObjType(_('index'), 'index'),
461
+ 'variable': ObjType(_('variable'), 'variable'),
462
+ 'constraint': ObjType(_('constraint'), 'constraint'),
463
+ 'mathematicalprogram': ObjType(_('mathematicalprogram'), 'mathematicalprogram'),
464
+ 'quantity': ObjType(_('quantity'), 'quantity'),
465
+ 'databasetable': ObjType(_('databasetable'), 'databasetable'),
466
+ 'calendar': ObjType(_('calendar'), 'calendar'),
467
+ 'file': ObjType(_('file'), 'file'),
468
+ 'handle': ObjType(_('handle'), 'handle'),
469
+ 'data': ObjType(_('data'), 'data'),
470
+ 'attribute': ObjType(_('attribute'), 'attr'),
471
+ 'module': ObjType(_('module'), 'mod'),
472
+ }
473
+ directives = {
474
+ 'function': AIMMSFunction,
475
+ 'method': AIMMSCallable,
476
+ 'identifier': AIMMSIdentifier,
477
+ 'modelnode': AIMMSModelNode,
478
+ 'class': AIMMSConstructor,
479
+ 'procedure': AIMMSProcedure,
480
+ 'librarymodule': AIMMSLibraryModule,
481
+ 'externalprocedure': AIMMSExternalProcedure,
482
+ 'parameter': AIMMSParameter,
483
+ 'elementparameter': AIMMSElementParameter,
484
+ 'stringparameter': AIMMSStringParameter,
485
+ 'unitparameter': AIMMSUnitParameter,
486
+ 'set': AIMMSSet,
487
+ 'index': AIMMSIndex,
488
+ 'variable': AIMMSVariable,
489
+ 'constraint': AIMMSConstraint,
490
+ 'mathematicalprogram': AIMMSMathematicalProgram,
491
+ 'quantity' : AIMMSQuantity,
492
+ 'databasetable': AIMMSDatabaseTable,
493
+ 'calendar': AIMMSCalendar,
494
+ 'file': AIMMSFile,
495
+ 'handle': AIMMSHandle,
496
+ 'data': AIMMSObject,
497
+ 'attribute': AIMMSObject,
498
+ 'module': AIMMSModule,
499
+ }
500
+ roles = {
501
+ 'func': AIMMSXRefRole(fix_parens=True),
502
+ 'function': AIMMSXRefRole(fix_parens=True),
503
+ 'meth': AIMMSXRefRole(fix_parens=True),
504
+ 'id': AIMMSXRefRole(),
505
+ 'mn': AIMMSXRefRole(),
506
+ 'class': AIMMSXRefRole(),
507
+ 'procedure': AIMMSXRefRole(),
508
+ 'librarymodule': AIMMSXRefRole(),
509
+ 'externalprocedure': AIMMSXRefRole(),
510
+ 'parameter': AIMMSXRefRole(),
511
+ 'elementparameter': AIMMSXRefRole(),
512
+ 'stringparameter': AIMMSXRefRole(),
513
+ 'unitparameter': AIMMSXRefRole(),
514
+ 'set': AIMMSXRefRole(),
515
+ 'index': AIMMSXRefRole(),
516
+ 'variable': AIMMSXRefRole(),
517
+ 'constraint': AIMMSXRefRole(),
518
+ 'mathematicalprogram': AIMMSXRefRole(),
519
+ 'quantity': AIMMSXRefRole(),
520
+ 'databasetable': AIMMSXRefRole(),
521
+ 'calendar': AIMMSXRefRole(),
522
+ 'file': AIMMSXRefRole(),
523
+ 'handle': AIMMSXRefRole(),
524
+ 'data': AIMMSXRefRole(),
525
+ 'attr': AIMMSXRefRole(),
526
+ 'mod': AIMMSXRefRole(),
527
+ }
528
+ initial_data = {
529
+ 'objects': {}, # fullname -> docname, objtype
530
+ 'modules': {}, # mod_name -> docname
531
+ } # type: Dict[str, Dict[str, Tuple[str, str]]]
532
+
533
+ # def clear_doc(self, docname):
534
+ # # type: (str) -> None
535
+ # for fullname, (pkg_docname, _l) in list(self.data['objects'].items()):
536
+ # if pkg_docname == docname:
537
+ # del self.data['objects'][fullname]
538
+ # for mod_name, pkg_docname in list(self.data['modules'].items()):
539
+ # if pkg_docname == docname:
540
+ # del self.data['modules'][mod_name]
541
+
542
+ def merge_domaindata(self, docnames, otherdata):
543
+ # type: (List[str], Dict) -> None
544
+ # XXX check duplicates
545
+ for fullname, (fn, objtype) in otherdata['objects'].items():
546
+ if fn in docnames:
547
+ self.data['objects'][fullname] = (fn, objtype)
548
+ for mod_name, pkg_docname in otherdata['modules'].items():
549
+ if pkg_docname in docnames:
550
+ self.data['modules'][mod_name] = pkg_docname
551
+
552
+ def find_obj(self, env, mod_name, prefix, name, typ, searchorder=0):
553
+ # type: (BuildEnvironment, str, str, str, str, int) -> Tuple[str, Tuple[str, str]]
554
+ if name[-2:] == '()':
555
+ name = name[:-2]
556
+ objects = self.data['objects']
557
+
558
+ searches = []
559
+ if mod_name and prefix:
560
+ searches.append('::'.join([mod_name, prefix, name]))
561
+ if mod_name:
562
+ searches.append('::'.join([mod_name, name]))
563
+ if prefix:
564
+ searches.append('::'.join([prefix, name]))
565
+ searches.append(name)
566
+
567
+ if searchorder == 0:
568
+ searches.reverse()
569
+
570
+ newname = None
571
+ for search_name in searches:
572
+ if search_name in objects:
573
+ newname = search_name
574
+
575
+ return newname, objects.get(newname)
576
+
577
+ def resolve_xref(self, env, fromdocname, builder, typ, target, node,
578
+ contnode):
579
+ # type: (BuildEnvironment, str, Builder, str, str, addnodes.pending_xref, nodes.Element) -> nodes.Element # NOQA
580
+ mod_name = node.get('aimms:module')
581
+ prefix = node.get('aimms:object')
582
+ searchorder = node.hasattr('refspecific') and 1 or 0
583
+ name, obj = self.find_obj(env, mod_name, prefix, target, typ, searchorder)
584
+ if not obj:
585
+ return None
586
+ return make_refnode(builder, fromdocname, obj[0],
587
+ name.replace('$', '_S_'), contnode, name)
588
+
589
+ def resolve_any_xref(self, env, fromdocname, builder, target, node,
590
+ contnode):
591
+ # type: (BuildEnvironment, str, Builder, str, addnodes.pending_xref, nodes.Element) -> List[Tuple[str, nodes.Element]] # NOQA
592
+ mod_name = node.get('aimms:module')
593
+ prefix = node.get('aimms:object')
594
+ name, obj = self.find_obj(env, mod_name, prefix, target, None, 1)
595
+ if not obj:
596
+ return []
597
+ return [('aimms:' + self.role_for_objtype(obj[1]),
598
+ make_refnode(builder, fromdocname, obj[0],
599
+ name.replace('$', '_S_'), contnode, name))]
600
+
601
+ def get_objects(self):
602
+ # type: () -> Iterator[Tuple[str, str, str, str, str, int]]
603
+ for refname, (docname, type) in list(self.data['objects'].items()):
604
+ yield refname, refname, type, docname, \
605
+ refname.replace('$', '_S_'), 1
606
+
607
+ def get_full_qualified_name(self, node):
608
+ # type: (nodes.Element) -> str
609
+ modname = node.get('aimms:module')
610
+ prefix = node.get('aimms:object')
611
+ target = node.get('reftarget')
612
+ if target is None:
613
+ return None
614
+ else:
615
+ return '::'.join(filter(None, [modname, prefix, target]))
616
+
617
+
618
+ # def setup(app):
619
+ # # type: (Sphinx) -> Dict[str, Any]
620
+ # app.add_domain(AIMMSDomain)
621
+ # logger = logging.getLogger(__name__)
622
+ # logger.info('\nAIMMS Domain added')
623
+