Directive

Summary

Package:

VHDLDomain

Doc-string:

documented

File

Expected

Covered

Uncovered

Coverage

Directive.py

25

24

1

96.0%

Source

VHDLDomain/Directive.pydocumentedundocumentedignoredexcludednot counted
32"""
33The directives of the domain ``vhdl``: each describes an object of a design read into the domain.
34
35``vhdl:design`` and ``vhdl:library`` set the design and library the following directives and references of the
36document are in, until the next one.
37"""
...
59
61_logger = getLogger(__name__)
62
64@export
65class VHDLDirective(SphinxDirective):
66	"""
67	Base-class of the directives of domain ``vhdl``: access to the domain, the current design and library, and the
68	registration of a described object.
69	"""
70
71	_WARNING_TYPE: ClassVar[str] = "vhdl"  #: Type of the warnings the directives emit, the domain's name.
72
73	directiveName: ClassVar[str]  #: Name the directive is invoked by, used in every warning.
74
75	def _Domain(self) -> VHDLDomain:
76		"""
77		Return the domain ``vhdl``.
78
79		:returns: The domain.
80		"""
		...
82
83	def _CurrentDesign(self) -> tuple[Nullable[str], Nullable[Design]]:
84		"""
85		Return the design the directive is in: the one of option ``:design:``, else the current one.
86
87		A missing design is warned about.
88
89		:returns: The design's name and the design, or ``None`` and ``None`` if no design is current, or the name and
90		          ``None`` if the design wasn't read.
91		"""
		...
106
107	def _NodeID(self, objectType: str, qualifiedName: str) -> str:
108		"""
109		Return the anchor of a described object, unique in the document.
110
111		The anchor is built from the object type and the lower-case qualified name, e.g.
112		``vhdl-entity-stopwatch.lib_stopwatch.counter``.
113
114		:param objectType:    The object type, as ``entity``.
115		:param qualifiedName: The object's qualified name, as ``StopWatch.lib_StopWatch.Counter``.
116		:returns:             The anchor, from the lower-case qualified name.
117		"""
		...
119
120	def _Target(self, objectType: str, qualifiedName: str, indexText: str) -> list[Node]:
121		"""
122		Create the target and the index entry of a described object, and register it in the domain.
123
124		:param objectType:    The object type, as ``entity``.
125		:param qualifiedName: The object's qualified name, as ``StopWatch.lib_StopWatch.Counter``.
126		:param indexText:     The text of the object's entry in the general index.
127		:returns:             The index node and the target node.
128		"""
		...
136
137	def _Documentation(self, documentation: Nullable[str]) -> list[Node]:
138		"""
139		Parse an object's documentation comment as reStructuredText.
140
141		A line's leading comment marker ``--`` and the space following it are removed, so a comment block reads as text.
142
143		:param documentation: The documentation comment, as the frontend extracted it, or ``None``.
144		:returns:             The parsed nodes, none for no or an empty comment.
145		"""
		...
161
162	def _Format(self, element: object) -> str:
163		"""
164		Write a model element - a symbol, an expression - as VHDL source text.
165
166		An element the writer of pyVHDLModel can't write yet is written by its name, if it has one, and warned about.
167
168		:param element: The model element.
169		:returns:       The VHDL source text.
170		"""
		...
180
182@export
183class DesignDirective(VHDLDirective):
184	"""
185	The directive ``vhdl:design``: a design's target and index entry, and the current design of the document.
186
187	.. code-block:: rst
188
189	   .. vhdl:design:: StopWatch
190
191	The argument is the design's name, a key of ``vhdl_designs``. Every directive and reference following it in the
192	document is in this design. The directive writes no visible output except its content; placed above a page's title,
193	its target is the title, as a label is. With ``:no-index:``, it only makes the design the current one - for the
194	other pages of a design.
195
196	A design with generated pages (key ``pages`` in ``vhdl_designs``) lists its library pages in a hidden table of
197	contents, so they are below the directive's document in the navigation.
198	"""
199
200	directiveName: ClassVar[str] = "vhdl:design"  #: Name the directive is invoked by.
201
202	has_content =        True                            #: The content describes the design.
203	required_arguments = 1                               #: The design's name.
204	option_spec =        {"no-index": directives.flag}   #: Make the design current, without a target and index entry.
205
206	def run(self) -> list[Node]:
207		"""
208		Register the design, make it the current one, and parse the content.
209
210		:returns: An index node, the design's target and the content's nodes.
211		"""
		...
228
230@export
231class LibraryDirective(VHDLDirective):
232	"""
233	The directive ``vhdl:library``: a library's target, index entry and design units, and the current library of the
234	document.
235
236	.. code-block:: rst
237
238	   .. vhdl:library:: lib_StopWatch
239	      :design: StopWatch
240
241	The argument is the library's name; without ``:design:``, the library is in the current design. Every directive and
242	reference following it in the document is in this library. The directive writes the library's documentation, its
243	content, and a table of the library's design units - each name referring to the unit's description, if there is
244	one. With ``:no-index:``, it only makes the library the current one, and writes nothing.
245	"""
246
247	directiveName: ClassVar[str] = "vhdl:library"  #: Name the directive is invoked by.
248
249	has_content =        True  #: The content describes the library.
250	required_arguments = 1     #: The library's name.
251	option_spec =        {
252		"design":   directives.unchanged_required,
253		"no-index": directives.flag,
254	}  #: The design, if not the current one; ``:no-index:`` makes the library current, without describing it.
255
256	#: The kinds of design units the table lists, with the collection of :class:`~pyVHDLModel.Library` and the role.
257	_UNIT_KINDS: ClassVar[tuple[tuple[str, str, str], ...]] = (
258		("Context",       "Contexts",       "ctx"),
259		("Entity",        "Entities",       "ent"),
260		("Package",       "Packages",       "pack"),
261		("Configuration", "Configurations", "config"),
262	)
263
264	def run(self) -> list[Node]:
265		"""
266		Register the library, make it the current one, and write its documentation, content and design units.
267
268		:returns: An index node, the library's target, and the library's description.
269		"""
		...
299
300	def _DesignUnits(self, library: Library) -> Nullable[nodes.table]:
301		"""
302		Create the table of a library's design units: kind and name, the name referring to the unit's description.
303
304		:param library: The library.
305		:returns:       The table, or ``None`` if the library has no design units.
306		"""
		...