From c07a2e9cf61e749a4e002df1bf1867b86bd9a427 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 25 Jun 2018 17:27:20 +0100 Subject: [PATCH] Parse 'driver-notes-XXX' values This seems to have been missed in the import from nova. Change-Id: Ic38c16aca1e94a9a06ad6efc7f53772b660b68da Signed-off-by: Stephen Finucane --- doc/source/user/index.rst | 7 ++++++- .../support-driver-notes-b73d5b185f05db7f.yaml | 14 ++++++++++++++ sphinx_feature_classification/support_matrix.py | 14 ++++++++++++-- .../tests/fakes/support-matrix.ini | 1 + .../tests/test_sphinx_feature_classification.py | 10 ++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/support-driver-notes-b73d5b185f05db7f.yaml diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst index 957f3ec..a6c35d0 100644 --- a/doc/source/user/index.rst +++ b/doc/source/user/index.rst @@ -152,7 +152,8 @@ for every driver defined earlier in the file. :Mandatory: No Additional information about the implementation of this feature in driver - ``XXX``. + ``XXX``. While this is optional, it is highly recommended for implementations + in the ``partial`` state. For example: @@ -175,6 +176,8 @@ For example: block storage from a running instance. cli=my-project detach-volume driver.slow-driver=complete + driver-notes.slow-driver=Works without issue if instance is off. When + hotplugging, requires version foo of the driver. driver.fast-driver=complete Notice that a driver is only required to implement detach-volume if they @@ -213,4 +216,6 @@ This is simply the combined example from above. block storage from a running instance. cli=my-project detach-volume driver.slow-driver=complete + driver-notes.slow-driver=Works without issue if instance is off. When + hotplugging, requires version foo of the driver. driver.fast-driver=complete diff --git a/releasenotes/notes/support-driver-notes-b73d5b185f05db7f.yaml b/releasenotes/notes/support-driver-notes-b73d5b185f05db7f.yaml new file mode 100644 index 0000000..bf90694 --- /dev/null +++ b/releasenotes/notes/support-driver-notes-b73d5b185f05db7f.yaml @@ -0,0 +1,14 @@ +--- +features: + - | + You can now specify ``driver-notes.XXX`` values. These are useful to + provide additional context for features with a status of ``partial``. For + example:: + + [operation.Cool_Feature] + title=Cool Feature + status=optional + notes=A pretty darn cool feature. + driver.foo=complete + driver.bar=partial + driver-notes.bar=Requires hardware support. diff --git a/sphinx_feature_classification/support_matrix.py b/sphinx_feature_classification/support_matrix.py index 26d0934..1aefb7b 100644 --- a/sphinx_feature_classification/support_matrix.py +++ b/sphinx_feature_classification/support_matrix.py @@ -104,7 +104,13 @@ class Matrix(object): "one of (%s)" % (option, status, section, ", ".join( Implementation.STATUS_ALL))) - impl = Implementation(status) + option_notes = ''.join([DRIVER_NOTES_PREFIX, + option[len(DRIVER_PREFIX):]]) + notes = None + if cfg.has_option(section, option_notes): + notes = cfg.get(section, option_notes) + + impl = Implementation(status=status, notes=notes) feature.implementations[option] = impl return feature @@ -160,8 +166,9 @@ class Implementation(object): STATUS_ALL = [STATUS_COMPLETE, STATUS_MISSING, STATUS_PARTIAL, STATUS_UNKNOWN] - def __init__(self, status=STATUS_MISSING): + def __init__(self, status=STATUS_MISSING, notes=None): self.status = status + self.notes = notes STATUS_SYMBOLS = { @@ -375,6 +382,9 @@ class Directive(rst.Directive): ids=[key_id]), ] + if impl.notes is not None: + subitem.append(self._create_notes_paragraph(impl.notes)) + impls.append(subitem) para_divers.append(impls) diff --git a/sphinx_feature_classification/tests/fakes/support-matrix.ini b/sphinx_feature_classification/tests/fakes/support-matrix.ini index 66b32ea..52a5197 100644 --- a/sphinx_feature_classification/tests/fakes/support-matrix.ini +++ b/sphinx_feature_classification/tests/fakes/support-matrix.ini @@ -12,3 +12,4 @@ status=optional notes=A pretty darn cool feature. driver.foo=complete driver.bar=partial +driver-notes.bar=Requires hardware support. diff --git a/sphinx_feature_classification/tests/test_sphinx_feature_classification.py b/sphinx_feature_classification/tests/test_sphinx_feature_classification.py index fc1d633..86c9d32 100644 --- a/sphinx_feature_classification/tests/test_sphinx_feature_classification.py +++ b/sphinx_feature_classification/tests/test_sphinx_feature_classification.py @@ -58,3 +58,13 @@ class MatrixTestCase(base.TestCase): fake_driver = self.matrix.drivers[key] self.assertEqual(title, fake_driver.title) self.assertEqual(link, fake_driver.link) + + @ddt.unpack + @ddt.data({'key': 'driver.foo', 'status': 'complete', + 'notes': None}, + {'key': 'driver.bar', 'status': 'partial', + 'notes': 'Requires hardware support.'}) + def test_implementations_set(self, key, status, notes): + fake_implementation = self.matrix.features[0].implementations[key] + self.assertEqual(status, fake_implementation.status) + self.assertEqual(notes, fake_implementation.notes)