From d36f3358496b505a94ae49fc968497412dccc560 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 24 Jul 2011 11:37:33 +0100 Subject: Make publish-docs publish manpages as well (from cwd, not build area). --- unperish | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/unperish b/unperish index 0feb3dc..40b3038 100755 --- a/unperish +++ b/unperish @@ -24,6 +24,7 @@ import logging import os import shutil import subprocess +import tempfile __version__ = '0.0' @@ -234,18 +235,30 @@ class Unperish(cliapp.Application): def cmd_publish_docs(self, args): '''Publish docs related to this project.''' + + def publish(source, target_base): + target = os.path.join(self.settings['web-directory'], target_base) + if self.settings['verbose']: + print 'Copying %s to %s' % (source, target) + shutil.copyfile(source, target) if not self.settings['web-directory']: raise cliapp.AppException('Need --web-directory ' 'for publish-docs.') + docs = ['README', 'NEWS'] for doc in docs: if os.path.exists(doc): - target = os.path.join(self.settings['web-directory'], - doc + '.mdwn') - if self.settings['verbose']: - print 'Copying %s to %s' % (doc, target) - shutil.copyfile(doc, target) + publish(doc, doc + '.mdwn') + + for manpage in glob.glob('*.[1-8]'): + fmt = self.runcmd(['man', '-l', manpage]) + text = self.runcmd(['col', '-b'], stdin=fmt) + fd, name = tempfile.mkstemp() + os.write(fd, text) + os.close(fd) + publish(name, manpage + '.txt') + os.remove(name) def cmd_clean(self, args): '''Clean up the build-area (remove everything except the dir).''' -- cgit v1.2.1