From 1f0aeef897ac2594ce1bdf805d245bd8364b65e2 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 12 May 2022 16:48:41 +0100 Subject: [PATCH] Handle empty weights in doc generation --- docs/source/conf.py | 5 +++++ torchvision/models/mnasnet.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index f4b38075c8b..940098bfed5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -316,6 +316,11 @@ def inject_weight_metadata(app, what, name, obj, options, lines): """ if obj.__name__.endswith(("_Weights", "_QuantizedWeights")): + + if len(obj) == 0: + lines[:] = ["There are no available pre-trained weights."] + return + lines[:] = [ "The model builder above accepts the following values as the ``weights`` parameter.", f"``{obj.__name__}.DEFAULT`` is equivalent to ``{obj.DEFAULT}``.", diff --git a/torchvision/models/mnasnet.py b/torchvision/models/mnasnet.py index 7f4751f12a3..6f403fb5e30 100644 --- a/torchvision/models/mnasnet.py +++ b/torchvision/models/mnasnet.py @@ -316,6 +316,8 @@ def mnasnet0_75(*, weights: Optional[MNASNet0_75_Weights] = None, progress: bool `_ for more details about this class. + .. autoclass:: torchvision.models.MNASNet0_75_Weights + :members: """ weights = MNASNet0_75_Weights.verify(weights) @@ -366,6 +368,8 @@ def mnasnet1_3(*, weights: Optional[MNASNet1_3_Weights] = None, progress: bool = `_ for more details about this class. + .. autoclass:: torchvision.models.MNASNet1_3_Weights + :members: """ weights = MNASNet1_3_Weights.verify(weights)