annotate piecrust/commands/builtin/scaffolding.py @ 135:50b65c700c96

Don't use Werkzeug's reloader in non-debug mode unless we ask for it.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 25 Nov 2014 22:37:06 -0800
parents 69d5eecfa449
children 8355eb9dd8fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 import os
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 import os.path
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 import re
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 import io
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 import time
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 import logging
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 import textwrap
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 from piecrust import RESOURCES_DIR
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 from piecrust.chefutil import print_help_item
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 from piecrust.commands.base import ExtendableChefCommand, ChefCommandExtension
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 from piecrust.sources.base import IPreparingSource, MODE_CREATING
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 from piecrust.uriutil import multi_replace
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 logger = logging.getLogger(__name__)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 def make_title(slug):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 slug = re.sub(r'[\-_]', ' ', slug)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 return slug.title()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 class PrepareCommand(ExtendableChefCommand):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 """ Chef command for creating pages with some default content.
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 """
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 def __init__(self):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 super(PrepareCommand, self).__init__()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 self.name = 'prepare'
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 self.description = "Prepares new content for your website."
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31 def setupParser(self, parser, app):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
32 # Don't setup anything if this is a null app
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33 # (for when `chef` is run from outside a website)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
34 if app.root_dir is None:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
35 return
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
36
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
37 subparsers = parser.add_subparsers()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
38 for src in app.sources:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
39 if not isinstance(src, IPreparingSource):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
40 logger.debug("Skipping source '%s' because it's not "
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
41 "preparable." % src.name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
42 continue
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
43 if src.is_theme_source:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
44 logger.debug("Skipping source '%s' because it's a theme "
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
45 "source." % src.name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
46 continue
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
47 p = subparsers.add_parser(
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
48 src.item_name,
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49 help="Creates an empty page in the '%s' source." % src.name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 src.setupPrepareParser(p, app)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 p.add_argument('-t', '--template', default='default',
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
52 help="The template to use, which will change the "
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 "generated text and header.")
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
54 p.set_defaults(source=src)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
55
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
56 def run(self, ctx):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
57 app = ctx.app
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
58 source = ctx.args.source
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
59 metadata = source.buildMetadata(ctx.args)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
60 rel_path, metadata = source.findPagePath(metadata, MODE_CREATING)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
61 path = source.resolveRef(rel_path)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
62 name, ext = os.path.splitext(path)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
63 if ext == '.*':
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
64 path = '%s.%s' % (name,
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
65 app.config.get('site/default_auto_format'))
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
66 if os.path.exists(path):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
67 raise Exception("'%s' already exists." % path)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
68
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
69 tpl_name = ctx.args.template
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
70 extensions = self.getExtensions(app)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
71 ext = next(
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
72 filter(
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
73 lambda e: tpl_name in e.getTemplateNames(ctx.app),
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
74 extensions),
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
75 None)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
76 if ext is None:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
77 raise Exception("No such page template: %s" % tpl_name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
78
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
79 tpl_text = ext.getTemplate(ctx.app, tpl_name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
80 title = (metadata.get('slug') or metadata.get('path') or
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
81 'Untitled page')
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
82 title = make_title(title)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
83 tokens = {
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
84 '%title%': title,
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
85 '%time.today%': time.strftime('%Y/%m/%d'),
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
86 '%time.now%': time.strftime('%H:%M:%S')}
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
87 tpl_text = multi_replace(tpl_text, tokens)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
88
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
89 logger.info("Creating page: %s" % os.path.relpath(path, app.root_dir))
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
90 if not os.path.exists(os.path.dirname(path)):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
91 os.makedirs(os.path.dirname(path), 0o755)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
93 with open(path, 'w') as f:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
94 f.write(tpl_text)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
95
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
96
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
97 class DefaultPrepareTemplatesCommandExtension(ChefCommandExtension):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98 """ Provides the default scaffolding tempaltes to the `prepare`
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
99 command.
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
100 """
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
101 def __init__(self):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
102 super(DefaultPrepareTemplatesCommandExtension, self).__init__()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
103 self.command_name = 'prepare'
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
104
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
105 def getTemplateNames(self, app):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
106 return ['default', 'rss', 'atom']
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
107
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
108 def getTemplateDescription(self, app, name):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
109 descs = {
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
110 'default': "The default template, for a simple page.",
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
111 'rss': "A fully functional RSS feed.",
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
112 'atom': "A fully functional Atom feed."}
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
113 return descs[name]
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
114
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
115 def getTemplate(self, app, name):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
116 assert name in ['default', 'rss', 'atom']
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
117 src_path = os.path.join(RESOURCES_DIR, 'prepare', '%s.html' % name)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
118 with open(src_path, 'r', encoding='utf8') as fp:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
119 return fp.read()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
120
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
121
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
122 class DefaultPrepareTemplatesHelpTopic(ChefCommandExtension):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
123 """ Provides help topics for the `prepare` command.
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
124 """
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
125 command_name = 'help'
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
126
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
127 def getHelpTopics(self):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
128 return [('scaffolding',
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
129 "Available templates for the 'prepare' command.")]
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
130
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
131 def getHelpTopic(self, topic, app):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
132 with io.StringIO() as tplh:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
133 extensions = app.plugin_loader.getCommandExtensions()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
134 for e in extensions:
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
135 if e.command_name == 'prepare' and e.supports(app):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
136 for n in e.getTemplateNames(app):
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
137 d = e.getTemplateDescription(app, n)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
138 print_help_item(tplh, n, d)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
139 help_list = tplh.getvalue()
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
140
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
141 help_txt = (
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
142 textwrap.fill("Running the 'prepare' command will let "
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
143 "PieCrust setup a page for you in the correct place, with "
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
144 "some hopefully useful default text.") +
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
145 "\n\n" +
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
146 textwrap.fill("The following templates are available:") +
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
147 "\n\n" +
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
148 help_list)
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
149 return help_txt
69d5eecfa449 Better `prepare` command, with templates and help topics.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
150