Skip to content

Commit 21a2b88

Browse files
committed
Added doc-strings to symbols.
1 parent 3160fd5 commit 21a2b88

File tree

1 file changed

+63
-14
lines changed

1 file changed

+63
-14
lines changed

pyVHDLModel/Symbol.py

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@
3232
"""
3333
This module contains parts of an abstract document language model for VHDL.
3434
35-
Symbols derived from names.
35+
Symbols are entity specific wrappers for names that reference VHDL language entities.
3636
"""
37-
from enum import Flag, auto
38-
from typing import Any
37+
from enum import Flag, auto
38+
from typing import Any, Optional as Nullable
3939

40-
from pyTooling.Decorators import export
40+
from pyTooling.Decorators import export
41+
from pyTooling.MetaClasses import ExtendedType
4142

42-
from pyVHDLModel.Name import Name, AllName
43+
from pyVHDLModel.Name import Name, AllName
4344

4445

4546
@export
4647
class PossibleReference(Flag):
4748
"""
48-
A ``PossibleReference`` is an enumeration. It represents possible targets for a reference in a :class:`~pyVHDLModel.Symbol`.
49+
Is an enumeration, representing possible targets for a reference in a :class:`~pyVHDLModel.Symbol`.
4950
"""
5051

5152
Unknown = 0
@@ -90,10 +91,14 @@ class PossibleReference(Flag):
9091

9192

9293
@export
93-
class Symbol:
94-
_name: Name
95-
_possibleReferences: PossibleReference
96-
_reference: Any
94+
class Symbol(metaclass=ExtendedType):
95+
"""
96+
Base-class for all symbol classes.
97+
"""
98+
99+
_name: Name #: The name to reference the langauge entity.
100+
_possibleReferences: PossibleReference #: An enumeration to filter possible references.
101+
_reference: Nullable[Any] #: The resolved language entity, otherwise ``None``.
97102

98103
def __init__(self, name: Name, possibleReferences: PossibleReference):
99104
self._name = name
@@ -130,7 +135,18 @@ def __str__(self) -> str:
130135

131136
@export
132137
class LibraryReferenceSymbol(Symbol):
133-
"""A library reference in a library clause."""
138+
"""
139+
Represents a reference (name) to a library.
140+
141+
The internal name will be a :class:`~pyVHDLModel.Name.SimpleName`.
142+
143+
.. admonition:: Example
144+
145+
.. code-block:: VHDL
146+
147+
library ieee;
148+
-- ^^^^
149+
"""
134150

135151
def __init__(self, name: Name):
136152
super().__init__(name, PossibleReference.Library)
@@ -146,7 +162,18 @@ def Library(self, value: 'Library') -> None:
146162

147163
@export
148164
class PackageReferenceSymbol(Symbol):
149-
"""A package reference in a use clause."""
165+
"""
166+
Represents a reference (name) to a package.
167+
168+
The internal name will be a :class:`~pyVHDLModel.Name.SelectedName`.
169+
170+
.. admonition:: Example
171+
172+
.. code-block:: VHDL
173+
174+
use ieee.numeric_std;
175+
-- ^^^^^^^^^^^^^^^^
176+
"""
150177

151178
def __init__(self, name: Name):
152179
super().__init__(name, PossibleReference.Package)
@@ -162,7 +189,18 @@ def Package(self, value: 'Package') -> None:
162189

163190
@export
164191
class PackageMemberReferenceSymbol(Symbol):
165-
"""A package member reference in a use clause."""
192+
"""
193+
Represents a reference (name) to a package member.
194+
195+
The internal name will be a :class:`~pyVHDLModel.Name.SelectedName`.
196+
197+
.. admonition:: Example
198+
199+
.. code-block:: VHDL
200+
201+
use ieee.numeric_std.unsigned;
202+
-- ^^^^^^^^^^^^^^^^^^^^^^^^^
203+
"""
166204

167205
def __init__(self, name: Name):
168206
super().__init__(name, PossibleReference.PackageMember)
@@ -178,7 +216,18 @@ def Member(self, value: 'Package') -> None: # TODO: typehint
178216

179217
@export
180218
class AllPackageMembersReferenceSymbol(Symbol):
181-
"""A package reference in a use clause."""
219+
"""
220+
Represents a reference (name) to all package members.
221+
222+
The internal name will be a :class:`~pyVHDLModel.Name.AllName`.
223+
224+
.. admonition:: Example
225+
226+
.. code-block:: VHDL
227+
228+
use ieee.numeric_std.all;
229+
-- ^^^^^^^^^^^^^^^^^^^^
230+
"""
182231

183232
def __init__(self, name: AllName):
184233
super().__init__(name, PossibleReference.PackageMember)

0 commit comments

Comments
 (0)