Skip to content

Commit

Permalink
Generate documentation for prepare/feature plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Jan 9, 2025
1 parent d686811 commit 6fb5fb2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ docs/plugins/finish.rst
docs/plugins/prepare.rst
docs/plugins/provision.rst
docs/plugins/report.rst
docs/plugins/prepare-feature.rst
docs/plugins/test-checks.rst
docs/plugins/hardware-matrix.rst
docs/guide/test-runner-guest-compatibility-matrix.inc.rst
Expand Down
10 changes: 9 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GENERATED_DIRECTORIES = spec stories
STEPS = discover provision prepare execute finish report

# A list of `plugins/*.rst` files to generate
PLUGIN_TARGETS = $(addsuffix .rst,$(addprefix plugins/,$(STEPS))) plugins/test-checks.rst
PLUGIN_TARGETS = $(addsuffix .rst,$(addprefix plugins/,$(STEPS))) plugins/prepare-feature.rst plugins/test-checks.rst

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -64,6 +64,11 @@ define plugins-dependencies =
$(SCRIPTSDIR)/generate-plugins.py $(PLUGINS_TEMPLATE) $(TMTDIR)/steps/__init__.py $(TMTDIR)/steps/$(call plugins-to-step,$@)/*.py
endef

# Render a list of dependencies of a `plugins/feature.rst` target
define plugins-feature-dependencies =
$(SCRIPTSDIR)/generate-plugins.py $(PLUGINS_TEMPLATE) $(TMTDIR)/steps/__init__.py $(TMTDIR)/steps/prepare/__init__.py $(TMTDIR)/steps/prepare/feature/*.py
endef

# Render a list of dependencies of a `plugins/test-checks.rst` target
define plugins-checks-dependencies =
$(SCRIPTSDIR)/generate-plugins.py $(PLUGINS_TEMPLATE) $(TMTDIR)/steps/__init__.py $(TMTDIR)/checks/*.py
Expand Down Expand Up @@ -97,6 +102,9 @@ plugins/provision.rst: $(call plugins-dependencies)
plugins/report.rst: $(call plugins-dependencies)
$(call build-plugins)

plugins/prepare-feature.rst: $(call plugins-feature-dependencies)
$(call build-plugins)

plugins/test-checks.rst: $(call plugins-checks-dependencies)
$(call build-plugins)

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Here you will find documentation for plugins shipped with tmt.
Execute <execute>
Finish <finish>
Report <report>
prepare/feature <prepare-feature>
Test Checks <test-checks>
Empty file.
7 changes: 7 additions & 0 deletions docs/plugins/prepare-header.inc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prepare/feature plugins
-----------------------

Features available via :ref:`prepare/feature</plugins/prepare/feature>`
plugin are implemented and shipped as plugins. See
:ref:`/plugins/prepare-feature` for the list of available feature
plugins and their configuration.
20 changes: 20 additions & 0 deletions docs/scripts/generate-plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import tmt.steps.execute
import tmt.steps.finish
import tmt.steps.prepare
import tmt.steps.prepare.feature
import tmt.steps.provision
import tmt.steps.report
import tmt.utils
Expand Down Expand Up @@ -125,6 +126,21 @@ def plugin_iterator():
return plugin_iterator


def _create_feature_plugin_iterator(
registry: tmt.plugins.PluginRegistry[tmt.steps.prepare.feature.FeatureClass]):
""" Create iterator over plugins of a feature plugin registry """

def plugin_iterator():
for plugin_id in registry.iter_plugin_ids():
plugin = registry.get_plugin(plugin_id)

# TODO: once data class becomes composed from plugin data
# classes, the main one is all we have.
yield plugin_id, plugin, tmt.steps.prepare.feature.PrepareFeature._data_class

return plugin_iterator


def _create_test_check_plugin_iterator(registry: tmt.plugins.PluginRegistry[tmt.steps.Method]):
""" Create iterator over plugins of a test check registry """

Expand Down Expand Up @@ -178,6 +194,10 @@ def main() -> None:
plugin_generator = _create_step_plugin_iterator(
tmt.steps.report.ReportPlugin._supported_methods)

elif step_name == 'prepare-feature':
plugin_generator = _create_feature_plugin_iterator(
tmt.steps.prepare.feature._FEATURE_PLUGIN_REGISTRY)

elif step_name == 'test-checks':
plugin_generator = _create_test_check_plugin_iterator(tmt.checks._CHECK_PLUGIN_REGISTRY)

Expand Down
2 changes: 1 addition & 1 deletion docs/templates/plugins.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

.. _/plugins/{{ STEP }}:

{{ STEP | replace('-', ' ') | capitalize }} Plugins
{% if STEP == 'prepare-feature' %}prepare/feature{% else %}{{ STEP | replace('-', ' ') | capitalize }}{% endif %} Plugins
{{ '~' * (8 + (STEP | length)) }}

.. include:: {{ STEP }}-header.inc.rst
Expand Down
3 changes: 3 additions & 0 deletions tmt/steps/prepare/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ class PrepareFeature(tmt.steps.prepare.PreparePlugin[PrepareFeatureData]):
prepare:
how: feature
epel: disabled
See :ref:`/plugins/prepare-feature` for the list of available
feature plugins and their configuration.
"""

_data_class = PrepareFeatureData
Expand Down

0 comments on commit 6fb5fb2

Please sign in to comment.