Skip to content

Commit b8c675b

Browse files
committed
Add some more docstrings
1 parent ddee526 commit b8c675b

File tree

11 files changed

+18
-0
lines changed

11 files changed

+18
-0
lines changed

schema_salad/avro/schema.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def __init__(
385385
# read-only properties
386386
@property
387387
def symbols(self) -> list[str]:
388+
"""Retrieve the list of symbols."""
388389
return cast(list[str], self.get_prop("symbols"))
389390

390391

@@ -596,6 +597,7 @@ def __init__(
596597
# read-only properties
597598
@property
598599
def schemas(self) -> list[Schema]:
600+
"""Retrieve the list of schemas."""
599601
return self._schemas
600602

601603

@@ -664,6 +666,7 @@ def __init__(
664666
# read-only properties
665667
@property
666668
def fields(self) -> list[Field]:
669+
"""Retrieve the fields list."""
667670
return cast(list[Field], self.get_prop("fields"))
668671

669672

schema_salad/dotnet_codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ def type_loader(
502502
return self.collected_types[self.safe_name(type_declaration) + "Loader"]
503503

504504
def type_loader_enum(self, type_declaration: dict[str, Any]) -> TypeDef:
505+
"""Build an enum type loader for the given declaration."""
505506
for sym in type_declaration["symbols"]:
506507
self.add_vocab(shortname(sym), sym)
507508
enum_name = self.safe_name(type_declaration["name"])

schema_salad/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def with_sourceline(self, sl: Optional[SourceLine]) -> "SchemaSaladException":
7575
return self
7676

7777
def leaves(self) -> list["SchemaSaladException"]:
78+
"""Return the list of all the exceptions at the tips of the tree."""
7879
if len(self.children) > 0:
7980
return sum((c.leaves() for c in self.children), [])
8081
if len(self.message):

schema_salad/fetcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
self.session = session
6666

6767
def fetch_text(self, url: str, content_types: Optional[list[str]] = None) -> str:
68+
"""Retrieve the given resource as a string."""
6869
result = self.cache.get(url, None)
6970
if isinstance(result, str):
7071
return result

schema_salad/java_codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ def type_loader(
580580
return self.collected_types[self.safe_name(type_declaration)]
581581

582582
def type_loader_enum(self, type_declaration: dict[str, Any]) -> TypeDef:
583+
"""Build an enum type loader for the given declaration."""
583584
symbols = [self.property_name(sym) for sym in type_declaration["symbols"]]
584585
for sym in symbols:
585586
self.add_vocab(shortname(sym), sym)

schema_salad/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def arg_parser() -> argparse.ArgumentParser:
227227

228228

229229
def main(argsl: Optional[list[str]] = None) -> int:
230+
"""Run the schema-salad-tool."""
230231
if argsl is None:
231232
argsl = sys.argv[1:]
232233

schema_salad/makedoc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def vocab_type_name(url: str) -> str:
4343

4444

4545
def has_types(items: Any) -> list[str]:
46+
"""Retrieve all the types of a record."""
4647
r: list[str] = []
4748
if isinstance(items, MutableMapping):
4849
if items["type"] == "https://w3id.org/cwl/salad#record":
@@ -225,6 +226,7 @@ def number_headings(toc: ToC, maindoc: str) -> str:
225226

226227

227228
def fix_doc(doc: Union[list[str], str]) -> str:
229+
"""Concatenate doc strings, replacing email addresses with mailto links."""
228230
docstr = "".join(doc) if isinstance(doc, MutableSequence) else doc
229231
return "\n".join(
230232
[re.sub(r"<([^>@]+@[^>]+)>", r"[\1](mailto:\1)", d) for d in docstr.splitlines()]
@@ -381,6 +383,7 @@ def typefmt(
381383
raise SchemaSaladException("We should not be here!")
382384

383385
def render_type(self, f: dict[str, Any], depth: int) -> None:
386+
"""Render a type declaration."""
384387
if f["name"] in self.rendered or f["name"] in self.redirects:
385388
return
386389
self.rendered.add(f["name"])

schema_salad/ref_resolver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,11 @@ def _add_properties(self, s: str) -> None:
277277
self.foreign_properties.add(str(s))
278278

279279
def add_namespaces(self, ns: dict[str, str]) -> None:
280+
"""Add the given namespace to our vocab list."""
280281
self.vocab.update(ns)
281282

282283
def add_schemas(self, ns: Union[list[str], str], base_url: str) -> None:
284+
"""Fetch exernal schemas and add them to the graph."""
283285
if self.skip_schemas:
284286
return
285287
for sch in aslist(ns):

schema_salad/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ def make_avro_schema(
750750

751751

752752
def make_avro_schema_from_avro(avro: list[Union[Avro, dict[str, str], str]]) -> Names:
753+
"""Create avro.schema.Names from the given definitions."""
753754
names = Names()
754755
make_avsc_object(convert_to_dict(avro), names)
755756
return names

schema_salad/sourceline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def lineno(i: int, line: str) -> str:
8888

8989

9090
def bullets(textlist: list[str], bul: str) -> str:
91+
"""Indent using the specified number of bullets."""
9192
if len(textlist) == 1:
9293
return textlist[0]
9394
return "\n".join(indent(t, bullet=bul) for t in textlist)
@@ -245,6 +246,7 @@ def file(self) -> Optional[str]:
245246
return None
246247

247248
def start(self) -> Optional[tuple[int, int]]:
249+
"""Determine the starting location."""
248250
if self.file() is None:
249251
return None
250252
if self.key is None or self.item.lc.data is None or self.key not in self.item.lc.data:
@@ -255,6 +257,7 @@ def start(self) -> Optional[tuple[int, int]]:
255257
)
256258

257259
def end(self) -> Optional[tuple[int, int]]:
260+
"""Empty, for now."""
258261
return None
259262

260263
def makeLead(self) -> str:

0 commit comments

Comments
 (0)