Josh VanderLinden avatar Josh VanderLinden committed 6d9869f

Integrated mercurial into the quickstart wizard. Created a hook to HTMLize the .rst files that the repo is tracking.

Comments (0)

Files changed (3)

+# HG changeset patch
+# Parent c79013bbc6ad186639e0a3f901808f5f934e7c67
+
+diff --git a/hgblog/__init__.py b/hgblog/__init__.py
+new file mode 100644
+diff --git a/hgblog/generate_html.py b/hgblog/generate_html.py
+new file mode 100644
+--- /dev/null
++++ b/hgblog/generate_html.py
+@@ -0,0 +1,19 @@
++from mercurial.match import match
++from sphinx.cmdline import main as sphinxify
++
++def htmlize_articles(ui, repo, **kwargs):
++    """Calls on Sphinx to turn our .rst files into pretty HTML"""
++
++    # find all .rst files that Mercurial is currently tracking
++    m = match(repo.root, repo.getcwd(), ('*.rst',), default='relglob')
++    files_to_consider = repo[None].walk(m)
++
++    # tell Sphinx to HTML-ize the .rst files we found
++    sphinxify((
++        '-bdirhtml',
++        '-dbuild/doctrees',
++        'source',
++        'build/html',
++        ' '.join(files_to_consider),
++    ))
++
 # HG changeset patch
-# Parent 6cb09f68ce109215137d8b3c2079772770026763
+# Parent a3627c27a2f84b5a823bc585dc79c70e95c2193b
 
-diff -r 6cb09f68ce10 sphinx/quickstart.py
---- a/sphinx/quickstart.py	Thu Apr 22 07:30:37 2010 -0400
-+++ b/sphinx/quickstart.py	Thu Apr 22 08:00:59 2010 -0400
-@@ -74,9 +74,9 @@
+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.
  
  # The language for content autogenerated by Sphinx. Refer to documentation
  # for a list of supported languages.
-@@ -117,7 +117,7 @@
+@@ -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'.
  
  # 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 +129,7 @@
+@@ -129,7 +130,7 @@
  
  # The name for this set of Sphinx documents.  If None, it defaults to
  # "<project> v<release> documentation".
  
  # A shorter title for the navigation bar.  Default is the same as html_title.
  #html_short_title = None
-@@ -282,21 +282,20 @@
+@@ -282,21 +283,20 @@
  '''
  
  MASTER_FILE = '''\
  
  * :ref:`genindex`
  * :ref:`modindex`
-@@ -671,27 +670,35 @@
+@@ -671,27 +671,34 @@
  
  
  def inner_main(args):
 +    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).'''
++accept a default value, if one is given in brackets).
  
-     print '''
+-    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.'''
                                    translate(texescape.tex_escape_map)
  
      # escape backslashes and single quotes in strings that are put into
-@@ -836,7 +796,7 @@
+@@ -806,6 +766,28 @@
+     if not path.isdir(d['path']):
+         mkdir_p(d['path'])
  
-     if d['makefile']:
-         d['rsrcdir'] = d['sep'] and 'source' or '.'
--        d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
-+        d['rbuilddir'] = d['sep'] and 'html' or d['dot'] + 'html'
-         # use binary mode, to avoid writing \r\n on Windows
-         f = open(path.join(d['path'], 'Makefile'), 'wb')
-         f.write((MAKEFILE % d).encode('utf-8'))
-@@ -844,25 +804,14 @@
++    # 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']
  
-     if d['batchfile']:
-         d['rsrcdir'] = d['sep'] and 'source' or '.'
--        d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
-+        d['rbuilddir'] = d['sep'] and 'html' or d['dot'] + 'html'
-         f = open(path.join(d['path'], 'make.bat'), 'w')
+     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 '''
 rename_files.patch
 quickstart.patch
+hooks.patch
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.