/
quickstart.patch
350 lines (309 loc) · 12.2 KB
/
quickstart.patch
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# HG changeset patch
# Parent e6a739003667615559936c787600975362279220
diff -r e6a739003667 setup.py
--- a/setup.py Mon Apr 26 15:37:37 2010 -0400
+++ b/setup.py Mon Apr 26 15:42:10 2010 -0400
@@ -42,7 +42,7 @@
<http://bitbucket.org/birkenfeld/sphinx/get/tip.gz#egg=Sphinx-dev>`_.
'''
-requires = ['Pygments>=0.8', 'Jinja2>=2.2', 'docutils>=0.4']
+requires = ['Pygments>=0.8', 'Jinja2>=2.2', 'docutils>=0.4', 'mercurial>=1.5']
if sys.version_info < (2, 4):
print 'ERROR: Sphinx requires at least Python 2.4 to run.'
diff -r e6a739003667 sphinx/quickstart.py
--- a/sphinx/quickstart.py Mon Apr 26 15:37:37 2010 -0400
+++ b/sphinx/quickstart.py Mon Apr 26 15:42:10 2010 -0400
@@ -19,6 +19,7 @@
from sphinx.util.console import purple, bold, red, turquoise, \
nocolor, color_terminal
from sphinx.util import texescape
+from mercurial import commands as HG_commands, ui as HG_ui, hg as HG
PROMPT_PREFIX = '> '
@@ -66,17 +67,19 @@
master_doc = '%(master_str)s'
# General information about the project.
-project = u'%(project_str)s'
-copyright = u'%(copyright_str)s'
+project = u"""%(project_str)s"""
+copyright = u"""%(copyright_str)s"""
+enable_comments = %(enable_comments)s
+disqus_site = u"""%(disqus_site_str)s"""
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '%(version_str)s'
+#version = '%(version_str)s'
# The full version, including alpha/beta/rc tags.
-release = '%(release_str)s'
+#release = '%(release_str)s'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -90,7 +93,12 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
-exclude_patterns = [%(exclude_patterns)s]
+
+def get_excludes():
+ from hgblog.utils import get_untracked_rst_files
+ return get_untracked_rst_files()
+
+exclude_patterns = get_excludes() + [%(exclude_patterns)s]
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
@@ -117,7 +125,7 @@
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
+html_theme = 'conjunction'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -129,7 +137,7 @@
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
-#html_title = None
+html_title = u"""%(project_str)s"""
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
@@ -232,7 +240,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('%(master_str)s', '%(project_manpage)s', u'%(project_doc)s',
- [u'%(author_str)s'], 1)
+ [u"""%(author_str)s"""], 1)
]
'''
@@ -241,10 +249,10 @@
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
-epub_title = u'%(project_str)s'
-epub_author = u'%(author_str)s'
-epub_publisher = u'%(author_str)s'
-epub_copyright = u'%(copyright_str)s'
+epub_title = u"""%(project_str)s"""
+epub_author = u"""%(author_str)s"""
+epub_publisher = u"""%(author_str)s"""
+epub_copyright = u"""%(copyright_str)s"""
# The language of the text. It defaults to the language option
# or en if the language is not set.
@@ -282,28 +290,36 @@
'''
MASTER_FILE = '''\
-.. %(project)s documentation master file, created by
- sphinx-quickstart on %(now)s.
+.. %(project)s master file, created by hgblog-quickstart on %(now)s.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Welcome to %(project)s's documentation!
-===========%(underline)s=================
+%(project)s
+%(underline)s
Contents:
.. toctree::
:maxdepth: 2
-Indices and tables
-==================
+ about
+
+Links
+=====
* :ref:`genindex`
-* :ref:`modindex`
* :ref:`search`
'''
+ABOUT_FILE = '''\
+========
+About Me
+========
+
+This is the about me page.
+'''
+
MAKEFILE = '''\
# Makefile for Sphinx documentation
#
@@ -671,27 +687,35 @@
def inner_main(args):
- d = {}
+ d = {
+ 'sep': True,
+ 'dot': '_',
+ 'version': '',
+ 'release': '',
+ 'suffix': '.rst',
+ 'master': 'index',
+ 'epub': False,
+ 'disqus_site': '',
+ }
texescape.init()
if not color_terminal():
nocolor()
- print bold('Welcome to the Sphinx %s quickstart utility.') % __version__
+ print bold('Welcome to the HgBlog %s quickstart utility.') % __version__
print '''
Please enter values for the following settings (just press Enter to
-accept a default value, if one is given in brackets).'''
+accept a default value, if one is given in brackets).
- print '''
-Enter the root path for documentation.'''
- do_prompt(d, 'path', 'Root path for the documentation', '.', is_path)
+Enter the root path for your blog articles.'''
+ do_prompt(d, 'path', 'Root path for your blog articles', '.', is_path)
while path.isfile(path.join(d['path'], 'conf.py')) or \
path.isfile(path.join(d['path'], 'source', 'conf.py')):
print
print bold('Error: an existing conf.py has been found in the '
'selected root path.')
- print 'sphinx-quickstart will not overwrite existing Sphinx projects.'
+ print 'hgblog-quickstart will not overwrite existing HgBlog projects.'
print
do_prompt(d, 'path', 'Please enter a new root path (or just Enter '
'to exit)', '', is_path)
@@ -699,56 +723,14 @@
sys.exit(1)
print '''
-You have two options for placing the build directory for Sphinx output.
-Either, you use a directory "_build" within the root path, or you separate
-"source" and "build" directories within the root path.'''
- do_prompt(d, 'sep', 'Separate source and build directories (y/N)', 'n',
- boolean)
+The blog name will occur in several places in the HTML.'''
+ do_prompt(d, 'project', 'Blog name')
+ do_prompt(d, 'author', 'Author name(s)')
+ do_prompt(d, 'enable_comments', 'Would you like to enable Disqus comments '
+ 'on your pages?', 'y', boolean)
- print '''
-Inside the root directory, two more directories will be created; "_templates"
-for custom HTML templates and "_static" for custom stylesheets and other static
-files. You can enter another prefix (such as ".") to replace the underscore.'''
- do_prompt(d, 'dot', 'Name prefix for templates and static dir', '_', ok)
-
- print '''
-The project name will occur in several places in the built documentation.'''
- do_prompt(d, 'project', 'Project name')
- do_prompt(d, 'author', 'Author name(s)')
- print '''
-Sphinx has the notion of a "version" and a "release" for the
-software. Each version can have multiple releases. For example, for
-Python the version is something like 2.5 or 3.0, while the release is
-something like 2.5.1 or 3.0a1. If you don't need this dual structure,
-just set both to the same value.'''
- do_prompt(d, 'version', 'Project version')
- do_prompt(d, 'release', 'Project release', d['version'])
- print '''
-The file name suffix for source files. Commonly, this is either ".txt"
-or ".rst". Only files with this suffix are considered documents.'''
- do_prompt(d, 'suffix', 'Source file suffix', '.rst', suffix)
- print '''
-One document is special in that it is considered the top node of the
-"contents tree", that is, it is the root of the hierarchical structure
-of the documents. Normally, this is "index", but if your "index"
-document is a custom template, you can also set this to another filename.'''
- do_prompt(d, 'master', 'Name of your master document (without suffix)',
- 'index')
-
- while path.isfile(path.join(d['path'], d['master']+d['suffix'])) or \
- path.isfile(path.join(d['path'], 'source', d['master']+d['suffix'])):
- print
- print bold('Error: the master file %s has already been found in the '
- 'selected root path.' % (d['master']+d['suffix']))
- print 'sphinx-quickstart will not overwrite the existing file.'
- print
- do_prompt(d, 'master', 'Please enter a new file name, or rename the '
- 'existing file and press Enter', d['master'])
-
- print '''
-Sphinx can also add configuration for epub output:'''
- do_prompt(d, 'epub', 'Do you want to use the epub builder (y/N)',
- 'n', boolean)
+ if d['enable_comments']:
+ do_prompt(d, 'disqus_site', 'What is the name of your Disqus site?')
print '''
Please indicate if you want to use one of the following Sphinx extensions:'''
@@ -775,7 +757,7 @@
'of documented Python objects (y/N)', 'n', boolean)
print '''
A Makefile and a Windows command file can be generated for you so that you
-only have to run e.g. `make html' instead of invoking sphinx-build
+only have to run e.g. `make html' instead of invoking hgbuild-build
directly.'''
do_prompt(d, 'makefile', 'Create Makefile? (Y/n)', 'y', boolean)
do_prompt(d, 'batchfile', 'Create Windows command file? (Y/n)',
@@ -793,19 +775,42 @@
d['copyright'] = time.strftime('%Y') + ', ' + d['author']
d['author_texescaped'] = unicode(d['author']).\
translate(texescape.tex_escape_map)
- d['project_doc'] = d['project'] + ' Documentation'
- d['project_doc_texescaped'] = unicode(d['project'] + ' Documentation').\
+ d['project_doc'] = d['project']
+ d['project_doc_texescaped'] = unicode(d['project']).\
translate(texescape.tex_escape_map)
# escape backslashes and single quotes in strings that are put into
# a Python string literal
for key in ('project', 'copyright', 'author', 'author_texescaped',
- 'project_doc_texescaped', 'version', 'release', 'master'):
+ 'project_doc_texescaped', 'version', 'release', 'master',
+ 'disqus_site'):
d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")
if not path.isdir(d['path']):
mkdir_p(d['path'])
+ # Create a mercurial repo
+ hg_ui = HG_ui.ui()
+ HG_commands.init(hg_ui, d['path'])
+ hg_repo = HG.repository(hg_ui, d['path'])
+
+ # Create an ignores file for HG
+ ignores = path.join(d['path'], '.hgignore')
+ open(ignores, 'w').write('''syntax: glob
+*.swp
+*.swo
+*~
+build
+.DS_Store
+''')
+
+ # Add our hooks
+ hooks = path.join(d['path'], '.hg', 'hgrc')
+ open(hooks, 'w').write('''[hooks]
+update.hgblog = python:hgblog.generate_html.htmlize_articles
+commit.hgblog = python:hgblog.generate_html.htmlize_articles
+''')
+
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
mkdir_p(srcdir)
@@ -834,6 +839,11 @@
f.write((MASTER_FILE % d).encode('utf-8'))
f.close()
+ aboutfile = path.join(srcdir, 'about%s' % d['suffix'])
+ f = open(aboutfile, 'w')
+ f.write((ABOUT_FILE % d).encode('utf-8'))
+ f.close()
+
if d['makefile']:
d['rsrcdir'] = d['sep'] and 'source' or '.'
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
@@ -849,20 +859,13 @@
f.write((BATCHFILE % d).encode('utf-8'))
f.close()
+ # Add the newest files to the repo
+ HG_commands.add(hg_ui, hg_repo)
+ HG_commands.commit(hg_ui, hg_repo, message='Initial commit. Created blog.')
+
print
print bold('Finished: An initial directory structure has been created.')
- print '''
-You should now populate your master file %s and create other documentation
-source files. ''' % masterfile + ((d['makefile'] or d['batchfile']) and '''\
-Use the Makefile to build the docs, like so:
- make builder
-''' or '''\
-Use the sphinx-build command to build the docs, like so:
- sphinx-build -b builder %s %s
-''' % (srcdir, builddir)) + '''\
-where "builder" is one of the supported builders, e.g. html, latex or linkcheck.
-'''
-
+ print '''You should now create some blog articles.'''
def main(argv=sys.argv):
try: