1. Josh VanderLinden
  2. hgblog

Source

hgblog / quickstart.patch

# HG changeset patch
# Parent a3627c27a2f84b5a823bc585dc79c70e95c2193b

diff -r a3627c27a2f8 sphinx/quickstart.py
--- a/sphinx/quickstart.py	Thu Apr 22 13:01:32 2010 -0400
+++ b/sphinx/quickstart.py	Thu Apr 22 14:12:15 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 = '> '
@@ -74,9 +75,9 @@
 # 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.
@@ -117,7 +118,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 = 'basic'
 
 # 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 +130,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
@@ -282,21 +283,20 @@
 '''
 
 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
-==================
+Links
+=====
 
 * :ref:`genindex`
 * :ref:`modindex`
@@ -671,27 +671,34 @@
 
 
 def inner_main(args):
-    d = {}
+    d = {
+        'sep': True,
+        'dot': '_',
+        'version': '',
+        'release': '',
+        'suffix': '.rst',
+        'master': 'index',
+        'epub': False,
+    }
     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 +706,9 @@
             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)
-
-    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')
+The blog name will occur in several places in the HTML.'''
+    do_prompt(d, 'project', 'Blog 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)
 
     print '''
 Please indicate if you want to use one of the following Sphinx extensions:'''
@@ -775,7 +735,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,8 +753,8 @@
     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
@@ -806,6 +766,28 @@
     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)
@@ -849,20 +831,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: