Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Apr 3, 2019
1 parent 23ab456 commit 9f5a841
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
33 changes: 28 additions & 5 deletions WDL/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,25 @@ class StructType(SourceNode):
"""WDL struct type definition"""

name: str
"""
:type: str
Name of the struct type (in the current document)
"""

members: Dict[str, T.Base]
"""
:type: Dict[str, WDL.Type.Base]
Member names and types
"""

imported: bool
"""
:type: bool
True if this struct type was imported from another document
"""

def __init__(
self, pos: SourcePosition, name: str, members: Dict[str, T.Base], imported: bool = False
Expand All @@ -51,8 +68,11 @@ def __init__(

@property
def type_id(self) -> str:
# Because the same struct type can have different names depending on
# the context, we use a content hash of the members
"""
:type: str
A string uniquely describing the member names and types, excluding the struct type name; useful to identify aliased struct types.
"""
return T._struct_type_id(self.members)


Expand Down Expand Up @@ -857,9 +877,12 @@ def _rewrite_output_idents(self) -> None:
("uri", str),
("namespace", str),
("aliases", List[Tuple[str, str]]),
("doc", Optional[TVDocument]),
("doc", "Optional[Document]"),
],
)
"""
Represents one imported document, with position of the import statement, import URI, namespace, struct type aliases, and (after typechecking) the ``Document`` object.
"""


class Document(SourceNode):
Expand All @@ -872,9 +895,9 @@ class Document(SourceNode):

imports: List[DocImport]
"""
:type: List[Tuple[str,str,Optional[WDL.Tree.Document]]]
:type: List[DocImport]
Imports in the document (filename/URI, namespace, and later the sub-document)"""
Imported documents"""
struct_types: Env.StructTypes
""":type: Dict[str, Dict[str, WDL.Type.Base]]"""
tasks: List[Task]
Expand Down
5 changes: 2 additions & 3 deletions WDL/Type.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@ def coerces(self, rhs: Base, check_quant: bool = True) -> bool:
@property
def type_id(self) -> str:
"""
:type: int
:type: str
An identifier for the struct type, which can go by different names
depending on the context.
A string uniquely describing the member names and types, excluding the struct type name; useful to identify aliased struct types.
"""
assert isinstance(self.members, dict)
return _struct_type_id(self.members)
Expand Down

0 comments on commit 9f5a841

Please sign in to comment.