forked from redhat-performance/tuned
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_plugin_docs.py
36 lines (28 loc) · 943 Bytes
/
compile_plugin_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse
import os
import inspect
from tuned.utils.plugin_loader import PluginLoader
from tuned.plugins.base import Plugin
class DocLoader(PluginLoader):
def __init__(self):
super(DocLoader, self).__init__()
def _set_loader_parameters(self):
self._namespace = "tuned.plugins"
self._prefix = "plugin_"
self._interface = Plugin
parser = argparse.ArgumentParser()
parser.add_argument("intro")
parser.add_argument("out")
args = parser.parse_args()
with open(args.intro, "r") as intro_file:
intro = intro_file.read()
all_plugins = sorted(DocLoader().load_all_plugins(), key=lambda x: x.__module__)
with open(args.out, "w") as out_file:
out_file.write(intro)
for plugin in all_plugins:
plugin_file = inspect.getfile(plugin)
plugin_name = os.path.basename(plugin_file)[7:-3]
out_file.write("\n")
out_file.write("== **%s**\n" % plugin_name)
out_file.write(inspect.cleandoc(plugin.__doc__))
out_file.write("\n")