mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
supybot-plugin-doc: Add config option for the page title
This commit is contained in:
parent
a7fb46f526
commit
5b98503fd3
@ -33,6 +33,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import string
|
||||||
|
|
||||||
import supybot
|
import supybot
|
||||||
|
|
||||||
@ -77,12 +78,15 @@ import supybot.registry as registry
|
|||||||
|
|
||||||
world.documenting = True
|
world.documenting = True
|
||||||
|
|
||||||
|
TITLE_TEMPLATE = 'Documentation for the $name plugin for Supybot'
|
||||||
|
|
||||||
class PluginDoc(object):
|
class PluginDoc(object):
|
||||||
def __init__(self, mod):
|
def __init__(self, mod, titleTemplate):
|
||||||
self.mod = mod
|
self.mod = mod
|
||||||
self.inst = self.mod.Class(None)
|
self.inst = self.mod.Class(None)
|
||||||
self.name = self.mod.Class.__name__
|
self.name = self.mod.Class.__name__
|
||||||
self.appendExtraBlankLine = False
|
self.appendExtraBlankLine = False
|
||||||
|
self.titleTemplate = string.Template(titleTemplate)
|
||||||
self.lines = []
|
self.lines = []
|
||||||
|
|
||||||
def appendLine(self, line, indent=0):
|
def appendLine(self, line, indent=0):
|
||||||
@ -97,7 +101,7 @@ class PluginDoc(object):
|
|||||||
|
|
||||||
def renderRST(self):
|
def renderRST(self):
|
||||||
self.appendExtraBlankLine = False
|
self.appendExtraBlankLine = False
|
||||||
s = 'Documentation for the %s plugin for Supybot' % self.name
|
s = self.titleTemplate.substitute(name=self.name)
|
||||||
self.appendLine(s)
|
self.appendLine(s)
|
||||||
self.appendLine('=' * len(s))
|
self.appendLine('=' * len(s))
|
||||||
self.lines.append('')
|
self.lines.append('')
|
||||||
@ -156,8 +160,7 @@ class PluginDoc(object):
|
|||||||
|
|
||||||
def renderSTX(self):
|
def renderSTX(self):
|
||||||
self.appendExtraBlankLine = True
|
self.appendExtraBlankLine = True
|
||||||
self.appendLine('Documentation for the %s plugin for '
|
self.appendLine(self.titleTemplate.substitute(name=self.name))
|
||||||
'Supybot' % self.name)
|
|
||||||
self.appendLine('Purpose', 1)
|
self.appendLine('Purpose', 1)
|
||||||
pdoc = getattr(self.mod, '__doc__',
|
pdoc = getattr(self.mod, '__doc__',
|
||||||
'My author didn\'t give me a purpose.')
|
'My author didn\'t give me a purpose.')
|
||||||
@ -227,7 +230,7 @@ class PluginDoc(object):
|
|||||||
yield confValues
|
yield confValues
|
||||||
|
|
||||||
def genDoc(m, options):
|
def genDoc(m, options):
|
||||||
Plugin = PluginDoc(m)
|
Plugin = PluginDoc(m, options.titleTemplate)
|
||||||
print('Generating documentation for %s...' % Plugin.name)
|
print('Generating documentation for %s...' % Plugin.name)
|
||||||
path = os.path.join(options.outputDir, '%s.%s' % (Plugin.name,
|
path = os.path.join(options.outputDir, '%s.%s' % (Plugin.name,
|
||||||
options.format))
|
options.format))
|
||||||
@ -265,6 +268,9 @@ if __name__ == '__main__':
|
|||||||
action='append', dest='pluginsDirs', default=[],
|
action='append', dest='pluginsDirs', default=[],
|
||||||
help='Looks in in the given directory for plugins and '
|
help='Looks in in the given directory for plugins and '
|
||||||
'generates documentation for all of them.')
|
'generates documentation for all of them.')
|
||||||
|
parser.add_option('--title-template',
|
||||||
|
default=TITLE_TEMPLATE, dest='titleTemplate',
|
||||||
|
help='Template string for the title of generated files')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# This must go before checking for args, of course.
|
# This must go before checking for args, of course.
|
||||||
|
Loading…
Reference in New Issue
Block a user