2021-04-11 11:34:14 +02:00
|
|
|
#!/usr/bin/env python3
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-17 17:58:47 +02:00
|
|
|
import importlib
|
2011-06-28 08:11:32 +02:00
|
|
|
import os
|
2021-04-11 11:34:14 +02:00
|
|
|
import pkgutil
|
|
|
|
import subprocess
|
|
|
|
import textwrap
|
|
|
|
|
|
|
|
import supybot.plugins
|
|
|
|
|
|
|
|
OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "use", "plugins")
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
def iter_subpackages(package):
|
|
|
|
for importer, modname, ispkg in pkgutil.iter_modules(package.__path__):
|
|
|
|
if ispkg:
|
|
|
|
yield modname
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
subprocess.run([
|
|
|
|
"supybot-plugin-doc",
|
|
|
|
"--plugins-dir", os.path.dirname(supybot.plugins.__file__),
|
|
|
|
"-o", OUTPUT_DIR,
|
|
|
|
"-f", "rst",
|
|
|
|
"--title-template", "$name",
|
|
|
|
], check=True)
|
2011-10-29 13:28:46 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
plugins = list(iter_subpackages(supybot.plugins))
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
with open(os.path.join(OUTPUT_DIR, "index.rst"), "w") as fd:
|
|
|
|
fd.write(
|
|
|
|
textwrap.dedent(
|
|
|
|
"""
|
|
|
|
Built-in plugins reference
|
|
|
|
==========================
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
Here is a list of all built-in plugins and their commands
|
|
|
|
and configuration.
|
|
|
|
For an overview of all major plugins, see
|
|
|
|
`Limnoria.net's plugin page`_
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
.. _Limnoria.net's plugin page: https://limnoria.net/plugins.xhtml
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-17 17:58:47 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
for plugin in plugins:
|
|
|
|
if plugin == "Alias":
|
|
|
|
# Deprecated
|
|
|
|
continue
|
|
|
|
plugin_module = importlib.import_module(f"supybot.plugins.{plugin}")
|
|
|
|
fd.write(f":doc:`{plugin} <{plugin}>`\n")
|
|
|
|
fd.write(textwrap.indent(plugin_module.__doc__, " "))
|
|
|
|
fd.write("\n")
|
|
|
|
|
|
|
|
fd.write(
|
|
|
|
textwrap.dedent(
|
|
|
|
"""
|
2021-04-11 11:34:14 +02:00
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 1
|
2021-04-17 17:58:47 +02:00
|
|
|
:hidden:
|
2011-06-28 08:11:32 +02:00
|
|
|
|
2021-04-11 11:34:14 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for plugin in plugins:
|
|
|
|
fd.write(f" {plugin}\n")
|