-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate plugin documentation from their sources
This required a small refactoring of how field properties were stored. Instead of treating them as something owned by CLI options, they have their use outside of CLI area, and must exist in field metadata to be consumable in general. Now we have a template, a script, a section in docs. Fixing the content would be the next step...
- Loading branch information
Showing
14 changed files
with
304 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.. _plugins: | ||
.. _plugin_introduction: | ||
|
||
=========================== | ||
Plugin Introduction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
:tocdepth: 0 | ||
|
||
.. _/plugins/{{ STEP }}: | ||
|
||
{{ STEP | capitalize }} Plugins | ||
{{ '=' * (8 + (STEP | length)) }} | ||
|
||
{% for PLUGIN_ID in REGISTRY.iter_plugin_ids() %} | ||
{% set method = REGISTRY.get_plugin(PLUGIN_ID) %} | ||
{% set PLUGIN = method.class_ %} | ||
|
||
.. _plugins/{{ STEP }}/{{ PLUGIN_ID | strip }}: | ||
|
||
{{ PLUGIN_ID }} | ||
{{ '^' * (PLUGIN_ID | length)}} | ||
|
||
{% if PLUGIN.__doc__ %} | ||
{{ PLUGIN.__doc__ | dedent | strip }} | ||
{% endif %} | ||
|
||
**Configuration** | ||
|
||
{% for field in container_fields(PLUGIN._data_class) %} | ||
{% if field.name in ('how', 'name', 'where') and field.internal != true %} | ||
{% set _, option, _, metadata = container_field(PLUGIN._data_class, field.name) %} | ||
|
||
{% if metadata.metavar %} | ||
{{ option }}: ``{{ metadata.metavar }}`` | ||
{% elif metadata.default is boolean %} | ||
{{ option }}: ``true|false`` | ||
{% else %} | ||
{{ option }}: | ||
{% endif %} | ||
{% if metadata.help %} | ||
{{ metadata.help | strip | indent(4, first=true) }} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if not loop.last %} | ||
---- | ||
{% endif %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.. _plugins: | ||
|
||
Plugins | ||
======= | ||
|
||
Here you will find documentation for plugins shipped with tmt. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
Discover <discover> | ||
Provision <provision> | ||
Prepare <prepare> | ||
Execute <execute> | ||
Finish <finish> | ||
Report <report> | ||
Test checks <test-checks> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import textwrap | ||
|
||
import tmt.log | ||
import tmt.plugins | ||
import tmt.steps.discover | ||
import tmt.steps.execute | ||
import tmt.steps.finish | ||
import tmt.steps.prepare | ||
import tmt.steps.provision | ||
import tmt.steps.report | ||
import tmt.utils | ||
from tmt.utils import Path, render_template_file | ||
|
||
HELP = textwrap.dedent(""" | ||
Usage: generate-plugins.py <STEP-NAME> <TEMPLATE-PATH> <OUTPUT-PATH> | ||
Generate pages for step plugins sources. | ||
""").strip() | ||
|
||
|
||
def main() -> None: | ||
if len(sys.argv) != 4: | ||
print(HELP) | ||
|
||
sys.exit(1) | ||
|
||
step_name = sys.argv[1] | ||
template_filepath = Path(sys.argv[2]) | ||
output_filepath = Path(sys.argv[3]) | ||
|
||
# We will need a logger... | ||
logger = tmt.log.Logger.create() | ||
logger.add_console_handler() | ||
|
||
# ... explore available plugins... | ||
tmt.plugins.explore(logger) | ||
|
||
if step_name == 'discover': | ||
registry = tmt.steps.discover.DiscoverPlugin._supported_methods | ||
|
||
elif step_name == 'execute': | ||
registry = tmt.steps.execute.ExecutePlugin._supported_methods | ||
|
||
elif step_name == 'finish': | ||
registry = tmt.steps.finish.FinishPlugin._supported_methods | ||
|
||
elif step_name == 'prepare': | ||
registry = tmt.steps.prepare.PreparePlugin._supported_methods | ||
|
||
elif step_name == 'provision': | ||
registry = tmt.steps.provision.ProvisionPlugin._supported_methods | ||
|
||
elif step_name == 'report': | ||
registry = tmt.steps.report.ReportPlugin._supported_methods | ||
|
||
else: | ||
raise tmt.utils.GeneralError(f"Unhandled step name '{step_name}'.") | ||
|
||
# ... and render the template. | ||
output_filepath.write_text(render_template_file( | ||
template_filepath, | ||
STEP=step_name, | ||
REGISTRY=registry, | ||
container_fields=tmt.utils.container_fields, | ||
container_field=tmt.utils.container_field)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.