Unverified Commit 29211740 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Make weights tables row size smaller (#5904)

* Custom class for weights table

* Proper CSS
parent e0467c64
/* This rule (and possibly this entire file) should be removed once
/* This rule should be removed once
https://github.com/pytorch/pytorch_sphinx_theme/issues/125 is fixed.
We override the rule so that the links to the notebooks aren't hidden in the
......@@ -10,3 +10,14 @@ article.pytorch-article .sphx-glr-download-link-note.admonition.note,
article.pytorch-article .reference.download.internal, article.pytorch-article .sphx-glr-signature {
display: block;
}
/* These 2 rules below are for the weight tables (generated in conf.py) to look
* better. In particular we make their row height shorter */
.table-weights td, .table-weights th {
margin-bottom: 0.2rem;
padding: 0 !important;
line-height: 1 !important;
}
.table-weights p {
margin-bottom: 0.2rem !important;
}
......@@ -342,6 +342,7 @@ def inject_weight_metadata(app, what, name, obj, options, lines):
v = f"`link <{v}>`__"
table.append((str(k), str(v)))
table = tabulate(table, tablefmt="rst")
lines += [".. rst-class:: table-weights"] # Custom CSS class, see custom_torchvision.css
lines += [".. table::", ""]
lines += textwrap.indent(table, " " * 4).split("\n")
lines.append("")
......@@ -369,6 +370,7 @@ def generate_weights_table(module, table_name, metrics):
generated_dir = Path("generated")
generated_dir.mkdir(exist_ok=True)
with open(generated_dir / f"{table_name}_table.rst", "w+") as table_file:
table_file.write(".. rst-class:: table-weights\n") # Custom CSS class, see custom_torchvision.css
table_file.write(".. table::\n")
table_file.write(f" :widths: 100 {'20 ' * len(metrics_names)} 20 10\n\n")
table_file.write(f"{textwrap.indent(table, ' ' * 4)}\n\n")
......
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