hgblog / quickstart.patch

# HG changeset patch
# Parent d99b593d3b04399d0c3d1bfb217f2fedf94f8b5a

diff -r d99b593d3b04 setup.py
--- a/setup.py	Sat Apr 24 20:56:24 2010 -0400
+++ b/setup.py	Sat Apr 24 21:13:49 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 d99b593d3b04 sphinx/quickstart.py
--- a/sphinx/quickstart.py	Sat Apr 24 20:56:24 2010 -0400
+++ b/sphinx/quickstart.py	Sat Apr 24 21:13:49 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.
@@ -117,7 +120,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 +132,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 +235,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 +244,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 +285,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 +682,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 +717,12 @@
             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)
+    do_prompt(d, 'enable_comments', 'Would you like to enable Disqus comments '
+              'on your pages?', 'y', boolean)
+    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 +749,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 +767,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 +831,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 +851,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:
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.