Source

hgblog / 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# HG changeset patch
# Parent 9acbf8c69f2f53cce827d8d130a42ac64d36af89

diff -r 9acbf8c69f2f setup.py
--- a/setup.py	Fri Sep 30 00:48:18 2011 -0400
+++ b/setup.py	Fri Sep 30 00:56:12 2011 -0400
@@ -45,7 +45,7 @@
 <http://bitbucket.org/birkenfeld/sphinx/get/tip.gz#egg=Sphinx-dev>`_.
 '''
 
-requires = ['Pygments>=1.2', 'Jinja2>=2.3', 'docutils>=0.7']
+requires = ['Pygments>=1.2', 'Jinja2>=2.3', 'docutils>=0.7', 'mercurial>=1.9.1']
 
 if sys.version_info < (2, 4):
     print('ERROR: Sphinx requires at least Python 2.4 to run.')
diff -r 9acbf8c69f2f sphinx/quickstart.py
--- a/sphinx/quickstart.py	Fri Sep 30 00:48:18 2011 -0400
+++ b/sphinx/quickstart.py	Fri Sep 30 00:56:12 2011 -0400
@@ -20,6 +20,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
 
 # function to get input from terminal -- overridden by the test suite
 try:
@@ -41,7 +42,7 @@
 # -*- coding: utf-8 -*-
 #
 # %(project)s documentation build configuration file, created by
-# sphinx-quickstart on %(now)s.
+# hgblog-quickstart on %(now)s.
 #
 # This file is execfile()d with the current directory set to its containing dir.
 #
@@ -80,17 +81,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.
@@ -104,7 +107,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
@@ -131,7 +139,7 @@
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-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
@@ -143,7 +151,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
@@ -286,10 +294,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.
@@ -333,35 +341,43 @@
 '''
 
 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
 #
 
 # You can set these variables from the command line.
 SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
+SPHINXBUILD   = hgblog-build
 PAPER         =
 BUILDDIR      = %(rbuilddir)s
 
@@ -521,7 +537,7 @@
 REM Command file for Sphinx documentation
 
 if "%%SPHINXBUILD%%" == "" (
-\tset SPHINXBUILD=sphinx-build
+\tset SPHINXBUILD=hgblog-build
 )
 set BUILDDIR=%(rbuilddir)s
 set ALLSPHINXOPTS=-d %%BUILDDIR%%/doctrees %%SPHINXOPTS%% %(rsrcdir)s
@@ -794,19 +810,28 @@
 
 
 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()
 
     if len(args) > 3:
-        print 'Usage: sphinx-quickstart [root]'
+        print 'Usage: hgblog-quickstart [root]'
         sys.exit(1)
     elif len(args) == 2:
         d['path'] = args[1]
 
-    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).'''
@@ -816,15 +841,15 @@
 Selected root path: %s''' % d['path'])
     else:
         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 the 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)
@@ -832,69 +857,17 @@
             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:'''
-    do_prompt(d, 'ext_autodoc', 'autodoc: automatically insert docstrings '
-              'from modules (y/N)', 'n', boolean)
-    do_prompt(d, 'ext_doctest', 'doctest: automatically test code snippets '
-              'in doctest blocks (y/N)', 'n', boolean)
-    do_prompt(d, 'ext_intersphinx', 'intersphinx: link between Sphinx '
-              'documentation of different projects (y/N)', 'n', boolean)
-    do_prompt(d, 'ext_todo', 'todo: write "todo" entries '
-              'that can be shown or hidden on build (y/N)', 'n', boolean)
-    do_prompt(d, 'ext_coverage', 'coverage: checks for documentation '
-              'coverage (y/N)', 'n', boolean)
     do_prompt(d, 'ext_pngmath', 'pngmath: include math, rendered '
               'as PNG images (y/N)', 'n', boolean)
     do_prompt(d, 'ext_jsmath', 'jsmath: include math, rendered in the '
@@ -908,7 +881,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)',
@@ -920,26 +893,46 @@
     d['underline'] = len(d['project']) * '='
     d['extensions'] = ', '.join(
         repr('sphinx.ext.' + name)
-        for name in ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
-                     'pngmath', 'jsmath', 'ifconfig', 'viewcode')
+        for name in ('pngmath', 'jsmath', 'ifconfig', 'viewcode')
         if d['ext_' + name])
     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', 'project_doc', 'project_doc_texescaped',
                 'author', 'author_texescaped', 'copyright',
-                'version', 'release', 'master'):
+                '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)
@@ -956,8 +949,6 @@
     conf_text = QUICKSTART_CONF % d
     if d['epub']:
         conf_text += EPUB_CONFIG % d
-    if d['ext_intersphinx']:
-        conf_text += INTERSPHINX_CONFIG
 
     f = open(path.join(srcdir, 'conf.py'), 'w', encoding='utf-8')
     f.write(conf_text)
@@ -968,6 +959,11 @@
     f.write(MASTER_FILE % d)
     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'
@@ -983,20 +979,13 @@
         f.write(BATCHFILE % d)
         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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.