Commit 82387959 authored by Nic's avatar Nic
Browse files

improve autodoc

parent 195c10be
......@@ -211,13 +211,19 @@ class VDataAutodoc:
df.drop(columns="anyOf", inplace=True)
df = df.fillna("")
df.index.names = ["column"]
df.reset_index(inplace=True)
# -------------------------------------------------------------
# process special columns
if "mandatory" in df.columns:
df["mandatory"] = pd.Series(
dict(zip(schema.required, [True] * len(schema.required)))
)
mandatory = dict(zip(schema.required, [True] * len(schema.required)))
_uniq = dict(schema.uniqueness_sets)
if _uniq:
uniq = {}
for id, cols in _uniq.items():
for col in cols:
uniq[col] = id
df["set"] = pd.Series(uniq)
df["set"] = df.set.fillna("")
if mandatory:
df["mandatory"] = pd.Series(mandatory)
df["mandatory"] = df.mandatory.fillna("")
if "type" in df.columns:
df["type"] = df["type"].replace(
......@@ -229,6 +235,7 @@ class VDataAutodoc:
)
# -------------------------------------------------------------
# bold index
df.reset_index(inplace=True)
df["column"] = "**" + df["column"].astype(str) + "**"
# -------------------------------------------------------------
# order columns
......@@ -253,6 +260,11 @@ class VDataAutodoc:
df, headers="keys", tablefmt="rst", showindex=False
)
fh.write(_write(table))
if _uniq:
fh.write(_write("the following sets of columns combination need to be **unique**:"))
for uniq, cols in _uniq.items():
columns = ", ".join([f"``{c}``" for c in cols])
fh.write(_write(f" * ``{uniq}``: {columns}"))
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment